add reconnect duration allows for verifying disconnect intervals (#15306)

This commit is contained in:
Harshavardhana 2022-07-15 14:41:24 -07:00 committed by GitHub
parent 4aecd8d039
commit 785b429737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -242,8 +242,10 @@ func (c *Client) MarkOffline() bool {
} }
if c.HealthCheckFn() { if c.HealthCheckFn() {
if atomic.CompareAndSwapInt32(&c.connected, offline, online) { if atomic.CompareAndSwapInt32(&c.connected, offline, online) {
logger.Info("Client %s online", c.url.String()) now := time.Now()
atomic.StoreInt64(&c.lastConn, time.Now().UnixNano()) disconnected := now.Sub(c.LastConn())
logger.Info("Client '%s' re-connected in %s", c.url.String(), disconnected)
atomic.StoreInt64(&c.lastConn, now.UnixNano())
} }
return return
} }