EctoSharding v0.0.5 EctoSharding View Source

EctoSharding ShardRegistry and Repo supervisor.

This is the supervisor that will supervise the internal shard registry and build and supervise the ecto repo for each shard specified in the configuration. Before start_link is called all of the shard configuration must be present in the ecto_sharding application env. In otherwords, Application.get_env(:ecto_sharding, Ecto.Sharding) must return all of the configured shards.

This also provides the only public API to the shard registry that consumers should need to interact with, which allows for setting the current shard and retriving the correct repo for the current shard.

Link to this section Summary

Types

The identifier for a shard repo

Functions

Get the repo based on the current shard

Get the currently set shard

Set the current shard to be used for all queries including sharded schemas

Get the repo corresponding to the give shard

Start the sharding supervisor

Link to this section Types

Link to this type shard() View Source
shard() :: integer | String.t

The identifier for a shard repo.

This will be used to store and lookup each shard repo. It currently only allows integers or strings, but in the future it may support anything that implements String.Chars protocol.

Link to this section Functions

Get the repo based on the current shard.

Link to this function current_shard() View Source
current_shard() :: shard

Get the currently set shard.

Link to this function current_shard(shard) View Source
current_shard(shard) :: :ok

Set the current shard to be used for all queries including sharded schemas.

Link to this function repo_for_shard(shard) View Source
repo_for_shard(shard) :: EctoSharding.Repo.t

Get the repo corresponding to the give shard.

Link to this function start_link() View Source
start_link() :: {:ok, pid}

Start the sharding supervisor.