Skip to content

Commit

Permalink
Merge pull request #876 from boris-ilijic/rtt-verbose-mode
Browse files Browse the repository at this point in the history
Feature: RTT command verbose mode
  • Loading branch information
ripienaar authored Sep 25, 2023
2 parents 191856b + 8f2888e commit e972a82
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cli/rtt_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,22 @@ func (c *rttCmd) calcRTT(server string, copts []nats.Option) (string, time.Durat

var totalTime time.Duration

if opts.Trace {
fmt.Printf("RTT iterations for server: %s\n", server)
}
for i := 1; i <= c.iterations; i++ {
rtt, err := nc.RTT()
if err != nil {
return "", 0, fmt.Errorf("rtt failed: %v", err)
}

totalTime += rtt
if opts.Trace {
fmt.Printf("#%d:\trtt=%s\n", i, rtt)
if i == c.iterations {
fmt.Println()
}
}
}

return nc.ConnectedUrl(), totalTime / time.Duration(c.iterations), nil
Expand Down

0 comments on commit e972a82

Please sign in to comment.