sbroker
processes that are
automatically started in the sbroker
supervision tree.
Behaviours: sbroker.
This module provides helpers for managing sbroker
processes that are
automatically started in the sbroker
supervision tree.
brokers
can be automatically started when the sbroker
application starts
by setting the sbroker
application env brokers
. It is a list of broker
names and specifications, of the form:
[{Name :: sbroker:name(), Spec :: {AskQueueSpec :: sbroker:handler_spec(), AskRQueueSpec :: sbroker:handler_spec(), [MeterSpec :: sbroker:handler_spec()]}}]
Name
is the name of the broker and each broker will be registered using its
name, e.g. {local, my_broker}
. Spec
is the specification for the
sbroker
, which is equivalent to returning {ok, Spec}
from the init/1
callback: AskQueueSpec
is the ask
queue spec, AskRQueueSpec
is the
ask_r
queue spec and MeterSpec
is a meter spec.
sbroker
application allows multiple applications,
or parts of the same supervision tree, to access a sbroker
even if their
counterparty crashes. It also allows either party to be started first and
await the other using the sbroker
queues.
change_config/0 | Call sbroker:change_config/1 on all brokers started in the sbroker
application. |
delete/1 | Delete a broker with name, Name . |
restart/1 | Restart a broker with name, Name . |
start/1 | Starts a broker with name, Name . |
terminate/1 | Terminate a broker with name, Name . |
which_brokers/0 | List user brokers started in the sbroker application. |
change_config() -> [{Name, Reason}]
Call sbroker:change_config/1
on all brokers started in the sbroker
application.
This function can be used to reconfigure all brokers that are already started
after the sbroker
application env brokers
is changed.
Name
is the sbroker:name()
of the
broker and Reason
is the reason.
delete(Name) -> ok | {error, Reason}
Delete a broker with name, Name
.
The broker is deleted in the sbroker
application's supervision tree using
Brokers are automatically started when the sbroker
is started, and might be
restarted if the entry remains in the sbroker
application env brokers
, so
this function should only be required to delete a broker after it has removed
from brokers
.
ok
on successfully deleting the regulator, otherwise
{error, Reason}
where Reason
is reason for the error.
restart(Name) -> {ok, Pid} | {error, Reason}
Restart a broker with name, Name
.
The broker is restarted in the sbroker
application's supervision tree using
configuration from the sbroker
application env brokers
. Brokers are
automatically started when the sbroker
is started so this function should
only be required if a broker is terminated.
{ok, Pid}
on starting the broker, where Pid
is the pid()
of the
broker, {ok, undefined}
if a configuration for Name
does not exist in
brokers
or {error, Reason}
if the broker fails to start with reason
Reason
.
start(Name) -> {ok, Pid} | {error, Reason}
Starts a broker with name, Name
.
The broker is started in the sbroker
application's supervision tree using
configuration from the sbroker
application env brokers
. Brokers are
automatically started when the sbroker
application is started so this
function should only be required if a broker is added to the configuration.
{ok, Pid}
on starting the broker, where Pid
is the pid()
of the
broker, {ok, undefined}
if a configuration for Name
does not exist in
brokers
or {error, Reason}
if the broker fails to start with reason
Reason
.
terminate(Name) -> ok | {error, not_found}
Terminate a broker with name, Name
.
The broker is terminated in the sbroker
application's supervision tree.
Brokers are automatically started when the sbroker
is started, and might be
restarted if the entry remains in the sbroker
application env brokers
, so
this function should only be required to terminate a broker after it has been
removed from brokers
.
ok
once the broker is terminated, otherwise {error, not_found}
.
which_brokers() -> [{Name, Pid, Type, Modules}]
List user brokers started in the sbroker
application.
Name
is the sbroker:name()
of the broker,
Pid
is the pid()
or undefined
, Type
is worker
and Modules
is
dynamic
.
Generated by EDoc