pub trait Reaction: Sized {
    type Incoming;
    type Returning;

    // Required methods
    fn noop() -> Self;
    fn drop_frame() -> Self;
    fn delay(time: Duration) -> Self;
    fn forge_response(
        f: Arc<dyn Fn(Self::Incoming) -> Self::Returning + Send + Sync>
    ) -> Self;
    fn forge_response_with_delay(
        time: Duration,
        f: Arc<dyn Fn(Self::Incoming) -> Self::Returning + Send + Sync>
    ) -> Self;
    fn drop_connection() -> Self;
    fn drop_connection_with_delay(time: Duration) -> Self;
    fn with_feedback_when_performed(
        self,
        tx: UnboundedSender<Self::Incoming>
    ) -> Self;
}
Expand description

Just a trait to unify API of both RequestReaction and ResponseReaction. As they are both analogous, I will describe them here.

  • to_addressee and to_sender field correspond to actions that the proxy should perform towards the frame’s intended receiver and sender, respectively.
  • drop_connection’s outer Option denotes whether proxy should drop connection after performing the remaining actions, and its inner Option contains the delay of the drop.
  • feedback_channel is a channel to which proxy shall send any frame that matches the rule. It can be useful for testing that a particular node was the intended adressee of the frame.

Reaction contains useful constructors of common-case Reactions. The names should be self-explanatory.

Required Associated Types§

Required Methods§

source

fn noop() -> Self

Does nothing extraordinary, i.e. passes the frame with no changes to it.

source

fn drop_frame() -> Self

Drops frame, i.e. passes it into void.

source

fn delay(time: Duration) -> Self

Passes the frame only after specified delay.

source

fn forge_response( f: Arc<dyn Fn(Self::Incoming) -> Self::Returning + Send + Sync> ) -> Self

Instead of passing the frame to the addressee, returns the forged frame back to the addresser.

source

fn forge_response_with_delay( time: Duration, f: Arc<dyn Fn(Self::Incoming) -> Self::Returning + Send + Sync> ) -> Self

The same as forge_response, but with specified delay.

source

fn drop_connection() -> Self

Drops the frame AND drops the connection with both the driver and the cluster.

source

fn drop_connection_with_delay(time: Duration) -> Self

The same as drop_connection, but with specified delay.

source

fn with_feedback_when_performed( self, tx: UnboundedSender<Self::Incoming> ) -> Self

Adds sending the matching frame as feedback using the provided channel. Modifies the existing Reaction.

Implementors§