Skip to content

Commit

Permalink
Add deleteActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Aug 26, 2019
1 parent 2e153f7 commit 310fa5b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/router/managed_routing_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ func (rt *managedRoutingTable) Cleanup() error {
return err
}

return rt.DeleteRules(expiredIDs...)
if err := rt.DeleteRules(expiredIDs...); err != nil {
return err
}

rt.deleteActivity(expiredIDs...)
}

// ruleIsExpired checks whether rule's keep alive timeout is exceeded.
Expand All @@ -82,3 +86,11 @@ func (rt *managedRoutingTable) ruleIsTimedOut(routeID routing.RouteID, rule rout
lastActivity, ok := rt.activity[routeID]
return !ok || time.Since(lastActivity) > rule.KeepAlive()
}

// deleteActivity removes activity records for the specified set of `routeIDs`.
// NOTE: for internal use, is NOT thread-safe, object lock should be acquired outside
func (rt *managedRoutingTable) deleteActivity(routeIDs ...routing.RouteID) {
for _, rID := range routeIDs {
delete(rt.activity, rID)
}
}

0 comments on commit 310fa5b

Please sign in to comment.