diff --git a/conn.go b/conn.go index 0c382550..321da690 100644 --- a/conn.go +++ b/conn.go @@ -692,7 +692,7 @@ func (c *Conn) cleanup() { msgsInFlight = atomic.LoadInt64(&c.messagesInFlight) } if msgsInFlight > 0 { - if time.Now().Sub(lastWarning) > time.Second { + if time.Since(lastWarning) > time.Second { c.log(LogLevelWarning, "draining... waiting for %d messages in flight", msgsInFlight) lastWarning = time.Now() } @@ -701,7 +701,7 @@ func (c *Conn) cleanup() { // until the readLoop has exited we cannot be sure that there // still won't be a race if atomic.LoadInt32(&c.readLoopRunning) == 1 { - if time.Now().Sub(lastWarning) > time.Second { + if time.Since(lastWarning) > time.Second { c.log(LogLevelWarning, "draining... readLoop still running") lastWarning = time.Now() } diff --git a/consumer.go b/consumer.go index 895c89a5..390002a6 100644 --- a/consumer.go +++ b/consumer.go @@ -1033,8 +1033,8 @@ func (r *Consumer) redistributeRDY() { possibleConns := make([]*Conn, 0, len(conns)) for _, c := range conns { - lastMsgDuration := time.Now().Sub(c.LastMessageTime()) - lastRdyDuration := time.Now().Sub(c.LastRdyTime()) + lastMsgDuration := time.Since(c.LastMessageTime()) + lastRdyDuration := time.Since(c.LastRdyTime()) rdyCount := c.RDY() r.log(LogLevelDebug, "(%s) rdy: %d (last message received %s)", c.String(), rdyCount, lastMsgDuration)