View Source partisan_gen_server behaviour (partisan v5.0.0-beta.14)
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.
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() |
(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 system_terminate(_, _, _, [_]) -> no_return().
-spec wait_response(RequestId :: request_id(), timeout()) -> {reply, Reply :: term()} | timeout | {error, {Reason :: term(), server_ref()}}.