crux_gateway v0.2.3 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() | (() -> String.t()),
:shard_count => pos_integer(),
optional(:shards) => [non_neg_integer() | Range.t()],
optional(:presence) => presence(),
optional(:guild_subscriptions) => boolean(),
optional(:dispatcher) =>
GenStage.Dispatcher.t() | {GenStage.Dispatcher.t(), term()}
}
| list()
options() ::
%{
:token => String.t(),
:url => String.t() | (() -> String.t()),
:shard_count => pos_integer(),
optional(:shards) => [non_neg_integer() | Range.t()],
optional(:presence) => presence(),
optional(:guild_subscriptions) => boolean(),
optional(:dispatcher) =>
GenStage.Dispatcher.t() | {GenStage.Dispatcher.t(), term()}
}
| list()
Used to start Crux.Gateway.
See start_link/1
Notes:
:tokencan be retrieved from here.:urlyou can GET from/gateway/bot(orc:Crux.Rest.gateway_bot/0).This can also be a function with an arity of 0 returning it.
:shard_countsame as:url.Optionally
:shards, which has to be a list of numbers and ranges.
Examples:[1..3],[1, 2, 3],[1..3, 8, 9]Defaults to
0..shard_count-1.Optionally
:presence, which is used for the initial presence of every session.
This should be a map with a"game"and"status"key, or a function with an arity of one (the shard id) and returning such a map, ornilfor the default.
If a function, it will be invoked whenever a shard is about to identify.Defaults to
%{"game" => nil, "status" => "online"}.Optionally
:guild_subscriptions, aids large or generally stateless bots by opting out of several events and less data being sent over the gateway.
For more information see Discord Docs and the relevant PR on GitHub.Defaults to
trueOptionally
:dispatcher, which has to be a validGenStage.Dispatcheror a tuple of one and initial state.
SeeCrux.Gateway.Connection.Producerfor more info.Defaults to
GenStage.BroadcastDispatcher
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(init_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.