pub struct PartitionReplication {
pub partition_id: PartitionId,
/* private fields */
}Expand description
Replication state for a single partition
Fields§
§partition_id: PartitionIdPartition identifier
Implementations§
Source§impl PartitionReplication
impl PartitionReplication
Sourcepub fn new(
partition_id: PartitionId,
local_node: NodeId,
is_leader: bool,
config: ReplicationConfig,
) -> Self
pub fn new( partition_id: PartitionId, local_node: NodeId, is_leader: bool, config: ReplicationConfig, ) -> Self
Create new partition replication state
Sourcepub async fn become_leader(&self, epoch: u64, replicas: Vec<NodeId>)
pub async fn become_leader(&self, epoch: u64, replicas: Vec<NodeId>)
Become leader for this partition
Sourcepub fn become_follower(&self, epoch: u64)
pub fn become_follower(&self, epoch: u64)
Become follower for this partition
Sourcepub async fn record_appended(&self, offset: u64) -> Result<()>
pub async fn record_appended(&self, offset: u64) -> Result<()>
Record appended locally (called by storage layer)
Sourcepub async fn handle_replica_fetch(
&self,
replica_id: &NodeId,
fetch_offset: u64,
) -> Result<bool>
pub async fn handle_replica_fetch( &self, replica_id: &NodeId, fetch_offset: u64, ) -> Result<bool>
Handle replica fetch and update progress Returns true if ISR changed
Sourcepub async fn check_replica_health(&self) -> Vec<NodeId> ⓘ
pub async fn check_replica_health(&self) -> Vec<NodeId> ⓘ
Check for lagging replicas and remove from ISR
Sourcepub async fn wait_for_acks(&self, offset: u64, acks: Acks) -> Result<()>
pub async fn wait_for_acks(&self, offset: u64, acks: Acks) -> Result<()>
Wait for replication based on ack mode
Sourcepub fn high_watermark(&self) -> u64
pub fn high_watermark(&self) -> u64
Get current high watermark
Sourcepub fn log_end_offset(&self) -> u64
pub fn log_end_offset(&self) -> u64
Get current log end offset
Sourcepub fn leader_epoch(&self) -> u64
pub fn leader_epoch(&self) -> u64
Get current leader epoch
Sourcepub async fn has_min_isr(&self) -> bool
pub async fn has_min_isr(&self) -> bool
Check if we have enough ISR for writes
Sourcepub fn cleanup_stale_pending_acks(&self, timeout: Duration) -> usize
pub fn cleanup_stale_pending_acks(&self, timeout: Duration) -> usize
Clean up stale pending acks that have exceeded the timeout
Sends Err(Timeout) to waiters before removing stale entries, so callers
get a clear timeout error instead of a misleading ChannelClosed.
This should be called periodically to prevent memory leaks from
pending acks that were never completed (e.g., due to network partitions).
Returns the number of cleaned up entries.