Skip to main content

Crate ember_cluster

Crate ember_cluster 

Source
Expand description

ember-cluster: distributed coordination for ember.

This crate provides the building blocks for running ember as a distributed cluster with automatic failover and horizontal scaling.

§Architecture

The cluster layer sits between the protocol layer and the storage engine, handling:

  • Slot management: 16384 hash slots distributed across nodes
  • Topology tracking: Node membership and health monitoring
  • Failure detection: SWIM gossip protocol for quick detection
  • Consensus: Raft for cluster configuration changes
  • Migration: Live slot resharding without downtime

§Quick Start

use ember_cluster::{ClusterState, ClusterNode, NodeId, key_slot};

// Create a single-node cluster
let node_id = NodeId::new();
let node = ClusterNode::new_primary(node_id, "127.0.0.1:6379".parse().unwrap());
let cluster = ClusterState::single_node(node);

// Route a key to its slot
let slot = key_slot(b"mykey");
assert!(cluster.owns_slot(slot));

Structs§

BasicNode
An implementation of trait Node that contains minimal node information.
ClusterNode
Information about a single node in the cluster.
ClusterSecret
A shared secret used to authenticate cluster transport messages.
ClusterSnapshot
State machine snapshot.
ClusterState
The complete state of the cluster as seen by a node.
ClusterStateData
Internal cluster state managed by the state machine.
Election
State for an in-progress automatic failover election.
GossipConfig
Configuration for the gossip protocol.
GossipEngine
The gossip engine manages cluster membership and failure detection.
MemberInfo
Information about a cluster member.
MemberState
Internal state of a cluster member as tracked by gossip.
Migration
A single slot migration operation.
MigrationBatch
Represents a batch of keys to migrate.
MigrationConfig
Configuration for migration behavior.
MigrationEntry
A single key-value entry being migrated.
MigrationId
Unique identifier for a migration operation.
MigrationManager
Tracks all active migrations for a node.
NodeFlags
Status flags for a node.
NodeId
Unique identifier for a cluster node.
NodeInfo
Information about a cluster node.
RaftNetworkFactory
Factory that creates per-peer RaftNetworkClient instances.
RaftNode
High-level Raft node wrapper.
RaftStorage
Combined log and state machine storage for Raft.
SlotMap
Maps each of the 16384 slots to a node ID.
SlotRange
A contiguous range of slots assigned to a node.
TypeConfig
Type configuration for openraft.

Enums§

ClusterCommand
Commands that modify cluster configuration.
ClusterError
Errors that can occur during cluster operations.
ClusterHealth
Overall cluster health status.
ClusterResponse
Response from applying a cluster command.
ConfigParseError
Error returned when parsing a nodes.conf file fails.
GossipEvent
Events emitted by the gossip engine.
GossipMessage
Message types for the SWIM gossip protocol.
MemberStatus
Health status of a member.
MigrationError
Errors that can occur during migration.
MigrationRedirect
Result of checking whether a command should be redirected during migration.
MigrationState
Current state of a slot migration.
NodeRole
The role of a node in the cluster.
NodeUpdate
A state update about a node, piggybacked on protocol messages.
RaftDiskError
RaftProposalError
Error from proposing a command through Raft.

Constants§

SLOT_COUNT
Total number of hash slots in the cluster (Redis Cluster standard).

Functions§

key_slot
Computes the hash slot for a key.
raft_id_from_node_id
Derives a stable u64 raft ID from a NodeId UUID.