# `Slap.KV.Cluster`
[🔗](https://github.com/mjrusso/slap/blob/slap_kv-v0.3.0/slap_kv/lib/slap/kv/cluster.ex#L1)

The shards that hold the rows, a `Slap.Cluster`. A partition's rows are
on shard `shard_for(partition)`. Each shard runs partition writers,
each the only process that writes its own
subset of the shard's partitions. Set
`child_options: [partition_writers: n]` on the cluster (default 16).

Run one instance of this built-in cluster per VM. It can own many shards
and participate in a cluster across VMs. The same VM can also run
`Slap.Streams.Cluster`.

To configure a cluster under your application's name, define a module
with `use Slap.KV.Cluster, otp_app: :my_app`, supervise that module in
place of `Slap.KV.Cluster`, and pass `cluster: MyApp.KVCluster` to KV
operations and `Slap.KV.HTTP.Router`. Run one KV cluster per VM; peer
discovery is node-wide.

Configure it like any `Slap.Cluster`:

    config :slap_kv, Slap.KV.Cluster,
      store: {:url, "s3://bucket/prefix", aws_endpoint: "https://rustfs:9000"},
      path: "kv",
      shards: 8

Durable writes wait for SlateDB's next WAL flush. This cluster sets
`flush_interval` to 10 ms; SlateDB's default is 100 ms. Other settings
leave the 10 ms default intact. The README describes the latency and
object-store request trade-off.

Give the cluster its own `:path` when it shares a store with another
cluster.

# `__using__`
*macro* 

Defines a KV cluster under the given `:otp_app`.

# `assignments`

Where every shard is. See `Slap.Cluster.assignments/1`.

# `call`

Runs a function with a shard's context. See `Slap.Cluster.call/4`.

# `local_shards`

The shards open on this node.

# `lookup`

Where a shard is. See `Slap.Cluster.lookup/2`.

# `shard_for`

The shard for a placement key. See `Slap.Cluster.shard_for/2`.

# `start_link`

Starts the cluster. `opts` override the application environment, which
overrides the `:defaults` given to `use Slap.Cluster`.

# `stop`

Stops the cluster on this node, closing its shards.

# `via`

A name for a per-shard process. See `Slap.Cluster.via/3`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
