Skip to main content

Subscription

Struct Subscription 

Source
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

Source

pub fn new(config: SubscriptionConfig) -> Self

Create a new subscription with the given configuration.

Source

pub fn get_state(&self) -> SubscriptionState

Get the current subscription state.

Source

pub fn get_current_vlsn(&self) -> u64

Get the most recently processed VLSN.

Source

pub fn get_entries_received(&self) -> u64

Get the total number of entries received.

Source

pub fn get_config(&self) -> &SubscriptionConfig

Get the subscription configuration.

Source

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: IdleConnectingActive on success, or IdleConnectingError if the connection attempt fails.

Source

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.

Source

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.

Source

pub fn mark_caught_up(&self)

Mark the subscription as caught up with the master.

Source

pub fn mark_error(&self)

Transition the subscription to the error state.

Source

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.

Source

pub fn is_shutdown(&self) -> bool

Whether shutdown has been requested.

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, 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, 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