pub struct ControlPlane<S> { /* private fields */ }Expand description
Drives a partition through its migration phases against a MigrationStore,
enforcing the drain barrier between cutover and completion (docs/06 §5).
Implementations§
Source§impl<S: MigrationStore> ControlPlane<S>
impl<S: MigrationStore> ControlPlane<S>
Sourcepub fn new(store: S) -> Self
pub fn new(store: S) -> Self
Builds a controller over store with the default drain barrier and the
system clock.
Sourcepub fn with_barrier(self, barrier: Duration) -> Self
pub fn with_barrier(self, barrier: Duration) -> Self
Sets the drain barrier (builder style).
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self
Swaps the clock the barrier reads (tests inject a ManualClock).
Sourcepub async fn begin_migration(
&self,
partition: &PartitionId,
to: Placement,
) -> Result<Epoch, ControlError>
pub async fn begin_migration( &self, partition: &PartitionId, to: Placement, ) -> Result<Epoch, ControlError>
Begins migrating partition toward to. Writes keep flowing to the
origin during the ensuing drain phase.
§Errors
ControlError::Transition if the partition is unknown or migrating.
Sourcepub async fn enter_cutover(
&self,
partition: &PartitionId,
) -> Result<Epoch, ControlError>
pub async fn enter_cutover( &self, partition: &PartitionId, ) -> Result<Epoch, ControlError>
Enters the cutover window and starts the drain barrier clock. Writes are now rejected fleet-wide (every instance polls this fresh).
§Errors
ControlError::Transition if the partition is not draining.
Sourcepub async fn complete_migration(
&self,
partition: &PartitionId,
) -> Result<Epoch, ControlError>
pub async fn complete_migration( &self, partition: &PartitionId, ) -> Result<Epoch, ControlError>
Completes the migration once the drain barrier has elapsed since cutover, the pointer flip. Refused (without mutating the store) while in-flight pre-cutover writes might still be committing.
§Errors
ControlError::BarrierPending if the barrier has not elapsed;
ControlError::Transition if the partition is not in cutover.
Sourcepub async fn abort_migration(
&self,
partition: &PartitionId,
) -> Result<Epoch, ControlError>
pub async fn abort_migration( &self, partition: &PartitionId, ) -> Result<Epoch, ControlError>
Aborts an in-flight migration, returning the partition to its origin and clearing any pending barrier.
§Errors
ControlError::Transition if the partition is not migrating.
Sourcepub async fn state(
&self,
partition: &PartitionId,
) -> Option<(PartitionState, Epoch)>
pub async fn state( &self, partition: &PartitionId, ) -> Option<(PartitionState, Epoch)>
The partition’s current migration state and epoch, or None. For
operator/observability read-out (docs/06 §5).