[][src]Trait tcb::broadcast::broadcast_trait::TCB

pub trait TCB {
    type SendCallReturn;
    fn new(
        local_id: usize,
        local_port: usize,
        peer_addresses: Vec<String>,
        configuration: Configuration
    ) -> Self;
fn send(&mut self, msg: Vec<u8>) -> Self::SendCallReturn;
fn end(&self);
fn recv(&mut self) -> Result<GenericReturn, RecvError>;
fn try_recv(&mut self) -> Result<GenericReturn, TryRecvError>;
fn recv_timeout(
        &mut self,
        duration: Duration
    ) -> Result<GenericReturn, RecvTimeoutError>;
fn tcbstable(&mut self, id: usize, counter: usize); }

Required API for the Tagged Causal Broadcast middleware. This trait is implemented by the GRAPH and VV middleware implementations. The delivery functions return messages wrapped in a generic enum so that this trait can be implemented by both approaches.

Associated Types

type SendCallReturn

Type of the return from a send call.

Loading content...

Required methods

fn new(
    local_id: usize,
    local_port: usize,
    peer_addresses: Vec<String>,
    configuration: Configuration
) -> Self

Creates a new middleware instance. This function only returns after the middleware has a connection to every other peer in both directions.

Arguments

local_id - Peer's globally unique id in the group.

local_port - Port where the middleware will be listening for connections.

peer_addresses - Addresses the middleware will connect to.

configuration - Middleware's configuration file.

fn send(&mut self, msg: Vec<u8>) -> Self::SendCallReturn

Broadcasts a message to every peer in the group. Returns the sent message context if successfull.

Arguments

msg - Serialized message to be broadcast

fn end(&self)

Signals and waits for the middleware to terminate.

fn recv(&mut self) -> Result<GenericReturn, RecvError>

Delivers a message from the middleware. Blocks the calling thread until a message is delivered or the channel to the middleware is empty or disconnected.

fn try_recv(&mut self) -> Result<GenericReturn, TryRecvError>

Attempts to deliver a message from the middleware without blocking the caller thread. Either a message is immeadiately delivered from the channel or an error is returned if the channel is empty.

fn recv_timeout(
    &mut self,
    duration: Duration
) -> Result<GenericReturn, RecvTimeoutError>

Waits for a message to be delivered from the middleware for a limited time. If the channel is empty and not disconnected, the caller thread is blocked until a message is received in the channel or the timeout ends. If there are no messages until the timeout ends or the channel becomes disconnected, an error is returned.

Arguments

duration - Timeout duration

fn tcbstable(&mut self, id: usize, counter: usize)

ACKS a stable message. This is needed for the GRAPH approach so the node with the message's information can be deleted from the graph and its position in the array be available and reused for another message. Otherwise the array that maps the causal dependency graph will grow exponentially. However, if stability was disabled from the configuration file, then the message's are directly removed from the graph upon delivery, rendering the call to this method unnecessary.

The VV implementation doesn't require the call of this method.

Arguments

id - Stable dot id field

counter - Stable dot counter field

Loading content...

Implementors

impl TCB for GRAPH[src]

type SendCallReturn = Result<Vec<Dot>, SendError<ClientPeerMiddleware>>

Type of the return from a send call, which is the sent message context or an error.

fn new(
    local_id: usize,
    local_port: usize,
    peer_addresses: Vec<String>,
    configuration: Configuration
) -> Self
[src]

Creates a new middleware instance. This function only returns after the middleware has a connection to every other peer in both directions.

Arguments

local_id - Peer's globally unique id in the group.

local_port - Port where the middleware will be listening for connections.

peer_addresses - Addresses the middleware will connect to.

configuration - Middleware's configuration file.

fn send(&mut self, msg: Vec<u8>) -> Self::SendCallReturn[src]

Broadcasts a message to every peer in the group. Returns the sent message context if successfull.

Arguments

msg - Serialized message to be broadcast

fn end(&self)[src]

Signals and waits for the middleware to terminate.

fn recv(&mut self) -> Result<GenericReturn, RecvError>[src]

Delivers a message from the middleware. Blocks the calling thread until a message is delivered or the channel to the middleware is empty or disconnected.

fn try_recv(&mut self) -> Result<GenericReturn, TryRecvError>[src]

Attempts to deliver a message from the middleware without blocking the caller thread. Either a message is immeadiately delivered from the channel or an error is returned if the channel is empty.

fn recv_timeout(
    &mut self,
    duration: Duration
) -> Result<GenericReturn, RecvTimeoutError>
[src]

Waits for a message to be delivered from the middleware for a limited time. If the channel is empty and not disconnected, the caller thread is blocked until a message is received in the channel or the timeout ends. If there are no messages until the timeout ends or the channel becomes disconnected, an error is returned.

Arguments

duration - Timeout duration

fn tcbstable(&mut self, id: usize, counter: usize)[src]

ACKS a stable message. This is needed for the GRAPH approach so the node with the message's information can be deleted from the graph and its position in the array be available and reused for another message. Otherwise the array that maps the causal dependency graph will grow exponentially. However, if stability was disabled from the configuration file, then the message's are directly removed from the graph upon delivery, rendering the call to this method unnecessary.

The VV implementation doesn't require the call of this method.

Arguments

id - Stable dot id field

counter - Stable dot counter field

impl TCB for VV[src]

type SendCallReturn = Result<(), SendError<ClientPeerMiddleware>>

Type of the return from a send call, which is an empty value or an error.

fn new(
    local_id: usize,
    local_port: usize,
    peer_addresses: Vec<String>,
    configuration: Configuration
) -> Self
[src]

Creates a new middleware instance. This function only returns after the middleware has a connection to every other peer in both directions.

Arguments

local_id - Peer's globally unique id in the group.

local_port - Port where the middleware will be listening for connections.

peer_addresses - Addresses the middleware will connect to.

configuration - Middleware's configuration file.

fn send(&mut self, message: Vec<u8>) -> Self::SendCallReturn[src]

Broadcasts a message to every peer in the group. Returns the sent message context if successfull.

Arguments

message - Serialized message to be broadcast

fn end(&self)[src]

Signals and waits for the middleware to terminate.

fn recv(&mut self) -> Result<GenericReturn, RecvError>[src]

Delivers a message from the middleware. Blocks the calling thread until a message is delivered or the channel to the middleware is empty or disconnected.

fn try_recv(&mut self) -> Result<GenericReturn, TryRecvError>[src]

Attempts to deliver a message from the middleware without blocking the caller thread. Either a message is immeadiately delivered from the channel or an error is returned if the channel is empty.

fn recv_timeout(
    &mut self,
    duration: Duration
) -> Result<GenericReturn, RecvTimeoutError>
[src]

Waits for a message to be delivered from the middleware for a limited time. If the channel is empty and not disconnected, the caller thread is blocked until a message is received in the channel or the timeout ends. If there are no messages until the timeout ends or the channel becomes disconnected, an error is returned.

Arguments

duration - Timeout duration

fn tcbstable(&mut self, _: usize, _: usize)[src]

ACKS a stable message, but is not necessary to call in the VV approach.

id - Stable dot id field

counter - Stable dot counter field

Loading content...