SuperCache.Cluster.Raft.Machine (SuperCache v1.9.0)

Copy Markdown View Source

Raft state machine that applies committed commands to a local ETS partition.

The machine is configured with the partition index it owns:

{:machine, SuperCache.Cluster.Raft.Machine, %{partition_idx: 2}}

Commands are either a single operation tuple ({op_name, op_arg}) or a batch ({:batch, [op]}). Both use the same local apply helpers as SuperCache.Cluster.Replicator, so Raft mode and the other replication modes write identical records to ETS.

Application is guarded by the Raft log index stored in SuperCache.Cluster.Raft.Applied; a replayed index is acknowledged without re-applying its operations. The machine state also carries the highest applied index so snapshots checkpoint it as metadata, and installing a snapshot restores the ETS watermark.