SuperWorker.Supervisor.Group (SuperWorker v0.5.0)

View Source

Documentation for SuperWorker.Supervisor.Group.

Summary

Functions

A internal function. Add a worker to the group.

Check, validate and convert key-value pairs to struct.

Get all workers from the group.

Get worker from the group.

A internal function. Restart a worker in the group.

Check if worker exists in the group.

Types

check_options_result()

@type check_options_result() :: {:ok, t()} | {:error, atom() | {atom(), any()}}

t()

@type t() :: %SuperWorker.Supervisor.Group{
  id: any(),
  restart_strategy: atom(),
  supervisor: atom() | nil,
  table: atom() | nil
}

worker_operation_result()

@type worker_operation_result() :: {:ok, t()} | {:error, atom()}

Functions

add_worker(group, worker)

A internal function. Add a worker to the group.

broadcast(group, message)

@spec broadcast(
  %SuperWorker.Supervisor.Group{
    id: term(),
    restart_strategy: term(),
    supervisor: term(),
    table: term()
  },
  any()
) :: :ok | {:error, list()}

check_options(options)

@spec check_options([keyword()]) ::
  {:ok,
   %SuperWorker.Supervisor.Group{
     id: term(),
     restart_strategy: term(),
     supervisor: term(),
     table: term()
   }}
  | {:error, atom() | {atom(), any()}}
@spec check_options([atom() | keyword()]) :: check_options_result()

Check, validate and convert key-value pairs to struct.

count_workers(group)

@spec count_workers(%SuperWorker.Supervisor.Group{
  id: term(),
  restart_strategy: term(),
  supervisor: term(),
  table: term()
}) :: non_neg_integer()
@spec count_workers(t()) :: non_neg_integer()

get_all_workers(group)

@spec get_all_workers(t()) :: {:ok, [SuperWorker.Supervisor.Worker.t()]}

Get all workers from the group.

get_worker(group, worker_id)

@spec get_worker(t(), any()) ::
  {:ok, SuperWorker.Supervisor.Worker.t()} | {:error, atom()}

Get worker from the group.

kill_all_workers(group, reason \\ :kill)

kill_worker(group, worker, reason)

remove_worker(group, worker_id)

restart_worker(group, worker)

@spec restart_worker(t(), SuperWorker.Supervisor.Worker.t() | any()) ::
  worker_operation_result()

A internal function. Restart a worker in the group.

send_message(group, worker_id, message)

worker_exists?(group, worker_id)

@spec worker_exists?(t(), any()) :: boolean()

Check if worker exists in the group.