Camber.drain.message: def of bend-kit-camber@0.15.0.1 Import: import bend-kit-camber@0.15.0.1/camber.bend as Camber Lines 106-123 of bend-kit-camber@0.15.0.1/camber.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-camber@0.15.0.1/camber.bend&start_line=106&end_line=123 import Base # Closing Base channels retains buffered messages. Drain them and answer stopped # callers, rather than stranding accepted commands behind the close command. def drain.message(~R: Type, ~P: Data, ~I: Data, ~E: Data, ~O: Data, ~destroy: R -> IO(Unit), message: Message ) -> IO(Unit): match message: case Submit{principal, input, reply}: do IO: sent : Result<&1, &1, Outcome, Unit> <- Chan.send(Outcome, reply, Stopped{}) return Unit{} case Inspect{reply}: Chan.close(Counts, reply) case Shutdown{reply}: do IO: sent : Result<&1, &1, CloseResult, Unit> <- Chan.send(CloseResult, reply, Closed{}) return Unit{} case Returned{resource}: destroy(resource) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan.close https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan.send https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-kit-camber@0.15.0.1/camber.bend&name=CloseResult https://jend.leeeet.dev/definition.txt?path=bend-kit-camber@0.15.0.1/camber.bend&name=Counts https://jend.leeeet.dev/definition.txt?path=bend-kit-camber@0.15.0.1/camber.bend&name=Message https://jend.leeeet.dev/definition.txt?path=bend-kit-camber@0.15.0.1/camber.bend&name=Outcome