View Source Tamnoon (Tamnoon v1.0.0-a.2)

This module provides functions needed to initialize Tamnoon. You do not need to handle it directly, rather, the only time you need to call something in this module is in your supervision tree, to add it to the children and configure it (see child_spec/1).

Example

def start_link(opts \\ []) do
  children = [Tamnoon]
  opts = [strategy: :one_for_one, name: Tamnoon.Supervisor]
  Supervisor.start_link(children, opts)
end

Summary

Types

Options for initializing Tamnoon. Defaults to [8000, Tamnoon.Router, Tamnoon.SocketHandler, Tamnoon.Methods, %{}].

Functions

Returns a Tamnoon server supervisor child spec. See tamnoon_opts/0 for more info.

Starts the supervisor. See tamnoon_opts/0 for more info.

Types

@type tamnoon_opts() :: [
  initial_state: map(),
  port: number(),
  router: module(),
  socket_handler: module(),
  methods_module: module()
]

Options for initializing Tamnoon. Defaults to [8000, Tamnoon.Router, Tamnoon.SocketHandler, Tamnoon.Methods, %{}].

  • port: The port Tamnoon will run on. Defaults to 8000.
  • initial_state: The state new clients will start with. Defaults to an empty map.
  • methods_module: The module where your methods are defined (see Tamnoon.Methods). Defaults to Tamnoon.Methods.
  • router: The router module (see Plug.Router). Defaults to Tamnoon.Router.
  • socket_handler: The handler module for WebSocket requests. Usually doesn't need to be overriden. Defaults to Tamnoon.SocketHandler.

Functions

@spec child_spec(opts :: tamnoon_opts()) :: map()

Returns a Tamnoon server supervisor child spec. See tamnoon_opts/0 for more info.

@spec start_link(server_opts :: tamnoon_opts()) ::
  {:ok, pid()}
  | {:error, {:already_started, pid()} | {:shutdown, term()} | term()}

Starts the supervisor. See tamnoon_opts/0 for more info.