mars-shard · lifecycle
Public declarations and documentation for mars-shard::lifecycle.
Prototype / draft — separate from production registry operations.
Package: mars-shard · Workspace version: 0.1.0 · Module: lifecycle
Status: prototype / draft. This is not the production registry topology.
This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.
lifecycle::LifecycleEvent
A lifecycle event describing a shard operation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum LifecycleEvent {
/// A shard is being split into two new shards.
Split {
source_shard: String,
new_shard_a: String,
new_shard_b: String,
},
/// Two shards are being merged into one.
Merge {
shard_a: String,
shard_b: String,
target_shard: String,
},
/// A shard is being migrated between clusters.
Migrate {
shard: String,
from_cluster: String,
to_cluster: String,
},
}Source line: 20.
lifecycle::OperationState
State machine for a lifecycle operation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum OperationState {
/// Operation has been created but not started.
Initiated,
/// Operation is actively executing.
InProgress,
/// Operation is finalizing (writing metadata, updating topology).
Completing,
/// Operation completed successfully.
Complete,
/// Operation failed with a reason.
Failed(String),
}Source line: 47.
lifecycle::LifecycleOperation
A tracked lifecycle operation.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LifecycleOperation {
/// Unique operation ID.
pub id: String,
/// The lifecycle event being executed.
pub event: LifecycleEvent,
/// Current state of the operation.
pub state: OperationState,
/// When the operation was initiated.
pub started_at: chrono::DateTime<chrono::Utc>,
/// When the operation completed (if it has).
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_at: Option<chrono::DateTime<chrono::Utc>>
}Source line: 67.
lifecycle::LifecycleManager
Manages shard split, merge, and migrate operations.
pub struct LifecycleManager {
}Source line: 86.
lifecycle::LifecycleManager::new
Create a new lifecycle manager with the given thresholds.
split_threshold: capacity fraction above which a shard should split (default 0.80).merge_threshold: capacity fraction below which a shard should merge (default 0.20).
pub fn new(split_threshold: f64, merge_threshold: f64) -> Self;Source line: 100.
lifecycle::LifecycleManager::check_split_needed
Check whether a shard's capacity exceeds the split threshold.
pub fn check_split_needed(&self, shard: &ShardInfo) -> bool;Source line: 130.
lifecycle::LifecycleManager::check_merge_needed
Check whether a shard's capacity is below the merge threshold.
pub fn check_merge_needed(&self, shard: &ShardInfo) -> bool;Source line: 135.
lifecycle::LifecycleManager::initiate_split
Initiate a split operation for a shard.
Creates two new shard IDs derived from the source shard.
pub fn initiate_split(&mut self, shard_id: &str) -> Result<LifecycleOperation, ShardError>;Source line: 142.
lifecycle::LifecycleManager::initiate_merge
Initiate a merge operation combining two shards.
pub fn initiate_merge(
&mut self,
shard_a: &str,
shard_b: &str,
) -> Result<LifecycleOperation, ShardError>;Source line: 168.
lifecycle::LifecycleManager::initiate_migrate
Initiate a migration operation.
pub fn initiate_migrate(
&mut self,
shard_id: &str,
from_cluster: &str,
to_cluster: &str,
) -> Result<LifecycleOperation, ShardError>;Source line: 207.
lifecycle::LifecycleManager::advance
Advance a lifecycle operation to a new state.
pub fn advance(&mut self, op_id: &str, new_state: OperationState) -> Result<(), ShardError>;Source line: 237.
lifecycle::LifecycleManager::pending_operations
List all pending (non-complete, non-failed) operations.
pub fn pending_operations(&self) -> Vec<&LifecycleOperation>;Source line: 268.
lifecycle::LifecycleManager::all_operations
List all operations (including completed and failed).
pub fn all_operations(&self) -> &[LifecycleOperation];Source line: 281.
lifecycle::LifecycleManager::split_threshold
Returns the split threshold.
pub fn split_threshold(&self) -> f64;Source line: 286.
lifecycle::LifecycleManager::merge_threshold
Returns the merge threshold.
pub fn merge_threshold(&self) -> f64;Source line: 291.
Source provenance
Source: mars-shard/src/lifecycle.rs · SHA-256 1a0713b91233ac4dd92ade4240deb3ba285cef98732e485fd9e773fbee863341. Package overview.