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: StringThe 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: StringPolicy 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
impl CompiledGraph
Sourcepub async fn execute(&self, ctx: Context) -> Context
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.
Sourcepub async fn execute_traced(
&self,
ctx: Context,
recorder: TraceRecorder,
) -> (Context, TraceRecorder)
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.
Sourceasync fn run(
&self,
ctx: Context,
recorder: Option<TraceRecorder>,
) -> (Context, Option<TraceRecorder>)
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§
impl Freeze for CompiledGraph
impl !RefUnwindSafe for CompiledGraph
impl Send for CompiledGraph
impl Sync for CompiledGraph
impl Unpin for CompiledGraph
impl UnsafeUnpin for CompiledGraph
impl !UnwindSafe for CompiledGraph
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