def Lease.held
import bend-kube-runtime@0.2.0.0/src/lease.bend as Leaseimport 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))))