add method generate queue name from subject name

This commit is contained in:
namhq1989 2022-12-16 10:51:21 +07:00
parent 21a288d927
commit 239346a435
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package natsio
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strings"
"github.com/thoas/go-funk" "github.com/thoas/go-funk"
) )
@ -30,6 +31,10 @@ func GenerateReqrepSubject(stream, server, subject string) string {
return fmt.Sprintf("%s.reqrep.%s.%s", stream, server, subject) return fmt.Sprintf("%s.reqrep.%s.%s", stream, server, subject)
} }
func GenerateQueueNameFromSubject(subject string) string {
return strings.ReplaceAll(subject, ".", "_")
}
// InterfaceToBytes ... // InterfaceToBytes ...
func InterfaceToBytes(data interface{}) []byte { func InterfaceToBytes(data interface{}) []byte {
b, err := json.Marshal(data) b, err := json.Marshal(data)