Skip to content

Commit

Permalink
Improve new JS API fetch error logging
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
  • Loading branch information
jnmoyne committed Apr 28, 2024
1 parent c37fd0e commit edca0ac
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions cli/bench_command.go
Expand Up @@ -1212,24 +1212,30 @@ func (c *benchCmd) runSubscriber(bm *bench.Benchmark, nc *nats.Conn, startwg *sy

if c.newJSAPI {
if c.pull {
msgs, err := consumer.Fetch(batchSize)
if err == nil && msgs.Error() == nil {
if progress != nil {
state = "Fetching "
consumer.Messages()
}
msgs, err := consumer.Fetch(batchSize)
if err != nil {
if c.noProgress {
if err == nats.ErrTimeout {
log.Print("Fetch timeout!")
} else {
log.Printf("New consumer Fetch error: %v", err)
}
c.fetchTimeout = true
}

for msg := range msgs.Messages() {
mh2(msg)
i++
}
} else {
if c.noProgress {
if err == nats.ErrTimeout {
log.Print("Fetch timeout!")
} else {
log.Printf("New consumer Fetch error: %v", err)
}
}
if progress != nil {
state = "Fetching "
}

for msg := range msgs.Messages() {
mh2(msg)
i++
}

if msgs.Error() != nil {
log.Printf("New consumer Fetch msgs error: %v", msgs.Error())
c.fetchTimeout = true
}
}
Expand Down

0 comments on commit edca0ac

Please sign in to comment.