Skip to main content

lease_action

Function lease_action 

Source
pub fn lease_action(policy: TakeoverPolicy, held_by_other: bool) -> LeaseAction
Expand description

Decide the lease action. held_by_other is true when a different owner currently holds the maintenance lease for this repository.

use kopiur_api::{lease_action, LeaseAction, TakeoverPolicy};

// Free (or already ours) → always claim, regardless of policy.
assert_eq!(lease_action(TakeoverPolicy::Never, false), LeaseAction::Claim);
// Held by another → dispatch on policy.
assert_eq!(lease_action(TakeoverPolicy::Never, true), LeaseAction::Yield);
assert_eq!(lease_action(TakeoverPolicy::Force, true), LeaseAction::Takeover);