36 lines
919 B
Go
36 lines
919 B
Go
package natsio
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/thoas/go-funk"
|
|
)
|
|
|
|
// mergeAndUniqueArrayStrings ...
|
|
func mergeAndUniqueArrayStrings(arr1, arr2 []string) []string {
|
|
var result = make([]string, 0)
|
|
result = append(result, arr1...)
|
|
result = append(result, arr2...)
|
|
result = funk.UniqString(result)
|
|
return result
|
|
}
|
|
|
|
// generateSubjectNames ...
|
|
func generateSubjectNames(streamName string, subjects []string) []string {
|
|
var result = make([]string, 0)
|
|
for _, subject := range subjects {
|
|
name := combineStreamAndSubjectName(streamName, subject)
|
|
result = append(result, name)
|
|
}
|
|
return result
|
|
}
|
|
|
|
func combineStreamAndSubjectName(stream, subject string) string {
|
|
return fmt.Sprintf("%s.%s", stream, subject)
|
|
}
|
|
|
|
// GenerateSubjectByClientType ...
|
|
func GenerateSubjectByClientType(subject string) string {
|
|
return fmt.Sprintf("%s.%s.%s.%s", globalConfig.StreamName, globalConfig.Server, globalConfig.Service, subject)
|
|
}
|