View Source partisan_gen_server behaviour (partisan v5.0.0-beta.21)

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

Link to this callback

code_change/3

View Source (optional)
-callback code_change(OldVsn :: term() | {down, term()}, State :: term(), Extra :: term()) ->
               {ok, NewState :: term()} | {error, Reason :: term()}.
Link to this callback

format_status/2

View Source (optional)
-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 | {continue, term()}} |
               {noreply, NewState :: term()} |
               {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
               {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 | {continue, term()}} |
               {stop, Reason :: term(), NewState :: term()}.
Link to this callback

handle_info/2

View Source (optional)
-callback handle_info(Info :: timeout | term(), State :: term()) ->
               {noreply, NewState :: term()} |
               {noreply, NewState :: term(), timeout() | hibernate | {continue, term()}} |
               {stop, Reason :: term(), NewState :: term()}.
-callback init(Args :: term()) ->
        {ok, State :: term()} |
        {ok, State :: term(), timeout() | hibernate | {continue, term()}} |
        {stop, Reason :: term()} |
        ignore.
-callback terminate(Reason :: normal | shutdown | {shutdown, term()} | term(), State :: term()) -> term().

Link to this section Functions

Link to this function

abcast(Nodes, Name, Request)

View Source
Link to this function

call(Name, Request, TimeoutOrOpts)

View Source
Link to this function

cast(ServerRef, Request, Opts)

View Source
Link to this function

check_response(Msg, RequestId)

View Source
-spec check_response(Msg :: term(), RequestId :: request_id()) ->
                  {reply, Reply :: term()} | no_reply | {error, {Reason :: term(), server_ref()}}.
Link to this function

enter_loop(Mod, Options, State)

View Source
Link to this function

enter_loop(Mod, Options, State, ServerName)

View Source
Link to this function

enter_loop(Mod, Options, State, ServerName, Timeout)

View Source
Link to this function

format_log(Report, FormatOpts0)

View Source
Link to this function

format_status(Opt, StatusData)

View Source
Link to this function

init_it(Starter, Parent, Name, Mod, Args, Options)

View Source
Link to this function

multi_call(Nodes, Name, Req)

View Source
Link to this function

multi_call(Nodes, Name, Req, Timeout)

View Source
Link to this function

receive_response(RequestId, Timeout)

View Source
-spec receive_response(RequestId :: request_id(), timeout()) ->
                    {reply, Reply :: term()} | timeout | {error, {Reason :: term(), server_ref()}}.
Link to this function

send_request(Name, Request)

View Source
-spec send_request(Name :: server_ref(), Request :: term()) -> request_id().
Link to this function

send_request(Name, Request, Opts)

View Source
-spec send_request(Name :: server_ref(), Request :: term(), Opts :: list()) -> request_id().
Link to this function

start(Mod, Args, Options)

View Source
Link to this function

start(Name, Mod, Args, Options)

View Source
Link to this function

start_link(Mod, Args, Options)

View Source
Link to this function

start_link(Name, Mod, Args, Options)

View Source
Link to this function

start_monitor(Mod, Args, Options)

View Source
Link to this function

start_monitor(Name, Mod, Args, Options)

View Source
Link to this function

stop(Name, Reason, Timeout)

View Source
Link to this function

system_code_change(_, Module, OldVsn, Extra)

View Source
Link to this function

system_continue(Parent, Debug, _)

View Source
Link to this function

system_replace_state(StateFun, _)

View Source
Link to this function

system_terminate(Reason, Parent, Debug, _)

View Source
-spec system_terminate(_, _, _, [_]) -> no_return().
Link to this function

wait_response(RequestId, Timeout)

View Source
-spec wait_response(RequestId :: request_id(), timeout()) ->
                 {reply, Reply :: term()} | timeout | {error, {Reason :: term(), server_ref()}}.
Link to this function

wake_hib(Parent, Name, State, Mod, HibernateAfterTimeout, Debug)

View Source