~/bend-docscommunity

src/lease.bend checks

raw source on the hub · import bend-kube-runtime@0.3.0.0/src/lease.bend as Lease

3 imports
import Base
import ./json.bend as J
import ./core.bend as C

Types

type Obs source · line 24 · raw

Data

What we last saw of the record, and when (our clock, in ms).

type LeaseAct source · line 27 · raw

Data

type Decision source · line 32 · raw

Data

Definitions

def Obs.none source · line 35 · raw

Obs

def Lease.spec source · line 38 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @field:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

def Lease.holder source · line 41 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> String

def Lease.renew_time source · line 44 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> String

def Lease.transitions source · line 47 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> U32

def Lease.new_spec source · line 50 · raw

@id:String -> @+dur:U32 -> @acquire:String -> @renew:String -> @+trans:U32 -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

def Lease.fresh source · line 56 · raw

@ns:String -> @name:String -> @id:String -> @+dur:U32 -> @+now:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

A fresh Lease naming us.

def Lease.elapsed.go source · line 61 · raw

@+d:U32 -> @back:Bool -> U32

def Lease.elapsed source · line 71 · raw

@+now:U32 -> @+at:U32 -> U32

Time since an observation, by our clock: a clock that stepped back (now before at, by the wrapped difference) counts as no time at all, so a clock step can never make a live lease look expired.

def Lease.observe.same source · line 74 · raw

@o:Obs -> @+now:U32 -> @back:Bool -> Obs

def Obs.at source · line 82 · raw

@o:Obs -> U32

def Lease.observe.go source · line 87 · raw

@h:String -> @r:String -> @+o:Obs -> @+now:U32 -> @same:Bool -> Obs

def Lease.observe source · line 96 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @o:Obs -> @+now:U32 -> Obs

The record seen now: the old observation if nothing changed, else a new one stamped now.

def Lease.held source · line 103 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+me:String -> @o:Obs -> @+now:U32 -> @+dur:U32 -> Bool

Whether another holder's lease is still live by our clock.

def Lease.take.go source · line 110 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @me:String -> @+dur:U32 -> @+now:String -> @ours:Bool -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

def Lease.take source · line 119 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+me:String -> @+dur:U32 -> @+now:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

The Lease rewritten to name us, keeping its metadata (resourceVersion).

def Lease.decide.fin source · line 122 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+me:String -> @o:Obs -> @+dur:U32 -> @+now:String -> @held:Bool -> Decision

def Lease.decide.held source · line 130 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+me:String -> @+o:Obs -> @+now_ms:U32 -> @+dur:U32 -> @+now:String -> Decision

def Lease.decide.got source · line 134 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+me:String -> @o:Obs -> @+now_ms:U32 -> @+dur:U32 -> @+now:String -> Decision

def Lease.decide source · line 140 · raw

@cur:Maybe<&2, 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json> -> @ns:String -> @name:String -> @+me:String -> @o:Obs -> @+now_ms:U32 -> @+dur:U32 -> @+now:String -> Decision

One round: the Lease read (None when absent), us, what we saw before, our clock in ms, the lease duration in seconds, and the time to stamp.

def Lease.release source · line 150 · raw

@+l:0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json -> @+now:String -> 0xd9b268abd125fd306c83ea43554e4f2c/src/json.Json

The Lease handed back: no holder, a one-second duration, so the next candidate takes it at once (client-go's ReleaseOnCancel).