Trait scylla_proxy::Reaction
source · 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
andto_sender
field correspond to actions that the proxy should perform towards the frame’s intended receiver and sender, respectively.drop_connection
’s outerOption
denotes whether proxy should drop connection after performing the remaining actions, and its innerOption
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§
sourcefn drop_frame() -> Self
fn drop_frame() -> Self
Drops frame, i.e. passes it into void.
sourcefn forge_response(
f: Arc<dyn Fn(Self::Incoming) -> Self::Returning + Send + Sync>
) -> Self
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.
sourcefn forge_response_with_delay(
time: Duration,
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
The same as forge_response, but with specified delay.
sourcefn drop_connection() -> Self
fn drop_connection() -> Self
Drops the frame AND drops the connection with both the driver and the cluster.
sourcefn drop_connection_with_delay(time: Duration) -> Self
fn drop_connection_with_delay(time: Duration) -> Self
The same as drop_connection, but with specified delay.
sourcefn with_feedback_when_performed(
self,
tx: UnboundedSender<Self::Incoming>
) -> Self
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
.