Skip to main content

CompiledGraph

Struct CompiledGraph 

Source
pub struct CompiledGraph {
    nodes: HashMap<String, Box<dyn Plugin>>,
    success_edges: HashMap<String, String>,
    error_edges: HashMap<String, String>,
    entry_node_id: String,
    terminal_node_ids: HashSet<String>,
    catch_all_handler: Option<String>,
    policy_name: String,
    resources: Arc<PluginResources>,
}
Expand description

A compiled, ready-to-execute graph with instantiated plugins.

Built by compile_policy and shared read-only by the data-plane; one instance serves all requests matching the route that references its policy.

Fields§

§nodes: HashMap<String, Box<dyn Plugin>>§success_edges: HashMap<String, String>

node_id -> next node_id on success

§error_edges: HashMap<String, String>

node_id -> next node_id on error

§entry_node_id: String

The node that starts the pipeline (first node after listener)

§terminal_node_ids: HashSet<String>

Node IDs that are terminal (client nodes) — execution stops when we reach one

§catch_all_handler: Option<String>

Policy-level catch-all error handler node ID

§policy_name: String

Policy name, used as a metrics label.

§resources: Arc<PluginResources>

Process-wide services (metrics registry, shared clients); per-node metrics recording is disabled when resources.metrics is None.

Implementations§

Source§

impl CompiledGraph

Source

pub async fn execute(&self, ctx: Context) -> Context

Executes the graph with the given initial context and returns the final context (with response populated).

Walks nodes starting at the entry node (the first node after the listener), following the success edge after each Ok result. On a plugin error the error is tagged with the failing node’s ID, pushed onto ctx.errors, and execution jumps to the node’s error edge if one exists, otherwise to the policy-level catch-all handler; with neither, execution stops and a generic JSON 500 response is written. Reaching a terminal client node (or a node with no success edge) ends the walk. This method never fails: every outcome is expressed through the returned context’s response.

Source

pub async fn execute_traced( &self, ctx: Context, recorder: TraceRecorder, ) -> (Context, TraceRecorder)

Same walk as execute, additionally recording a [Trace] of every node: the context after each one, the outcome, and which edge the engine followed.

Used by debug mode and the sandbox. Deliberately the same loop rather than a parallel implementation — a trace that could drift from the real execution path would be worse than no trace at all.

Source

async fn run( &self, ctx: Context, recorder: Option<TraceRecorder>, ) -> (Context, Option<TraceRecorder>)

The single graph walk, optionally recording each step.

When recorder is None the only added cost is one Option discriminant check per node — the same shape as the existing metrics branch, and perfectly branch-predicted.

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> MaybeSend for T