Jido.Signal.Instance (Jido Signal v2.2.1)

View Source

Manages instance-scoped signal infrastructure.

Provides a child_spec for starting instance-scoped supervisors that mirror the global signal infrastructure but are isolated to a specific instance.

Usage

Add to your application's supervision tree:

children = [
  # Global signal infrastructure starts automatically via application.ex

  # Instance-scoped infrastructure
  {Jido.Signal.Instance, name: MyApp.Jido}
]

Supervisor.start_link(children, strategy: :one_for_one)

Then use the jido: option to route operations through your instance:

{:ok, bus} = Jido.Signal.Bus.start_link(
  name: :my_bus,
  jido: MyApp.Jido
)

Child Processes

Each instance starts:

  • Registry (for managing signal subscriptions)
  • TaskSupervisor (for async operations)
  • Extension Registry (for signal extensions)

Summary

Functions

Returns a child specification for starting an instance supervisor.

Checks if an instance is running.

Starts an instance supervisor with the given options.

Stops an instance supervisor.

Types

option()

@type option() :: {:name, atom()} | {:shutdown, timeout()}

Functions

child_spec(opts)

@spec child_spec([option()]) :: Supervisor.child_spec()

Returns a child specification for starting an instance supervisor.

Options

  • :name - The instance name (required). This will be used as the prefix for all child process names.
  • :shutdown - Shutdown timeout (default: 5000)

Examples

# In your supervision tree
{Jido.Signal.Instance, name: MyApp.Jido}

# With custom shutdown
{Jido.Signal.Instance, name: MyApp.Jido, shutdown: 10_000}

running?(instance)

@spec running?(atom()) :: boolean()

Checks if an instance is running.

Examples

iex> Jido.Signal.Instance.running?(MyApp.Jido)
true

start_link(opts)

@spec start_link([option()]) :: {:ok, pid()} | {:error, term()}

Starts an instance supervisor with the given options.

Options

  • :name - The instance name (required)

Returns

  • {:ok, pid} - Instance supervisor started successfully
  • {:error, reason} - Failed to start

stop(instance, timeout \\ 5000)

@spec stop(atom(), timeout()) :: :ok

Stops an instance supervisor.

Examples

:ok = Jido.Signal.Instance.stop(MyApp.Jido)