Skip to content

Commit

Permalink
Merge pull request #356 from testwill/time
Browse files Browse the repository at this point in the history
chore: use time.Since instead of time.Now().Sub
  • Loading branch information
mreiferson authored Jul 16, 2023
2 parents c647fa6 + d9c722e commit 14c9d1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 14c9d1d

Please sign in to comment.