HareMq.DynamicSupervisor (hare_mq v1.3.0)

Summary

Functions

Adds a new consumer process to the dynamic supervisor.

Returns a specification to start this module under a supervisor.

Initializes the dynamic supervisor with the specified options.

Returns a list of all consumers managed by this dynamic supervisor.

This function looks up the consumer by name in the :consumers registry, sends a cancellation message to the consumer to allow it to stop processing, and then terminates the child process.

Starts the AutoScaler as a child under this DynamicSupervisor.

Starts a child worker process with the specified worker and options.

Functions

Link to this function

add_consumer(list)

Adds a new consumer process to the dynamic supervisor.

Examples

iex> HareMq.DynamicSupervisor.add_consumer(worker: MyApp.Consumer, name: "MyApp.Consumer.W4", opts: [config: %{}, consume: MyApp.Consumer])
{:ok, #PID<0.125.0>}
Link to this function

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Initializes the dynamic supervisor with the specified options.

It starts a Task to asynchronously run the start_consumers function and initializes the dynamic supervisor with a one_for_one restart strategy.

Examples

iex> HareMq.DynamicSupervisor.start_link([config: %{consumer_count: 3}, consume: MyApp.Consumer])
{:ok, #PID<0.123.0>}
Link to this function

list_consumers()

Returns a list of all consumers managed by this dynamic supervisor.

Link to this function

remove_consumer(name)

This function looks up the consumer by name in the :consumers registry, sends a cancellation message to the consumer to allow it to stop processing, and then terminates the child process.

Examples

iex> HareMq.DynamicSupervisor.remove_consumer("MyApp.Consumer.W4")
:ok
Link to this function

start_auto_scaler(opts)

Starts the AutoScaler as a child under this DynamicSupervisor.

Link to this function

start_child(list)

Starts a child worker process with the specified worker and options.

Examples

iex> HareMq.DynamicSupervisor.start_child(worker: MyApp.Consumer, name: :consumer1, opts: [config: %{}, consume: MyApp.Consumer])
{:ok, #PID<0.124.0>}
Link to this function

start_link(opts)