In-progress blob upload sessions for the registry server.
A registry blob upload is the one inherently stateful part of the /v2 API: a client opens a
session, streams chunks (PATCH), then finalizes (PUT) with the expected digest. This
GenServer holds each session's accumulated bytes keyed by a UUID, and sweeps sessions that
have been idle longer than :ttl (so abandoned uploads don't leak memory).
Started by Stevedore.Server; not part of the weightless core.
Summary
Functions
Appends chunk to a session, returning the new total size.
Cancels and discards a session.
Returns a specification to start this module under a supervisor.
Opens a new upload session, returning its UUID.
Finalizes a session: removes it and returns the accumulated bytes.
Current accumulated size of a session.
Starts the session store. Options: :name, :ttl (ms).
Removes sessions idle longer than the TTL. Runs periodically; exposed for tests.
Types
@type uuid() :: String.t()
Functions
@spec append(GenServer.server(), uuid(), iodata(), non_neg_integer() | nil) :: {:ok, non_neg_integer()} | {:error, :unknown_session | :bad_range}
Appends chunk to a session, returning the new total size.
at is the offset the chunk claims to start at (from a Content-Range header). When given, it
must equal the session's current size or the append is rejected with {:error, :bad_range} and
the session is left untouched — the distribution-spec requires chunks to arrive in order
(out-of-order or retried chunks yield 416). Pass nil to append unconditionally (streamed
uploads with no range).
@spec cancel(GenServer.server(), uuid()) :: :ok
Cancels and discards a session.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create(GenServer.server()) :: {:ok, uuid()}
Opens a new upload session, returning its UUID.
@spec finish(GenServer.server(), uuid()) :: {:ok, binary()} | {:error, :unknown_session}
Finalizes a session: removes it and returns the accumulated bytes.
@spec size(GenServer.server(), uuid()) :: {:ok, non_neg_integer()} | {:error, :unknown_session}
Current accumulated size of a session.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the session store. Options: :name, :ttl (ms).
@spec sweep(GenServer.server()) :: :ok
Removes sessions idle longer than the TTL. Runs periodically; exposed for tests.