LLMProxy.Drain (llm_proxy v0.1.0)

Copy Markdown View Source

Runtime drain control for deployment-safe LLMProxy shutdowns.

Drain mode is an operational state: new user work is rejected while existing work is allowed to finish. Control is exposed through local RPC/release tasks, not through public HTTP routes.

Summary

Types

ref()

@type ref() :: reference()

status()

@type status() :: %{
  draining: boolean(),
  ready: boolean(),
  serving: boolean(),
  active: %{
    total: non_neg_integer(),
    requests: non_neg_integer(),
    streams: non_neg_integer(),
    agents: non_neg_integer()
  }
}

work_kind()

@type work_kind() :: :request | :stream | :agent

Functions

await_empty(timeout \\ 30000)

@spec await_empty(timeout()) :: :ok | {:error, :timeout}

cancel()

@spec cancel() :: status()

child_spec(opts)

@spec child_spec(keyword()) :: Supervisor.child_spec()

draining?()

@spec draining?() :: boolean()

enter(kind \\ :request, meta \\ %{})

@spec enter(work_kind(), map()) :: {:ok, ref()} | {:error, :draining}

leave(ref)

@spec leave(ref()) :: :ok

start(opts \\ [])

@spec start(keyword()) :: status()

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

status()

@spec status() :: status()

track(kind \\ :request, meta \\ %{}, fun)

@spec track(work_kind(), map(), (-> result)) :: result | {:error, :draining}
when result: term()