Migrating from shardlib

Copy Markdown View Source
shardlibshardex
{Shardlib, name: :pg, shards: [...], strategy: &f/2}use Shardex, otp_app: ... + config
shard_1: RepoShard1shard_1: {Shardex.Adapter.Ecto, repo: RepoShard1}
{ES.Supervisor, ES.Cluster1, opts}{Shardex.Adapter.Generic, child_spec: {ES.Supervisor, opts}, ref: ES.Cluster1}
separate *_replicas instanceshard_1: [primary: ..., replica: ...] + role: :replica
get_module(key, name: :pg)MyApp.Shards.ref(key)
get_module!(key)MyApp.Shards.ref!(key)
get_modules(keys) + Enum.group_byMyApp.Shards.group(items, key_fun)
batch_strategy: re-checking maintenanceimplement route_many/2; Shardex checks maintenance
strategy returning :not_foundreturn {:error, :unassigned}
enable_maintenance(s)maintenance(s, :stop) (or :drain)
disable_maintenance(s)activate(s)
in_maintenance?(shard)match?({:ok, %{status: st}} when st != :active, status(shard))
list_shards_info()shards()
test_mode: truestart_pools: false
[:shardlib, :query][:shardex, :run, :stop]

Strategies now receive (key, ctx) / (keys, ctx) and must return {:ok, shard} or {:error, reason}.