Skip to content

Commit

Permalink
Make ShouldDeduplicate more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jul 20, 2023
1 parent b5f4200 commit 23de526
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bridge/status/bridgestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ func (pong *BridgeState) SendHTTP(ctx context.Context, url, token string) error
}

func (pong *BridgeState) ShouldDeduplicate(newPong *BridgeState) bool {
if pong == nil || pong.StateEvent != newPong.StateEvent || pong.Error != newPong.Error || !maps.EqualFunc(pong.Info, newPong.Info, reflect.DeepEqual) {
return false
}
return pong.Timestamp.Add(time.Duration(pong.TTL) * time.Second).After(time.Now())
return pong != nil &&
pong.StateEvent == newPong.StateEvent &&
pong.Error == newPong.Error &&
maps.EqualFunc(pong.Info, newPong.Info, reflect.DeepEqual) &&
pong.Timestamp.Add(time.Duration(pong.TTL)*time.Second).After(time.Now())
}

0 comments on commit 23de526

Please sign in to comment.