MockTransport

Struct MockTransport 

Source
pub struct MockTransport<T>
where T: TypeConfig,
{ /* private fields */ }

Implementations§

Source§

impl<T> MockTransport<T>
where T: TypeConfig,

Source

pub fn checkpoint(&mut self)

Validate that all current expectations for all methods have been satisfied, and discard them.

Source

pub fn new() -> Self

Create a new mock object with no expectations.

This method will not be generated if the real struct already has a new method. However, it will be generated if the struct implements a trait with a new method. The trait’s new method can still be called like <MockX as TraitY>::new

Source§

impl<T> MockTransport<T>
where T: TypeConfig,

Source

pub fn expect_send_cluster_update(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the send_cluster_update method

Source

pub fn expect_send_append_requests(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the send_append_requests method

Source

pub fn expect_send_vote_requests(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the send_vote_requests method

Source

pub fn expect_send_purge_requests(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the send_purge_requests method

Source

pub fn expect_join_cluster(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the join_cluster method

Source

pub fn expect_discover_leader(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the discover_leader method

Source

pub fn expect_request_snapshot_from_leader(&mut self) -> &mut Expectation<T>

Create an Expectation for mocking the request_snapshot_from_leader method

Trait Implementations§

Source§

impl<T> Debug for MockTransport<T>
where T: TypeConfig,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Default for MockTransport<T>
where T: TypeConfig,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Transport<T> for MockTransport<T>
where T: TypeConfig,

Source§

fn send_cluster_update<'life0, 'life1, 'async_trait>( &'life0 self, req: ClusterConfChangeRequest, retry: &'life1 RetryPolicies, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<ClusterUpdateResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Propagates cluster configuration changes to voting members using Raft’s joint consensus.

§Protocol
  • Implements membership change protocol from Raft §6
  • Leader-exclusive operation
  • Automatically filters self-references and duplicates
§Parameters
  • req: Configuration change details with transition state
  • retry: Network retry policy with exponential backoff
  • membership: Cluster membership for channel resolution
§Errors
  • NetworkError::EmptyPeerList if no peers provided
  • NetworkError::TaskFailed for background execution failures
  • ConsensusError::NotLeader if executed by non-leader
§Implementation
  • Uses compressed gRPC streams for efficiency
  • Maintains response order matching input peers
  • Concurrent request processing with ordered aggregation
Source§

fn send_append_requests<'life0, 'life1, 'async_trait>( &'life0 self, requests: Vec<(u32, AppendEntriesRequest)>, retry: &'life1 RetryPolicies, membership: Arc<MOF<T>>, response_compress_enabled: bool, ) -> Pin<Box<dyn Future<Output = Result<AppendResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Replicates log entries to followers and learners.

§Protocol
  • Implements log replication from Raft §5.3
  • Leader-exclusive operation
  • Handles log consistency checks automatically
§Parameters
  • requests: Vector of (peer_id, AppendEntriesRequest)
  • retry: Network retry configuration
  • membership: Cluster membership for channel resolution
  • response_compress_enabled: Enable compression for replication responses
§Returns
  • On success: Ok(AppendResult) containing aggregated responses
  • On failure: Err(NetworkError) for unrecoverable errors
§Error Conditions: Top-level Err is returned ONLY when:
  • Input requests_with_peer_address is empty (NetworkError::EmptyPeerList)
  • Critical failures prevent spawning async tasks (not shown in current impl)
§Errors
  • NetworkError::EmptyPeerList for empty input
  • NetworkError::TaskFailed for partial execution failures
§Guarantees
  • At-least-once delivery semantics
  • Automatic deduplication of peer entries
  • Non-blocking error handling
Source§

fn send_vote_requests<'life0, 'life1, 'async_trait>( &'life0 self, req: VoteRequest, retry: &'life1 RetryPolicies, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<VoteResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Initiates leader election by requesting votes from cluster peers.

§Protocol
  • Implements leader election from Raft §5.2
  • Candidate-exclusive operation
  • Validates log completeness requirements
§Parameters
  • req: Election metadata with candidate’s term and log state
  • retry: Election-specific retry strategy
  • membership: Cluster membership for channel resolution
§Errors
  • NetworkError::EmptyPeerList for empty peer list
  • NetworkError::TaskFailed for RPC execution failures
§Safety
  • Automatic term validation in responses
  • Strict candidate state enforcement
  • Non-blocking partial failure handling
Source§

fn send_purge_requests<'life0, 'life1, 'async_trait>( &'life0 self, req: PurgeLogRequest, retry: &'life1 RetryPolicies, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Result<PurgeLogResponse>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Orchestrates log compaction across cluster peers after snapshot creation.

§Protocol
  • Implements log truncation from Raft §7
  • Leader-exclusive operation
  • Requires valid snapshot checksum
§Parameters
  • req: Snapshot metadata with truncation index
  • retry: Purge-specific retry configuration
  • membership: Cluster membership for channel resolution
§Errors
  • NetworkError::EmptyPeerList for empty peer list
  • NetworkError::TaskFailed for background execution errors
§Guarantees
  • At-least-once delivery
  • Automatic progress tracking
  • Crash-safe persistence requirements
Source§

fn join_cluster<'life0, 'async_trait>( &'life0 self, leader_id: u32, request: JoinRequest, retry: BackoffPolicy, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<JoinResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initiates cluster join process for a learner node

§Protocol
  • Implements cluster join protocol from Raft §6
  • Learner-exclusive operation
  • Requires leader connection
§Parameters
  • leader_channel: Pre-established gRPC channel to cluster leader
  • request: Join request with node metadata
  • retry: Join-specific retry configuration
  • membership: Cluster membership for channel resolution
§Errors
  • NetworkError::JoinFailed: On unrecoverable join failure
  • NetworkError::NotLeader: If contacted node isn’t leader
§Guarantees
  • At-least-once delivery
  • Automatic leader discovery
  • Idempotent operation
Source§

fn discover_leader<'life0, 'async_trait>( &'life0 self, request: LeaderDiscoveryRequest, rpc_enable_compression: bool, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<LeaderDiscoveryResponse>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Discovers current cluster leader

§Protocol
  • Broadcast-based leader discovery
  • Handles redirection to current leader
§Parameters
  • bootstrap_endpoints: Initial cluster endpoints
  • request: Discovery request with node metadata
§Errors
  • NetworkError::DiscoveryTimeout: When no response received
Source§

fn request_snapshot_from_leader<'life0, 'life1, 'async_trait>( &'life0 self, leader_id: u32, ack_tx: Receiver<SnapshotAck>, retry: &'life1 InstallSnapshotBackoffPolicy, membership: Arc<MOF<T>>, ) -> Pin<Box<dyn Future<Output = Result<Box<Streaming<SnapshotChunk>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Requests and streams a snapshot from the current leader.

§Parameters
  • leader_id: Current leader node ID
  • retry: Retry configuration (currently unused in implementation)
  • membership: Cluster membership for channel resolution
§Returns

Streaming of snapshot chunks from the leader

§Errors

Returns NetworkError if:

  • Connection to leader fails
  • gRPC call fails

Auto Trait Implementations§

§

impl<T> Freeze for MockTransport<T>

§

impl<T> RefUnwindSafe for MockTransport<T>
where T: RefUnwindSafe,

§

impl<T> Send for MockTransport<T>

§

impl<T> Sync for MockTransport<T>

§

impl<T> Unpin for MockTransport<T>
where T: Unpin,

§

impl<T> UnwindSafe for MockTransport<T>
where T: UnwindSafe,

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> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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<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