Jido.Messaging.InstanceSupervisor (Jido Messaging v1.0.0)

Copy Markdown View Source

Dynamic supervisor for channel instances.

Manages the lifecycle of channel instances (e.g., Telegram bots, Discord connections). Each instance is its own supervisor tree containing:

  • InstanceServer (lifecycle state machine)
  • Channel-specific processes (Poller, Sender, etc.)

Summary

Functions

Returns a specification to start this module under a supervisor.

Count running instances.

Get the status of an instance.

Get health snapshots for all running instances.

List all running instances.

Start the instance supervision tree (called by DynamicSupervisor).

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count_instances(messaging_module)

@spec count_instances(module()) :: non_neg_integer()

Count running instances.

instance_status(messaging_module, instance_id)

@spec instance_status(module(), String.t()) :: {:ok, map()} | {:error, :not_found}

Get the status of an instance.

list_instance_health(messaging_module)

@spec list_instance_health(module()) :: [map()]

Get health snapshots for all running instances.

Returns a list of health snapshot maps for each instance.

list_instances(messaging_module)

@spec list_instances(module()) :: [map()]

List all running instances.

start_instance(messaging_module, channel_type, attrs)

@spec start_instance(module(), atom(), map()) ::
  {:ok, Jido.Messaging.Instance.t()} | {:error, term()}

Start a new instance.

Returns {:ok, instance} with the created Instance struct, or {:error, reason}.

start_instance_tree(messaging_module, instance)

Start the instance supervision tree (called by DynamicSupervisor).

start_link(opts)

stop_instance(messaging_module, instance_id)

@spec stop_instance(module(), String.t()) :: :ok | {:error, :not_found}

Stop an instance by ID.