Module libp2p_group_worker
Behaviours: gen_statem.
Data Types
stream_client_spec()
stream_client_spec() = {Path::string(), {Module::atom(), Args::[any()]}}
target()
target() = {MAddr::string(), Spec::stream_client_spec()}
Function Index
| assign_stream/2 | Assigns the given stream to the worker. |
| assign_target/2 | Assign a target to a worker. |
| callback_mode/0 | |
| clear_target/1 | Clears the current target for the worker. |
| close/1 | Changes the group worker state to closing state. |
| closing/3 | |
| connected/3 | |
| connecting/3 | |
| init/1 | |
| send/3 | Sends a given Data binary on it's stream asynchronously. |
| send_ack/3 | Used as a convenience for groups using libp2p_ack_stream, this function sends an ack to the worker's stream if connected. |
| start_link/4 | |
| start_link/5 | |
| targeting/3 | |
| terminate/3 |
Function Details
assign_stream/2
assign_stream(Pid::pid(), StreamPid::pid()) -> ok
Assigns the given stream to the worker. This does not update
the target of the worker but moves the worker to the connected
state and uses it to send data.
assign_target/2
assign_target(Pid::pid(), Target::target()) -> ok
Assign a target to a worker. This causes the worker to go back to attempting to connect to the given target, dropping it’s stream if it has one. The target is passed as the a tuple consisting of the crytpo address and the spec of the stream client to start once the worker is connected to the target.
callback_mode/0
callback_mode() -> any()
clear_target/1
clear_target(Pid::pid()) -> ok
Clears the current target for the worker. The worker goes back to target acquisition, after dropping it’s streeam if it has one.
close/1
close(Pid::pid()) -> ok
Changes the group worker state to closing state. Closing
means that a newly assigned stream is still accepted but the worker
will not attempt to re-acquire a target or re-connect.
closing/3
closing(EventType, Msg, Data) -> any()
connected/3
connected(EventType, Msg, Data) -> any()
connecting/3
connecting(EventType, Msg, Data) -> any()
init/1
init(Args::term()) -> gen_statem:init_result(atom())
send/3
send(Pid::pid(), Ref::term(), Data::any()) -> ok
Sends a given Data binary on it’s stream asynchronously. The given Ref is
used to indicate the send result to the server for the worker.
See also: libp2p_group_server:send_result/3.
send_ack/3
send_ack(Pid::pid(), Seq::[pos_integer()], Reset::boolean()) -> ok
Used as a convenience for groups using libp2p_ack_stream, this function sends an ack to the worker’s stream if connected.
start_link/4
start_link(Kind::atom(), Server::pid(), GroupID::string(), TID::ets:tab()) -> {ok, Pid::pid()} | ignore | {error, Error::term()}
start_link/5
start_link(Kind::atom(), Stream::pid(), Server::pid(), GroupID::string(), TID::ets:tab()) -> {ok, Pid::pid()} | ignore | {error, Error::term()}
targeting/3
targeting(EventType, Msg, Data) -> any()
terminate/3
terminate(Reason::term(), State::term(), Data::term()) -> any()