def Lease.held

bend-kube-runtime@0.2.0.0 · src/lease.bend:75

import bend-kube-runtime@0.2.0.0/src/lease.bend as Lease
import Base
import bend-kube-runtime@0.2.0.0/src/json.bend as J

75# Whether another holder's lease is still live by our clock.
76def Lease.held(+l: J.Json, +me: String, o: Obs, +now: U32, +dur: U32) -> Bool:
77  match o:
78    case Obs{h, r, +at}:
79      Bool.and(Bool.not(String.is_empty(Lease.holder(l))),
80        Bool.and(Bool.not(String.eq(Lease.holder(l), me)),
81          U32.is_lt((now - at : U32), (dur * 1000 : U32))))

Uses (13)

Used by (1)