Packages

An elixir Discord library

Current section

Files

Jump to
nostrum_heroku lib nostrum cache mapping shard_pid_num.ex
Raw

lib/nostrum/cache/mapping/shard_pid_num.ex

defmodule Nostrum.Cache.Mapping.ShardPidNum do
@moduledoc """
Simple mapping of shard pid to num
"""
@doc """
Gets the a shard pid from a shard number.
"""
@spec get_pid(integer) :: {:ok, pid} | {:error, :id_not_found}
def get_pid(shard_num) do
case :ets.lookup(:shard_pid_num, shard_num) do
[{_shard_num, shard_pid}] -> {:ok, shard_pid}
[] -> {:error, :id_not_found}
end
end
end