mirror of
https://github.com/hanzoai/psrpc.git
synced 2026-09-30 23:47:22 +00:00
fix topic length check (#89)
This commit is contained in:
@@ -115,7 +115,7 @@ func formatServerChannel(service string, topic []string, queue bool) string {
|
||||
defer scratch.Put(p)
|
||||
b := append(*p, "SRV."...)
|
||||
b = append(b, service...)
|
||||
if channelPartsLen(topic) > 0 {
|
||||
if stringSliceLen(topic) > 0 {
|
||||
b = append(b, '.')
|
||||
b = appendChannelParts(b, '.', topic...)
|
||||
}
|
||||
@@ -125,6 +125,14 @@ func formatServerChannel(service string, topic []string, queue bool) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func stringSliceLen(s []string) int {
|
||||
var n int
|
||||
for i := range s {
|
||||
n += len(s[i])
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func formatChannel(delim byte, parts ...any) string {
|
||||
buf := make([]byte, 0, 4*channelPartsLen(parts...)/3)
|
||||
return string(appendChannelParts(buf, delim, parts...))
|
||||
|
||||
Reference in New Issue
Block a user