crux_gateway v0.2.0 Crux.Gateway View Source
Main entry point for Crux.Gateway
.
This module fits under a supervision tree, see start_link/1
arguments for configuration.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor
Starts a Crux.Gateway
process linked to the current process
Link to this section Types
gateway()
View Source
gateway() :: Supervisor.supervisor()
gateway() :: Supervisor.supervisor()
The gateway reference
options()
View Source
options() ::
%{
:token => String.t(),
:url => String.t(),
:shard_count => pos_integer(),
optional(:shards) => [non_neg_integer() | Range.t()],
optional(:dispatcher) =>
GenStage.Dispatcher.t() | {GenStage.Dispatcher.t(), term()},
optional(:presence) => presence()
}
| list()
options() :: %{ :token => String.t(), :url => String.t(), :shard_count => pos_integer(), optional(:shards) => [non_neg_integer() | Range.t()], optional(:dispatcher) => GenStage.Dispatcher.t() | {GenStage.Dispatcher.t(), term()}, optional(:presence) => presence() } | list()
Used to start Crux.Gateway
.
See start_link/1
Notes:
:token
can be retrieved from here.:url
you can GET it from/gateway/bot
(orCrux.Rest.gateway_bot/0
).:shard_count
^Optionally
:shards
, which has to be a list of numbers and ranges.
Examples:[1..3]
[1, 2, 3]
[1..3, 8, 9]
If omitted all shards will be run.Optionally
:dispatcher
, which has to be a validGenStage.Dispatcher
or a tuple of one and initial state.
SeeCrux.Gateway.Connection.Producer
for more info.Optionally
:presence
, which is used for the initial presence of every session.
This should be a presence or a function with an arity of one (the shard id) and returning a presence.
If a function, it will be invoked whenever a shard is about to identify.
If omitted the presence will default to online and no game.
presence()
View Source
presence() :: (non_neg_integer() -> map()) | map()
presence() :: (non_neg_integer() -> map()) | map()
Used as initial presence for every session.
Link to this section Functions
child_spec(arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
start_link(gateway_opts)
View Source
start_link(opts_or_tuple :: options() | {options(), Supervisor.options()}) ::
Supervisor.on_start()
start_link(opts_or_tuple :: options() | {options(), Supervisor.options()}) :: Supervisor.on_start()
Starts a Crux.Gateway
process linked to the current process.
Options are either just options/0
or a tuple of options/0
and Supervisor.options/0
.