Nostrum.Store.GuildShardMapping behaviour (nostrum v0.11.0-dev)

View Source

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

child_spec(term)

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

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

create(id, shard_num)

(since 0.8.0)

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

delete(id)

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

Delete any stored mapping for the given guild ID.

get(id)

(since 0.8.0)

Retrieve the shard number for the given guild ID.

Returns nil if no associated shard number was found.

Functions

create(guild_id, shard_num)

(since 0.8.0)

See Nostrum.Store.GuildShardMapping.ETS.create/2.

delete(guild_id)

(since 0.8.0)

See Nostrum.Store.GuildShardMapping.ETS.delete/1.

get(guild_id)

(since 0.8.0)

See Nostrum.Store.GuildShardMapping.ETS.get/1.