Spectre.Instance.Registry (Spectre v0.3.0)

Copy Markdown View Source

Race-safe local lookup for Agent Instances.

Registry entries are keyed only by Spectre.Instance.Ref; process names, channel identities, and conversation ids are never used as identity proof.

Summary

Functions

Starts or returns the unique supervised Instance for an Agent and Subject.

Returns the live local Instance for an Agent and Subject.

Returns the :via name for a logical Instance reference.

Functions

ensure_started(supervisor, agent, subject, opts \\ [])

Starts or returns the unique supervised Instance for an Agent and Subject.

lookup(agent, subject, registry \\ __MODULE__)

@spec lookup(module() | Spectre.AgentRef.t(), Spectre.Subject.t() | term(), atom()) ::
  {:ok, pid()} | {:error, :instance_not_found}

Returns the live local Instance for an Agent and Subject.

via(ref, registry \\ __MODULE__)

@spec via(Spectre.Instance.Ref.t(), atom()) ::
  {:via, Registry, {atom(), String.t(), Spectre.Instance.Ref.t()}}

Returns the :via name for a logical Instance reference.