Skip to main content

crafty_core/
lib.rs

1//! `crafty-core` — the pure Raft consensus state machine (no I/O).
2//!
3//! [`RaftNode`] drives leader election and log replication deterministically:
4//! it consumes events and returns [`Output`] effects for an outer runtime to
5//! execute (architecture-style). Because it performs no I/O and derives all randomness
6//! from a seed, an entire cluster can be simulated reproducibly (testing-strategy).
7//!
8//! Joint-consensus membership (membership-early), `ReadIndex` (read-consistency), and snapshots
9//! build on this foundation in later increments.
10
11pub use crafty_proto as proto;
12
13mod compaction;
14mod config;
15mod failure_detector;
16mod log;
17mod node;
18mod rng;
19mod shard;
20mod state_machine;
21mod two_phase;
22
23pub use compaction::{
24    CompactionPolicy, CompactionStats, DEFAULT_COMPACT_BYTES, DEFAULT_COMPACT_ENTRIES,
25    compaction_stats, entry_estimated_bytes, should_compact,
26};
27pub use failure_detector::{
28    AckWindowLiveness, FailureDetectorKind, PhiAccrualDetector, PhiAccrualLiveness,
29    ReachabilityConfig,
30};
31pub use node::{
32    CatalogProposeError, Committed, Config, MembershipError, NotLeader, Output, Persist, RaftNode,
33    ReadId, Role, SnapshotState,
34};
35pub use shard::{
36    CatalogError, CatalogExpansionPlan, DEFAULT_GROUP_LEARNER_FACTOR,
37    DEFAULT_GROUP_REPLICATION_FACTOR, GroupMembershipChange, GroupRebalancePlan,
38    GroupReplicationTarget, MAX_VIRTUAL_SHARDS, META_RAFT_GROUP_ID, RaftGroupId,
39    ShardCountExpansionPlan, ShardExpansionError, ShardId, ShardRouter, ShardRoutingKind,
40    ShardRoutingSwitchError, ShardRoutingSwitchPlan, StableShardActivationError,
41    StableShardActivationPlan, StableShardRouter, effective_replication_factor,
42    group_host_assignment, group_learners, group_membership_assignment, group_voters,
43    groups_joining_node_affects, groups_leaving_node_affects, is_meta_raft_group,
44    node_should_host_group, place_shard, plan_catalog_expansion, plan_group_membership_change,
45    plan_group_membership_sync, plan_node_group_rebalance, plan_shard_count_expansion,
46    plan_stable_shard_activation, plan_switch_to_stable_routing, shard_is_active,
47    stable_router_preserves_routable_keys, validate_catalog, virtual_shard_for,
48};
49pub use state_machine::{Command, Query, StateMachine};
50pub use two_phase::{
51    TWO_PHASE_DEFAULT_PREPARE_TIMEOUT_MS, TWO_PHASE_MAX_GROUPS, TWO_PHASE_MAX_PAYLOAD,
52    TWO_PHASE_MAX_STEPS, TwoPhasePlan, TwoPhasePlanError, TwoPhaseStep, validate_two_phase_plan,
53};