Skip to main content

Action

Enum Action 

Source
pub enum Action {
    Log {
        level: LogLevel,
        message: String,
    },
    Emit {
        event_type: String,
        payload: Value,
    },
    SetContext {
        key: String,
        value: Value,
    },
    IncrementCounter {
        name: String,
        amount: i64,
    },
    Alert {
        severity: AlertSeverity,
        title: String,
        message: String,
    },
    Throttle {
        key: String,
        max_per_second: f64,
    },
    Reject {
        reason: String,
        code: u32,
    },
    Redirect {
        target_node: Option<NodeId>,
        target_tags: Vec<String>,
    },
    Scale {
        resource: String,
        direction: ScaleDirection,
        amount: u32,
    },
    Custom {
        action_type: String,
        params: HashMap<String, Value>,
    },
    Chain(Vec<Action>),
    Noop,
}
Expand description

Action types that can be executed when rules match

Variants§

§

Log

Log a message

Fields

§level: LogLevel

Severity level at which to log the message

§message: String

Text content of the log entry

§

Emit

Emit an event

Fields

§event_type: String

Identifier for the type of event being emitted

§payload: Value

Arbitrary JSON data attached to the event

§

SetContext

Set a context value

Fields

§key: String

Context key to set

§value: Value

JSON value to store under the key

§

IncrementCounter

Increment a counter

Fields

§name: String

Name of the counter to increment

§amount: i64

Amount by which to increment the counter

§

Alert

Send alert/notification

Fields

§severity: AlertSeverity

Severity level of the alert

§title: String

Short human-readable title for the alert

§message: String

Detailed description of the alert

§

Throttle

Throttle/rate limit

Fields

§key: String

Identifier key used to track the rate limit bucket

§max_per_second: f64

Maximum number of requests allowed per second

§

Reject

Reject request

Fields

§reason: String

Human-readable explanation for the rejection

§code: u32

Numeric error code returned with the rejection

§

Redirect

Redirect to another node

Fields

§target_node: Option<NodeId>

Specific node to redirect to, if known

§target_tags: Vec<String>

Tags used to select a target node when no specific node is given

§

Scale

Scale resources

Fields

§resource: String

Name of the resource to scale

§direction: ScaleDirection

Whether to scale up or down

§amount: u32

Magnitude of the scaling adjustment

§

Custom

Execute custom action

Fields

§action_type: String

Identifier for the custom action type

§params: HashMap<String, Value>

Key-value parameters passed to the custom action handler

§

Chain(Vec<Action>)

Chain multiple actions

§

Noop

No action (useful for monitoring rules)

Implementations§

Source§

impl Action

Source

pub fn log(level: LogLevel, message: impl Into<String>) -> Self

Create a log action

Source

pub fn emit(event_type: impl Into<String>, payload: Value) -> Self

Create an emit action

Source

pub fn set_context(key: impl Into<String>, value: Value) -> Self

Create a set context action

Source

pub fn alert( severity: AlertSeverity, title: impl Into<String>, message: impl Into<String>, ) -> Self

Create an alert action

Source

pub fn reject(reason: impl Into<String>, code: u32) -> Self

Create a reject action

Source

pub fn redirect_to_tags(tags: Vec<String>) -> Self

Create a redirect action

Source

pub fn chain(actions: Vec<Action>) -> Self

Create a chain of actions

Source

pub fn action_count(&self) -> usize

Count total actions (including nested)

Trait Implementations§

Source§

impl Clone for Action

Source§

fn clone(&self) -> Action

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Action

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Action

Source§

fn eq(&self, other: &Action) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Action

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more