Skip to main content

ReplicaManager

Struct ReplicaManager 

Source
pub struct ReplicaManager { /* private fields */ }
Expand description

Central manager for shard-level replica tracking and failover coordination.

Implementations§

Source§

impl ReplicaManager

Source

pub fn new(replication_factor: usize) -> Self

Create a new manager with the given target replication_factor.

replication_factor must be at least 1 (1 = primary only, no replicas).

Source

pub fn register_replica( &mut self, replica: ShardReplica, ) -> Result<(), VectorError>

Register a new replica.

§Errors

Returns VectorError::InvalidData when:

  • A replica with the same (shard_id, replica_id) already exists.
  • replica.state is Primary but a primary is already registered for that shard.
Source

pub fn unregister_replica(&mut self, shard_id: u64, replica_id: &str) -> bool

Unregister a replica by (shard_id, replica_id).

Returns true if the replica was found and removed.

Source

pub fn promote_to_primary( &mut self, shard_id: u64, replica_id: &str, ) -> Result<(), VectorError>

Promote replica_id to Primary for shard_id.

Any existing primary is demoted to Replica first.

§Errors

Returns VectorError::InvalidData when the target replica is not found or is in the Failed state.

Source

pub fn mark_failed(&mut self, shard_id: u64, replica_id: &str)

Mark a replica as Failed.

If the failed replica was the primary, no automatic failover occurs here — call promote_to_primary on a healthy replica to elect a new one.

A no-op when the (shard_id, replica_id) pair does not exist.

Source

pub fn auto_failover(&mut self, shard_id: u64) -> Result<String, VectorError>

Attempt automatic failover for shard_id when the current primary fails.

Selects the healthy replica with the largest vector_count (most up-to-date) and promotes it. Returns the promoted replica’s ID on success.

§Errors

Returns VectorError::InvalidData when no healthy replica exists for the shard.

Source

pub fn update_sync_progress( &mut self, shard_id: u64, replica_id: &str, progress: f64, )

Update the progress of a CatchingUp replica.

When progress reaches 1.0, the replica is automatically promoted to Replica.

Source

pub fn get_primary(&self, shard_id: u64) -> Option<&ShardReplica>

Return the primary replica for shard_id, if any.

Source

pub fn get_replicas(&self, shard_id: u64) -> Vec<&ShardReplica>

Return all replicas for shard_id (including primary).

Source

pub fn get_healthy_replicas(&self, shard_id: u64) -> Vec<&ShardReplica>

Return all healthy (non-failed) replicas for shard_id.

Source

pub fn shard_ids(&self) -> Vec<u64>

Return all tracked shard IDs.

Source

pub fn replication_factor(&self) -> usize

The configured replication factor.

Source

pub fn needs_rebalancing(&self) -> bool

Returns true when any shard is under- or over-replicated relative to the configured replication_factor.

Source

pub fn replication_status(&self) -> ReplicationStatus

Produce a ReplicationStatus summary of the cluster’s health.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Ungil for T
where T: Send,