pub struct Subscription { /* private fields */ }Expand description
A subscription to a replication stream.
Manages the lifecycle of subscribing to a feeder’s replication stream: connecting, receiving entries, tracking progress, and shutting down.
Implementations§
Source§impl Subscription
impl Subscription
Sourcepub fn new(config: SubscriptionConfig) -> Self
pub fn new(config: SubscriptionConfig) -> Self
Create a new subscription with the given configuration.
Sourcepub fn get_state(&self) -> SubscriptionState
pub fn get_state(&self) -> SubscriptionState
Get the current subscription state.
Sourcepub fn get_current_vlsn(&self) -> u64
pub fn get_current_vlsn(&self) -> u64
Get the most recently processed VLSN.
Sourcepub fn get_entries_received(&self) -> u64
pub fn get_entries_received(&self) -> u64
Get the total number of entries received.
Sourcepub fn get_config(&self) -> &SubscriptionConfig
pub fn get_config(&self) -> &SubscriptionConfig
Get the subscription configuration.
Sourcepub fn start(&self) -> Result<()>
pub fn start(&self) -> Result<()>
Start the subscription by connecting to the feeder.
Which calls
SubscriptionThread.start(), which in turn invokes
RepUtils.openSocket(feederAddr) to establish a TCP connection to the
feeder node.
Transitions: Idle → Connecting → Active on success, or
Idle → Connecting → Error if the connection attempt fails.
Sourcepub fn get_connection(&self) -> Option<TcpStream>
pub fn get_connection(&self) -> Option<TcpStream>
Get the live TCP connection to the feeder, if connected.
Returns a cloned handle to the underlying TcpStream. Callers use
this to send/receive replication protocol messages.
Sourcepub fn process_entry(&self, vlsn: u64, _entry_type: u8, _data: Vec<u8>)
pub fn process_entry(&self, vlsn: u64, _entry_type: u8, _data: Vec<u8>)
Process an incoming replicated entry.
Updates the current VLSN and entry count. In the full implementation, this would also invoke the subscription callback.
Sourcepub fn mark_caught_up(&self)
pub fn mark_caught_up(&self)
Mark the subscription as caught up with the master.
Sourcepub fn mark_error(&self)
pub fn mark_error(&self)
Transition the subscription to the error state.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Shutdown the subscription.
Closes the TCP connection to the feeder (if open) and marks the
subscription as shut down.
which stops the SubscriptionThread and closes the feeder socket.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Whether shutdown has been requested.
Auto Trait Implementations§
impl !Freeze for Subscription
impl !RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl UnsafeUnpin for Subscription
impl UnwindSafe for Subscription
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
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>
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>
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