View Source Nostrum.Store.GuildShardMapping behaviour (Nostrum v0.10.0)
Behaviour & dispatcher for storing guild to shard mappings.
Purpose
When nostrum needs to run API calls over the gateway and multiple shards are used, it needs to determine which shard process will run the request. This module stores a mapping of guild IDs to their respective shard numbers. It is unlikely you need to use this module directly yourself.
Configuration
By default, nostrum will use Elixir.Nostrum.Store.GuildShardMapping.ETS
to store the
mapping. To override this, set the [:stores, :guild_shard_mapping]
setting
on nostrum's application configuration:
config :nostrum,
stores: %{
guild_shard_mapping: MyBot.Nostrum.Store.GuildShardMapping
}
This setting must be set at compile time.
Summary
Callbacks
Retrieve the child specification for starting this mapping under a supervisor.
Create a new mapping for the given guild ID to the given shard ID.
Delete any stored mapping for the given guild ID.
Retrieve the shard number for the given guild ID.
Callbacks
@callback child_spec(term()) :: Supervisor.child_spec()
Retrieve the child specification for starting this mapping under a supervisor.
@callback create(Nostrum.Struct.Guild.id(), Nostrum.Struct.WSState.shard_num()) :: :ok
Create a new mapping for the given guild ID to the given shard ID.
@callback delete(Nostrum.Struct.Guild.id()) :: :ok
Delete any stored mapping for the given guild ID.
@callback get(Nostrum.Struct.Guild.id()) :: Nostrum.Struct.WSState.shard_num() | nil
Retrieve the shard number for the given guild ID.
Returns nil
if no associated shard number was found.