natsio/utils.go

31 lines
711 B
Go
Raw Permalink Normal View History

2021-10-08 05:00:03 +00:00
package natsio
2021-10-08 07:41:58 +00:00
import (
"fmt"
"github.com/thoas/go-funk"
)
2021-10-08 05:00:03 +00:00
// 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
}
2021-10-08 07:41:58 +00:00
// 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)
}