pub fn evaluate(
state: &RoleState,
me: &MemberId,
now_millis: i64,
config: &LeaseConfig,
) -> DecisionExpand description
Decides what me does about the role of state at now_millis.
The rules are:
- A member that is not in the roster gets
Decision::NotRegistered. It has no rank, because rank comes from the registration record. - A member that the lease names, while that lease is live, gets
Decision::Hold. - A challenger of rank
ngetsDecision::Challengefromdeadline + n * challenge_staggeron. With no lease, the anchor is the registration instant of the member instead of a deadline, so rank 0 challenges at once and ranknchallengesnstaggers later. - Every other member gets
Decision::Wait, and the instant it carries is the earliest instant at which this answer changes for an unchanged role state.
The anchor of rule 3 always comes from the role state and never from
now_millis. A member that has no lease to wait for anchors on its own
registration record. An anchor of “now plus n staggers” would move forward
on every evaluation, and a standby of rank 1 or more would then wait for
ever while rank 0 is dead.
The member of an expired lease keeps rank 0, so it reclaims its own role at
its own deadline. See RoleState::rank_of.
A caller re-evaluates when it reads a new record, and at the latest at the
instant that Decision::Wait names.