Decides which node owns which shard.
A strategy is a process started under the cluster's supervisor, after the
host. It starts and stops shards on this node only through
Slap.Cluster.Host.start_shard/3 and stop_shard/2, and the host
reports every shard that stops through handle_shard_down/3.
SlateDB's fencing keeps at most one effective writer per shard whatever the strategy does, so a strategy only has to be mostly right: two nodes that both open a shard cost errors and a restart, not data.
Summary
Callbacks
The strategy's child spec. opts includes :cluster.
Called by the host, from the host process, when a shard on this node
stops: :fenced (another writer opened it), :crashed (it failed more
often than its supervisor allows) or :stopped (stop_shard/2). Must
not block; send a message to the strategy's process instead.
Where shard is owned, as far as the strategy knows. The result may be
stale.
Refreshes the strategy's view of where shards are, after call/4 found
it stale. Optional. It must return within timeout ms.
Validates strategy options before the cluster starts. Raise ArgumentError
for invalid options. Optional for custom strategies.
Types
Callbacks
@callback child_spec(opts :: keyword()) :: Supervisor.child_spec()
The strategy's child spec. opts includes :cluster.
Called by the host, from the host process, when a shard on this node
stops: :fenced (another writer opened it), :crashed (it failed more
often than its supervisor allows) or :stopped (stop_shard/2). Must
not block; send a message to the strategy's process instead.
Where shard is owned, as far as the strategy knows. The result may be
stale.
Refreshes the strategy's view of where shards are, after call/4 found
it stale. Optional. It must return within timeout ms.
@callback validate_options(opts :: keyword()) :: :ok
Validates strategy options before the cluster starts. Raise ArgumentError
for invalid options. Optional for custom strategies.