package natsio import ( "encoding/json" "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) } // GenerateJetStreamSubject ... // GenerateJetStreamSubject("admin", "help_center", "get_ticket_by_id") func GenerateJetStreamSubject(server, service, subject string) string { return fmt.Sprintf("%s.jetstream.%s.%s.%s", globalConfig.StreamName, server, service, subject) } // GenerateReqrepSubject ... // GenerateReqrepSubject("admin", "help_center", "get_ticket_by_id") func GenerateReqrepSubject(server, service, subject string) string { return fmt.Sprintf("%s.reqrep.%s.%s.%s", globalConfig.StreamName, server, service, subject) } // ToBytes ... func ToBytes(data interface{}) []byte { b, err := json.Marshal(data) if err != nil { fmt.Printf("[natsio.ToBytes] error: %v with data: %v\n", err, data) } return b }