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