Internals
This section explains how Kommander works below the public API. It is meant for developers who want to understand the runtime before operating it, debugging it, or contributing to it.
Kommander is organized around one core rule:
A partition's mutable Raft state has one owner at a time.
That rule is why the current implementation uses explicit partition executors, fair WAL schedulers, and a system coordinator instead of letting many threads update Raft state directly.
Main Components
| Component | Role |
|---|---|
RaftManager | Process-level coordinator. Owns discovery, communication, partitions, schedulers, timers, and the system coordinator. |
RaftPartition | Public-facing wrapper for one partition. Converts API calls and transport messages into executor operations. |
RaftPartitionExecutor | Single-threaded owner of one partition's state transitions. |
RaftPartitionStateMachine | Holds Raft state for a partition: role, term, votes, proposals, commit tracking, and leader expectations. |
RaftWriteAhead | WAL facade for recovery, propose, commit, rollback, follower append, checkpoint, and compaction work. |
FairReadScheduler | Runs synchronous WAL reads on fair, partition-aware worker queues. |
FairWalScheduler | Runs synchronous WAL writes on fair, partition-aware worker queues. |
RaftTimerService | Periodically injects leadership, heartbeat, discovery, and maintenance work. |
RaftTransportDispatcher | Sends outbound protocol responses without mutating partition state directly. |
RaftSystemCoordinator | Serializes system partition configuration changes, including partition range initialization and splits. |
Request Flow
A typical application write follows this path:
- The caller invokes
IRaft.ReplicateLogs. RaftManagerfinds the targetRaftPartition.RaftPartitionchecks that the local node is the partition leader.- The partition posts a client operation to
RaftPartitionExecutor. RaftPartitionStateMachinecreates a proposal and asksRaftWriteAheadto persist it.FairWalSchedulerwrites to the configuredIWALadapter.- The WAL completion is posted back to the same partition executor.
- The leader sends append-log messages to followers.
- After quorum completion, the proposal is committed or left for manual commit depending on
autoCommit. - Committed entries reach the application through
OnReplicationReceived.
The important point: network messages, timers, storage completions, and client calls all become partition operations. They do not mutate the partition state from random threads.