pub struct ProxyMirrorPlugin {
host: String,
path: Option<String>,
sample_ratio: f64,
client: Arc<OutboundClient>,
}Expand description
Mirrors matching requests to a shadow host, best-effort.
Fields§
§host: StringShadow base URL, e.g. http://shadow:8080 (scheme + host + optional
port, no trailing path).
path: Option<String>Optional path override; when unset the original request path is used.
sample_ratio: f64Fraction of requests to mirror, in 0.0..=1.0.
client: Arc<OutboundClient>Shared pooled outbound HTTP client (from PluginResources).
Implementations§
Source§impl ProxyMirrorPlugin
impl ProxyMirrorPlugin
Sourcepub fn from_config(
config: &HashMap<String, Value>,
resources: &Arc<PluginResources>,
) -> Result<Self, String>
pub fn from_config( config: &HashMap<String, Value>, resources: &Arc<PluginResources>, ) -> Result<Self, String>
Builds the plugin from node config.
Accepted keys:
host(string, required): shadow base URL — scheme + host + optional port, e.g.http://shadow:8080. Must start withhttp://orhttps://; no trailing path.path(string, optional): overrides the mirrored request path; when unset the original request path is mirrored. The original query string is always appended.sample_ratio(number, default1.0): fraction of requests to mirror, in0.0..=1.0.1.0mirrors every request;0.0mirrors none. Sampling uses a pseudo-random draw (seeroll_fraction).
type: proxy-mirror
config:
host: "http://shadow:8080"
path: "/mirror"
sample_ratio: 0.5Sourcefn should_mirror(&self) -> bool
fn should_mirror(&self) -> bool
Decides whether this request should be mirrored, per sample_ratio.
>= 1.0 always mirrors, 0.0 never mirrors; otherwise a pseudo-random
draw is compared against the ratio.
Sourcefn build_request(&self, ctx: &Context) -> OutboundRequest
fn build_request(&self, ctx: &Context) -> OutboundRequest
Builds the outbound mirror request from the current context (pure; does
no I/O). The mirrored URL is host + (path override or the original
path) + the original query string. All request headers and the body are
copied.
Trait Implementations§
Source§impl Plugin for ProxyMirrorPlugin
impl Plugin for ProxyMirrorPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for ProxyMirrorPlugin
impl !RefUnwindSafe for ProxyMirrorPlugin
impl Send for ProxyMirrorPlugin
impl Sync for ProxyMirrorPlugin
impl Unpin for ProxyMirrorPlugin
impl UnsafeUnpin for ProxyMirrorPlugin
impl !UnwindSafe for ProxyMirrorPlugin
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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