pub struct FaultInjectionPlugin {
abort: Option<AbortRule>,
delay: Option<DelayRule>,
}Expand description
Injects delays and/or abort responses into matching requests.
Order matches APISIX: the delay (if it triggers) is applied first, then
the abort check runs. body, and string header values, support $var
interpolation against the request.
Fields§
§abort: Option<AbortRule>§delay: Option<DelayRule>Implementations§
Source§impl FaultInjectionPlugin
impl FaultInjectionPlugin
Sourcepub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
pub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
Builds the plugin from node config. At least one of abort / delay
is required; expressions and shapes are validated here at config load.
Accepted keys:
abort(object): injected response.http_status(integer >= 200, required): response status.body(string): response body; supports$varinterpolation. Empty body when unset.headers(map{name: value}or array[{name, value}]): response headers; string values support$varinterpolation.percentage(integer 0-100): chance the abort triggers; unset means always.vars(array): APISIX condition expressions, OR-ed across items.
delay(object): injected latency.duration(number, seconds, may be fractional, required).percentage,vars: same gating as forabort.
type: fault-injection
config:
delay:
duration: 0.5
percentage: 30
abort:
http_status: 503
body: '{"error": "injected for $uri"}'
percentage: 10
vars:
- [["arg_debug", "==", "1"]]Trait Implementations§
Source§impl Plugin for FaultInjectionPlugin
impl Plugin for FaultInjectionPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”).
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,
Executes the plugin logic against the request/response context. Read more
Auto Trait Implementations§
impl Freeze for FaultInjectionPlugin
impl RefUnwindSafe for FaultInjectionPlugin
impl Send for FaultInjectionPlugin
impl Sync for FaultInjectionPlugin
impl Unpin for FaultInjectionPlugin
impl UnsafeUnpin for FaultInjectionPlugin
impl UnwindSafe for FaultInjectionPlugin
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
Mutably borrows from an owned value. Read more
§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>
Converts
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>
Converts
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