MCPcopy
hub / github.com/nats-io/nats.go / RTT

Method RTT

nats.go:5839–5851  ·  view source on GitHub ↗

RTT calculates the round trip time between this client and the server.

()

Source from the content-addressed store, hash-verified

5837
5838// RTT calculates the round trip time between this client and the server.
5839func (nc *Conn) RTT() (time.Duration, error) {
5840 if nc.IsClosed() {
5841 return 0, ErrConnectionClosed
5842 }
5843 if nc.IsReconnecting() {
5844 return 0, ErrDisconnected
5845 }
5846 start := time.Now()
5847 if err := nc.FlushTimeout(10 * time.Second); err != nil {
5848 return 0, err
5849 }
5850 return time.Since(start), nil
5851}
5852
5853// Flush will perform a round trip to the server and return when it
5854// receives the internal reply.

Callers 2

TestGetRTTFunction · 0.80
TestInProcessConnFunction · 0.80

Calls 3

IsClosedMethod · 0.95
IsReconnectingMethod · 0.95
FlushTimeoutMethod · 0.95

Tested by 2

TestGetRTTFunction · 0.64
TestInProcessConnFunction · 0.64