View Source Nostrum.Store.GuildShardMapping behaviour (Nostrum v0.9.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

Link to this callback

child_spec(term)

View Source (since 0.8.0)
@callback child_spec(term()) :: Supervisor.child_spec()

Retrieve the child specification for starting this mapping under a supervisor.

Link to this callback

create(id, shard_num)

View Source (since 0.8.0)

Create a new mapping for the given guild ID to the given shard ID.

Link to this callback

delete(id)

View Source (since 0.8.0)
@callback delete(Nostrum.Struct.Guild.id()) :: :ok

Delete any stored mapping for the given guild ID.

Retrieve the shard number for the given guild ID.

Returns nil if no associated shard number was found.

Functions