View Source partisan_gen_server behaviour (partisan v5.0.0-beta.15)
This module is an adaptation of Erlang's gen_server
module.
It replaces all instances of erlang:send/2
and erlang:monitor/2
with their Partisan counterparts.
It maintains the gen_server
API with the following exceptions:
call/3` and `multi_call/4` - override the 3rd and 4th arguments respectively to accept not only a timeout value but also a list of options containing any of the following: `{timeout, timeout()}
|{channel, partisan:channel()}
.cast/3` - identical to `cast/2
with the 3th argument is a list of options containing any of the following:{channel, partisan:channel()}
.send_request/4` - identical to `send_request/3
with the 4th argument is a list of options containing any of the following:{channel, partisan:channel()}
.
NOTICE
At the moment this only works for partisan_pluggable_peer_service_manager
backend.
Link to this section Summary
Link to this section Types
-type request_id() :: term().
-type server_ref() :: pid() | partisan_remote_ref:p() | (LocalName :: atom()) | {Name :: atom(), Node :: atom()} | {global, GlobalName :: term()} | {via, RegMod :: module(), ViaName :: term()}.
Link to this section Callbacks
-callback code_change(OldVsn :: term() | {down, term()}, State :: term(), Extra :: term()) ->
{ok, NewState :: term()} | {error, Reason :: term()}.
-callback format_status(Opt, StatusData) -> Status
when
Opt :: normal | terminate,
StatusData :: [PDict | State],
PDict :: [{Key :: term(), Value :: term()}],
State :: term(),
Status :: term().
-callback handle_call(Request :: term(), From :: {pid(), Tag :: term()}, State :: term()) ->
{reply, Reply :: term(), NewState :: term()} |
{reply, Reply :: term(), NewState :: term(), timeout() | hibernate} |
{noreply, NewState :: term()} |
{noreply, NewState :: term(), timeout() | hibernate} |
{stop, Reason :: term(), Reply :: term(), NewState :: term()} |
{stop, Reason :: term(), NewState :: term()}.
-callback handle_cast(Request :: term(), State :: term()) ->
{noreply, NewState :: term()} |
{noreply, NewState :: term(), timeout() | hibernate} |
{stop, Reason :: term(), NewState :: term()}.
-callback handle_info(Info :: timeout | term(), State :: term()) ->
{noreply, NewState :: term()} |
{noreply, NewState :: term(), timeout() | hibernate} |
{stop, Reason :: term(), NewState :: term()}.
-callback init(Args :: term()) ->
{ok, State :: term()} |
{ok, State :: term(), timeout() | hibernate} |
{stop, Reason :: term()} |
ignore.
-callback terminate(Reason :: normal | shutdown | {shutdown, term()} | term(), State :: term()) -> term().
Link to this section Functions
-spec check_response(Msg :: term(), RequestId :: request_id()) -> {reply, Reply :: term()} | no_reply | {error, {Reason :: term(), server_ref()}}.
-spec receive_response(RequestId :: request_id(), timeout()) -> {reply, Reply :: term()} | timeout | {error, {Reason :: term(), server_ref()}}.
-spec send_request(Name :: server_ref(), Request :: term()) -> request_id().
-spec send_request(Name :: server_ref(), Request :: term(), Opts :: list()) -> request_id().
-spec system_terminate(_, _, _, [_]) -> no_return().
-spec wait_response(RequestId :: request_id(), timeout()) -> {reply, Reply :: term()} | timeout | {error, {Reason :: term(), server_ref()}}.