Skip to main content

CompiledGraph

Struct CompiledGraph 

Source
pub struct CompiledGraph {
    nodes: HashMap<String, Box<dyn Plugin>>,
    edges: HashMap<String, HashMap<String, String>>,
    entry_node_id: String,
    terminal_node_ids: HashSet<String>,
    catch_all_handler: Option<String>,
    policy_name: String,
    resources: Arc<PluginResources>,
    stream_capable: HashSet<String>,
    buffering_reasons: Vec<BufferingReason>,
    cache_pair_warnings: Vec<CachePairWarning>,
    cache_targets: Vec<CacheTarget>,
}
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>>§edges: HashMap<String, HashMap<String, String>>

node_id -> (port -> target node_id). Ports normalized (out -> success).

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

§stream_capable: HashSet<String>

Ids of upstream nodes whose success path reaches client without passing any node that reads the response body. Read by is_stream_capable, consulted per node in run.

§buffering_reasons: Vec<BufferingReason>

Why each non-capable upstream must buffer, for operator-visible reporting.

§cache_pair_warnings: Vec<CachePairWarning>§cache_targets: Vec<CacheTarget>

Every proxy-cache half’s backend, for invalidation by pair id.

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.

Source

pub fn is_stream_capable(&self, node_id: &str) -> bool

Whether the upstream node named node_id may stream its response body straight through to the client — nothing between it and client on the success path reads the buffered response body. Consulted by run to set the __may_stream reserved key before invoking the node.

Source

pub fn cache_pair_warnings(&self) -> &[CachePairWarning]

Why each non-stream-capable upstream node must buffer, one entry per blocked upstream, for operator-visible reporting. proxy-cache halves with no counterpart. Informational, like CompiledGraph::buffering_reasons.

Source

pub fn cache_targets(&self) -> &[CacheTarget]

Every proxy-cache half’s backend, for invalidation by pair id.

Source

pub fn buffering_reasons(&self) -> &[BufferingReason]

Trait Implementations§

Source§

impl Debug for CompiledGraph

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> MaybeSend for T

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