Adap.Unit.Router
Route element to a node/process started on demand: Adap.Unit.Router.cast({mod,arg}=unit_spec,elem)
will:
- route the query to
mod.node(arg)
- see if a process for the spec
{mod,arg}
is running locally - if not start a process tree with
mod.start_link(arg)
- route the query to existing or newly created process with
mod.cast(pid,elem)
Processes are monitored in order to restart them on demand when they die.
A process specification is defined as a tuple {module,args}
: module must implement behaviour Adap.Unit
with previously described callbacks.
A Unit can represent : a GenServer, a pool of GenServers, a pool of node of GenServer, etc. The reference unit is a simple GenServer:
- which dies itself after a given "time to live"
- where the routed element is an anonymous function with one parameter
- casting the function on server and apply it with the server state as parameter
You can use Adap.Unit.Simple
to take the default implementation for this kind of processing unit.
Summary↑
cast(arg1, fun) |
start_link() |