MARS documentation
Rust librariesmars-shard

mars-shard · topology

Public declarations and documentation for mars-shard::topology.

Prototype / draft — separate from production registry operations.

Package: mars-shard · Workspace version: 0.1.0 · Module: topology

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.

topology::ShardStatus

Operational status of a shard.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ShardStatus {
    /// Shard is operational and accepting reads/writes.
    Active,
    /// Shard is in the process of splitting into two.
    Splitting,
    /// Shard is being merged with another shard.
    Merging,
    /// Shard data is being migrated to another cluster.
    Migrating,
    /// Shard is not available.
    Offline,
}

Source line: 18.

topology::ShardInfo

Metadata about a single shard in the topology.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShardInfo {
/// Unique shard identifier.

pub shard_id: String,
/// Cluster this shard belongs to.

pub cluster_id: String,
/// Region where this shard is deployed.

pub region: String,
/// Current operational status.

pub status: ShardStatus,
/// Capacity utilization as a fraction (0.0 to 1.0).

pub capacity_pct: f64,
/// Number of entries stored in this shard.

pub entry_count: u64,
/// IDs of shadow (replica) shards.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub shadow_shard_ids: Vec<String>,
/// Primary node responsible for this shard.

#[serde(skip_serializing_if = "Option::is_none")]
pub primary_node: Option<String>,
/// When this shard was created.

pub created_at: chrono::DateTime<chrono::Utc>
}

Source line: 38.

topology::ShardTopology

The complete shard topology map.

Tracks all shards and their organization into clusters and regions.

pub struct ShardTopology {

}

Source line: 68.

topology::ShardTopology::new

Create a new empty topology.

pub fn new() -> Self;

Source line: 76.

topology::ShardTopology::add_shard

Add a shard to the topology.

Returns an error if a shard with the same ID already exists.

pub fn add_shard(&mut self, info: ShardInfo) -> Result<(), ShardError>;

Source line: 87.

topology::ShardTopology::remove_shard

Remove a shard from the topology.

Returns an error if the shard does not exist.

pub fn remove_shard(&mut self, shard_id: &str) -> Result<(), ShardError>;

Source line: 135.

topology::ShardTopology::get_shard

Get a shard by ID.

pub fn get_shard(&self, shard_id: &str) -> Option<&ShardInfo>;

Source line: 160.

topology::ShardTopology::get_shard_mut

Get a mutable reference to a shard by ID.

pub fn get_shard_mut(&mut self, shard_id: &str) -> Option<&mut ShardInfo>;

Source line: 165.

topology::ShardTopology::shards_in_cluster

List all shards in a cluster.

pub fn shards_in_cluster(&self, cluster_id: &str) -> Vec<&ShardInfo>;

Source line: 170.

topology::ShardTopology::shards_in_region

List all shards in a region (across all clusters in that region).

pub fn shards_in_region(&self, region: &str) -> Vec<&ShardInfo>;

Source line: 178.

topology::ShardTopology::active_shards

List all shards with Active status.

pub fn active_shards(&self) -> Vec<&ShardInfo>;

Source line: 191.

topology::ShardTopology::overloaded_shards

List shards whose capacity exceeds the given threshold.

pub fn overloaded_shards(&self, threshold: f64) -> Vec<&ShardInfo>;

Source line: 199.

topology::ShardTopology::underloaded_shards

List shards whose capacity is below the given threshold.

pub fn underloaded_shards(&self, threshold: f64) -> Vec<&ShardInfo>;

Source line: 207.

topology::ShardTopology::total_entries

Total number of entries across all shards.

pub fn total_entries(&self) -> u64;

Source line: 215.

topology::ShardTopology::shard_count

Total number of shards in the topology.

pub fn shard_count(&self) -> usize;

Source line: 222.

topology::ShardTopology::cluster_count

Total number of clusters.

pub fn cluster_count(&self) -> usize;

Source line: 227.

topology::ShardTopology::region_count

Total number of regions.

pub fn region_count(&self) -> usize;

Source line: 232.

Source provenance

Source: mars-shard/src/topology.rs · SHA-256 fa790e6d4372ac79f0fa195271074df00abea570b5920af8afe5c48ef5d4c8db. Package overview.

On this page