Opsmaru.Incus.Gateway.Admission (opsmaru_incus v0.1.0)

Copy Markdown View Source

Host-started bounded admission for gateway exchanges.

Add {Opsmaru.Incus.Gateway.Admission, name: MyHost.GatewayAdmission, max_exchanges: 64} to the host's supervision tree when mounting the gateway; the library never starts it. Each relayed exchange holds one slot from before host callbacks run until its backend socket is closed. At capacity a request is rejected immediately: nothing is queued and no backend is opened.

Slots are tied to the holding process and released when it exits. A relay monitors the admission process and stops its own backend socket if admission stops or restarts, so a restart never leaves untracked backend traffic. Status and crash reports show only counts.

Summary

Functions

Take one slot for holder. Returns {:ok, slot}, {:error, :capacity} or {:error, :unavailable} when admission is not running.

Returns a specification to start this module under a supervisor.

Current number of held slots.

Release a slot. Idempotent; exiting holders are released automatically.

Move an existing slot to its protocol owner without reacquiring capacity.

Functions

acquire(admission, holder \\ self(), timeout \\ 1000)

Take one slot for holder. Returns {:ok, slot}, {:error, :capacity} or {:error, :unavailable} when admission is not running.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count(admission)

Current number of held slots.

release(arg)

Release a slot. Idempotent; exiting holders are released automatically.

start_link(opts)

transfer(arg, holder)

Move an existing slot to its protocol owner without reacquiring capacity.