alice v0.3.7 Alice.Router

Handles the routing of messages for Alice

Link to this section Summary

Functions

Returns a list of the currently registered handlers

Used internally to match command handlers

Used internally to match route handlers

Registers a handler. Returns :ok

Starts a Alice.Router process linked to the current process

Link to this section Functions

Link to this macro command(pattern, name) (macro)
Link to this function handlers(pid \\ Alice.Router)

Returns a list of the currently registered handlers.

If you started the router with default options, then you don’t have to pass in a pid. (It will use the default registered name Alice.Router.

Link to this function match_commands(conn)

Used internally to match command handlers

Link to this function match_pattern(arg1, arg2)
Link to this function match_routes(conn)

Used internally to match route handlers

Link to this function register_handler(pid \\ Alice.Router, handler)

Registers a handler. Returns :ok

Link to this macro route(pattern, name) (macro)
Link to this function start_link(handlers \\ [], opts \\ [name: Alice.Router])

Starts a Alice.Router process linked to the current process.

Note that a process started with start_link/2 is linked to the parent process and will exit in case of crashes.

Options

You can pass in a list of handlers to be registered immediately upon starting the Router process.

For other options, see GenServer.start_link/3. Default is to register the process with the name Alice.Router.

Return values

If the router is successfully created and initialized, the function returns {:ok, pid}, where pid is the pid of the router.