Obscura.Profile.Preparer (obscura v0.1.0)

Copy Markdown View Source

Supervised asynchronous preparation and ownership of a reusable profile runtime.

Add the preparer to an application supervision tree, then query status/1 or call await/2 before accepting work which requires the model-backed profile. The process prepares exactly once and retains the runtime for reuse. status/1 exposes the latest report-safe preparation event while large model assets download or load. Download authorization and offline behavior come from the :prepare_options passed to start_link/1.

Summary

Functions

Waits for preparation and returns the reusable runtime or diagnostic.

Returns a specification to start this module under a supervisor.

Returns the reusable runtime when preparation is complete.

Starts a supervised profile preparer.

Returns readiness and the latest safe progress event.

Subscribes the caller to progress and completion messages.

Types

server()

@type server() :: GenServer.server()

status()

@type status() :: :preparing | :ready | :failed

Functions

await(server, timeout \\ 30000)

@spec await(server(), timeout()) ::
  {:ok, Obscura.Profile.Runtime.t()} | {:error, Obscura.Diagnostic.t()}

Waits for preparation and returns the reusable runtime or diagnostic.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

runtime(server)

@spec runtime(server()) ::
  {:ok, Obscura.Profile.Runtime.t()}
  | {:error, :not_ready | Obscura.Diagnostic.t()}

Returns the reusable runtime when preparation is complete.

start_link(opts)

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

Starts a supervised profile preparer.

status(server)

@spec status(server()) :: map()

Returns readiness and the latest safe progress event.

subscribe(server)

@spec subscribe(server()) :: :ok

Subscribes the caller to progress and completion messages.