Peeper.GenServer behaviour (peeper v0.3.0)
View SourceA drop-in replacement for use GenServer
Summary
Callbacks
Almost the same as GenServer.init/1
but cannot return anything but {:ok, new_state}
tuple and is being invoked from handle_continue/2
followed init/1
of the state
keeper process.
Functions
Declares a Peeper.GenServer
behaviour, injects start_link/1
function
and the child spec.
Starts a Peeper
sub-supervision process tree linked to the current process.
Callbacks
@callback handle_call(request :: term(), GenServer.from(), state :: term()) :: {:reply, reply, new_state} | {:reply, reply, new_state, timeout() | :hibernate | {:continue, continue_arg :: term()}} | {:noreply, new_state} | {:noreply, new_state, timeout() | :hibernate | {:continue, continue_arg :: term()}} | {:stop, reason, reply, new_state} | {:stop, reason, new_state} when reply: term(), new_state: term(), reason: term()
Almost the same as GenServer.init/1
but cannot return anything but {:ok, new_state}
tuple and is being invoked from handle_continue/2
followed init/1
of the state
keeper process.
See: GenServer.init/1
Functions
Declares a Peeper.GenServer
behaviour, injects start_link/1
function
and the child spec.
Example
defmodule MyGenServer do
use Peeper.GenServer
@impl Peeper.GenServer
def handle_call(:state, _from, state),
do: {:reply, state, state}
@impl Peeper.GenServer
def handle_cast(:inc, state),
do: {:noreply, state, {:continue, :inc}}
@impl Peeper.GenServer
def handle_continue(:inc, state),
do: {:noreply, state + 1}
end
Starts a Peeper
sub-supervision process tree linked to the current process.