bend-kit-gateway Releases (3): 0.3.0.0 0x3157e95854f8621cff1d5c072e645c5a indexed https://jend.leeeet.dev/files.txt?path=bend-kit-gateway@0.3.0.0 0.2.0.0 0x355ace97f1dc7e8b51a103b29e4261e5 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-gateway@0.2.0.0 0.1.0.0 0xeba4d7101841619deee190a6047352c2 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-gateway@0.1.0.0 Definitions (21): Gateway.Gate (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=Gate) # The shared state of one gateway. `held` joins every unit that the pool lent # and that no finish has given back yet. type Gate is Type: Gate{pool: Res.Pool, held: Res.Grant, cache: C.Cache} Gateway.Pending (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=Pending) # A fetch in flight, as copyable data, so it can cross to the request task and back. type Pending is Data: Pending{key: String, gen: Nat, at: Nat} Gateway.Upstream (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=Upstream) # What the upstream fetch did. Failed covers an upstream error, a spent budget, and an open breaker. type Upstream is Data: Fetched{found: C.Found} Failed{} Gateway.Begin (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=Begin) type Begin is Type: Denied{gate: Gate} Busy{gate: Gate} Fresh{gate: Gate, entry: C.Entry} Fetch{gate: Gate, pending: Pending} Gateway.Finish (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=Finish) type Finish is Type: Settled{gate: Gate} Unheld{gate: Gate} Gateway.new (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=new) # An empty gateway: `capacity` requests at once, and an empty cache. def new(+owner: Nat, capacity: Nat, policy: C.Policy) -> Gate: Gateway.give.released (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=give.released) def give.released(r: Res.Release, rest: Res.Grant, cache: C.Cache) -> Finish: Gateway.give.split (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=give.split) def give.split(s: Res.Split, pool: Res.Pool, cache: C.Cache) -> Finish: Gateway.give (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=give) # Gives one lent unit back to the pool. Unheld means that no unit was lent. def give(pool: Res.Pool, held: Res.Grant, cache: C.Cache) -> Finish: Gateway.start.ticket (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=start.ticket) # Starts a fetch of key at clock `at`, as data. def start.ticket(r: C.Ticket & C.Cache) -> Pending & C.Cache: Gateway.start (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=start) def start(cache: C.Cache, +key: String, at: Nat) -> Pending & C.Cache: Gateway.settle (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=settle) # Stores what a fetch found. A failed fetch stores nothing. def settle(cache: C.Cache, p: Pending, u: Upstream) -> C.Cache: Gateway.begin.fetch (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.fetch) def begin.fetch(pool: Res.Pool, held: Res.Grant, r: Pending & C.Cache) -> Begin: Gateway.begin.refund (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.refund) # The joined grant names another pool: give the new unit back and refuse. def begin.refund(r: Res.Release, held: Res.Grant, cache: C.Cache) -> Begin: Gateway.begin.fresh (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.fresh) def begin.fresh(f: Finish, e: C.Entry) -> Begin: Gateway.begin.read (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.read) def begin.read(m: Maybe<&2, C.Entry>, pool: Res.Pool, held: Res.Grant, cache: C.Cache, +key: String, +now: Nat) -> Begin: Gateway.begin.joined (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.joined) def begin.joined(j: Res.Combine, pool: Res.Pool, +cache: C.Cache, +key: String, +now: Nat) -> Begin: Gateway.begin.took (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.took) def begin.took(r: Res.Reserve, held: Res.Grant, cache: C.Cache, +key: String, +now: Nat) -> Begin: Gateway.begin.granted (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin.granted) def begin.granted(ok: Bool, gate: Gate, +key: String, +now: Nat) -> Begin: Gateway.begin (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=begin) # Authorizes req, takes one unit, and reads key at `now`. Fresh has given its # unit back; Fetch keeps it until finish. def begin(policy: Az.Policy, req: Az.Request, gate: Gate, +key: String, +now: Nat) -> Begin: Gateway.finish (https://jend.leeeet.dev/definition.txt?path=bend-kit-gateway@0.3.0.0/gateway.bend&name=finish) # Stores what the fetch did and gives its unit back. def finish(gate: Gate, p: Pending, u: Upstream) -> Finish: