View Source Tamnoon (Tamnoon v1.0.0-a.3)
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, %{}]
.
Options for configuring the protocol used by Tamnoon. Can be either :http
or a keyword list containing
values for :keyfile
, :certfile
, and :otp_app
(:otp_app
is required only when using relative paths for the
key and certificate files). Defaults to :http
.
Functions
Returns a Tamnoon server supervisor child spec. See tamnoon_opts/0
for more info.
Copies HEEx file components to the release directory and creates a tamnoon_out directory
in it. It is needed to be ran as a step in the release (see Mix.Release
).
Starts the supervisor. See tamnoon_opts/0
for more info.
Types
@type tamnoon_opts() :: [ initial_state: map(), port: number(), methods_module: module(), router: module(), socket_handler: module(), protocol_opts: tamnoon_protocol_opts() ]
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 (seeTamnoon.Methods
). Defaults toTamnoon.Methods
.router
: The router module (seePlug.Router
). Defaults toTamnoon.Router
.socket_handler
: The handler module for WebSocket requests. Usually doesn't need to be overriden. Defaults toTamnoon.SocketHandler
.protocol_opts
: Whether Tamnoon uses HTTP or HTTPS. Seetamnoon_protocol_opts/0
for more info.
@type tamnoon_protocol_opts() :: :http | [keyfile: String.t(), certfile: String.t(), otp_app: atom()]
Options for configuring the protocol used by Tamnoon. Can be either :http
or a keyword list containing
values for :keyfile
, :certfile
, and :otp_app
(:otp_app
is required only when using relative paths for the
key and certificate files). Defaults to :http
.
Functions
@spec child_spec(opts :: tamnoon_opts()) :: map()
Returns a Tamnoon server supervisor child spec. See tamnoon_opts/0
for more info.
@spec make_release(Mix.Release) :: Mix.Release
Copies HEEx file components to the release directory and creates a tamnoon_out directory
in it. It is needed to be ran as a step in the release (see Mix.Release
).
@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.