API Reference slap_cluster v#0.2.0

Copy Markdown View Source

Modules

Runs N SlateDB databases ("shards") in one bucket: opens and closes them, turns SlateDB's writer fencing into supervised events, fans out durability notifications, and finds the shard for a key. It knows nothing about what the application stores; the application puts its own per-shard processes on top.

XXH64 (xxHash, 64-bit), for placing keys on shards.

Starts and stops the shards placed on this node, for the strategy.

Keeps this node connected to a fixed list of other nodes, retrying every 2 s. Routing between nodes needs distributed Erlang: the node must have a name and share the cookie.

The context of a shard placed on this node, given to the application's shard children and to functions run with call/3.

Starts application processes for a shard after its database opens.

Decides which node owns which shard.

Places shards on the connected nodes of a distributed Erlang cluster with no database and no leases: every node computes the same placement from the list of nodes running the cluster (a :pg group), by rendezvous hashing with bounded loads: shard n prefers the nodes in decreasing order of xxh64("<n>/<node>"), and goes to the first of them that has fewer than ceil(shards / nodes) shards so far. Every node gets its fair share, and a node joining or leaving moves few shards besides its own.

The placement loop of Slap.Cluster.Strategy.ObjectLease (leases in the object store), behind a storage behaviour for other lease stores: one lease per shard, a heartbeat per node, fair shares, and self-fencing. Where the leases live is a Slap.Cluster.Strategy.LeaseLoop.Store.

Where a lease strategy keeps its leases and heartbeats. Each callback gets the store's state and returns it, possibly changed. A lease is {owner, generation} while unexpired; owners/1 returns only those. Every call must return within the :timeout given to init/2.

Places every shard on this node. For single-node deployments, development and CI.

Places shards on the nodes of a cluster through leases kept as objects in the cluster's own object store: no database is needed, only the bucket the shards already live in. It is the lease strategy for deployments without a database.

A fixed assignment of shards to nodes, from configuration: no database, no leases, no failover. A node opens its own shards (and reopens them after a backoff if they fail, like Slap.Cluster.Strategy.Local), and routes to the others by the assignment. If a node is down, its shards are unavailable until it is back.