Skip to main content

DistributedRegionRecord

Struct DistributedRegionRecord 

Source
pub struct DistributedRegionRecord {
    pub id: RegionId,
    pub state: DistributedRegionState,
    pub config: DistributedRegionConfig,
    pub replicas: Vec<ReplicaInfo>,
    pub transitions: VecDeque<StateTransition>,
    pub last_replicated: Option<Time>,
    pub parent: Option<RegionId>,
    pub budget: Budget,
}
Expand description

Internal record for a distributed region.

Fields§

§id: RegionId

Unique identifier for this region.

§state: DistributedRegionState

Distributed-specific state.

§config: DistributedRegionConfig

Configuration for this region.

§replicas: Vec<ReplicaInfo>

Active replicas (by replica ID).

§transitions: VecDeque<StateTransition>

State transition history (bounded).

§last_replicated: Option<Time>

Last successful replication timestamp.

§parent: Option<RegionId>

Parent region (if nested).

§budget: Budget

Budget allocated to this region.

Implementations§

Source§

impl DistributedRegionRecord

Source

pub fn new( id: RegionId, config: DistributedRegionConfig, parent: Option<RegionId>, budget: Budget, ) -> Self

Creates a new distributed region in Initializing state.

Source

pub fn activate(&mut self, now: Time) -> Result<StateTransition, Error>

Attempts to transition to Active state.

Returns error if quorum not reached or invalid transition.

Source

pub fn replica_lost( &mut self, replica_id: &str, now: Time, ) -> Result<StateTransition, Error>

Marks a replica as lost and potentially degrades the region.

Source

pub fn trigger_recovery( &mut self, initiator: &str, now: Time, ) -> Result<StateTransition, Error>

Triggers recovery from degraded state.

Source

pub fn complete_recovery( &mut self, symbols_used: u32, now: Time, ) -> Result<StateTransition, Error>

Marks recovery as complete. Returns to Active.

Source

pub fn fail_recovery( &mut self, reason: String, now: Time, ) -> Result<StateTransition, Error>

Marks recovery as failed. Transitions to Closing.

Source

pub fn begin_close( &mut self, reason: TransitionReason, now: Time, ) -> Result<StateTransition, Error>

Begins the closing process.

Source

pub fn complete_close(&mut self, now: Time) -> Result<StateTransition, Error>

Completes the close (terminal transition).

Source

pub fn current_quorum(&self) -> u32

Returns the current quorum count (healthy replicas).

Source

pub fn has_quorum(&self) -> bool

Returns true if quorum is maintained.

Source

pub fn healthy_replicas(&self) -> u32

Returns healthy replica count.

Source

pub fn add_replica(&mut self, info: ReplicaInfo) -> Result<(), Error>

Adds a replica to the region.

Source

pub fn remove_replica(&mut self, replica_id: &str) -> Result<ReplicaInfo, Error>

Removes a replica from the region.

Source

pub fn update_replica_status( &mut self, replica_id: &str, status: ReplicaStatus, now: Time, ) -> Result<(), Error>

Updates replica status based on heartbeat.

Trait Implementations§

Source§

impl Debug for DistributedRegionRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> Same for T

Source§

type Output = T

Should always be Self
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<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