pub struct PrimaryTracker { /* private fields */ }Expand description
Primary Tracker
Can be used in three modes:
- With a TopologyProvider – automatic tracking via
with_provider(). - Standalone – manual
set_primary()/clear_primary()calls. - PostgreSQL – pass a
PostgresTopologyProvider(featurepostgres-topology).
Implementations§
Source§impl PrimaryTracker
impl PrimaryTracker
Sourcepub fn new_standalone() -> Self
pub fn new_standalone() -> Self
Create a standalone primary tracker (manual set/clear).
Sourcepub fn with_provider(provider: Arc<dyn TopologyProvider>) -> Self
pub fn with_provider(provider: Arc<dyn TopologyProvider>) -> Self
Create a primary tracker backed by a topology provider.
Sourcepub fn with_tracking_interval(self, interval: Duration) -> Self
pub fn with_tracking_interval(self, interval: Duration) -> Self
Set tracking interval.
Sourcepub fn subscribe(&self) -> Receiver<PrimaryChangeEvent>
pub fn subscribe(&self) -> Receiver<PrimaryChangeEvent>
Subscribe to primary change events.
Sourcepub fn get_primary(&self) -> Option<PrimaryInfo>
pub fn get_primary(&self) -> Option<PrimaryInfo>
Get current primary info.
Sourcepub fn get_primary_id(&self) -> Option<Uuid>
pub fn get_primary_id(&self) -> Option<Uuid>
Get current primary node ID.
Sourcepub fn get_primary_address(&self) -> Option<String>
pub fn get_primary_address(&self) -> Option<String>
Get current primary address.
Sourcepub fn has_primary(&self) -> bool
pub fn has_primary(&self) -> bool
Check if we have a healthy primary.
Sourcepub fn set_primary(&self, node_id: Uuid, address: String)
pub fn set_primary(&self, node_id: Uuid, address: String)
Set primary manually (or called during switchover).
Sourcepub fn confirm_primary(&self)
pub fn confirm_primary(&self)
Confirm the current primary (called after switchover completes).
Sourcepub fn clear_primary(&self)
pub fn clear_primary(&self)
Clear primary (called when primary is lost).
Auto Trait Implementations§
impl !Freeze for PrimaryTracker
impl !RefUnwindSafe for PrimaryTracker
impl Send for PrimaryTracker
impl Sync for PrimaryTracker
impl Unpin for PrimaryTracker
impl UnsafeUnpin for PrimaryTracker
impl !UnwindSafe for PrimaryTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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