diff --git a/cli/bench_command.go b/cli/bench_command.go index e79c39e7..8d019fde 100644 --- a/cli/bench_command.go +++ b/cli/bench_command.go @@ -62,6 +62,7 @@ type benchCmd struct { fetchTimeout bool multiSubject bool multiSubjectMax int + multisubjectFormat string deDuplication bool deDuplicationWindow time.Duration ack bool @@ -453,7 +454,7 @@ func (c *benchCmd) getPublishSubject(number int) string { if c.multiSubjectMax == 0 { return c.subject + "." + strconv.Itoa(number) } else { - return c.subject + "." + strconv.Itoa(number%c.multiSubjectMax) + return c.subject + "." + fmt.Sprintf(c.multisubjectFormat, number%c.multiSubjectMax) } } else { return c.subject @@ -1546,6 +1547,8 @@ func (c *benchCmd) coreNATSPublisher(nc *nats.Conn, progress *uiprogress.Bar, ms }) } + c.multisubjectFormat = fmt.Sprintf("%%0%dd", len(strconv.Itoa(c.multiSubjectMax))) + for i := 0; i < numMsg; i++ { if progress != nil { progress.Incr() @@ -1575,6 +1578,8 @@ func (c *benchCmd) coreNATSRequester(nc *nats.Conn, progress *uiprogress.Bar, ms }) } + c.multisubjectFormat = fmt.Sprintf("%%0%dd", len(strconv.Itoa(c.multiSubjectMax))) + for i := 0; i < numMsg; i++ { if progress != nil { progress.Incr() @@ -1610,6 +1615,8 @@ func (c *benchCmd) jsPublisher(nc *nats.Conn, progress *uiprogress.Bar, msg []by }) } + c.multisubjectFormat = fmt.Sprintf("%%0%dd", len(strconv.Itoa(c.multiSubjectMax))) + if c.batchSize != 1 { for i := 0; i < numMsg; { state = "Publishing"