pub struct ScriptPlugin {
runtime: ScriptRuntime,
}Expand description
Executes a scripted plugin as a graph node.
The script receives the full Context (request, response, message) and
returns a possibly modified copy; anything it writes into ctx.message
is visible to downstream nodes. Currently only the Lua (Luau) runtime is
supported.
Fields§
§runtime: ScriptRuntimeImplementations§
Source§impl ScriptPlugin
impl ScriptPlugin
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, loading and validating the script immediately so bad scripts fail at policy-compile time.
Accepted keys:
runtime(string, default"lua"): scripting runtime; any other value is an error.source(string): path to a script file, read at compile time.inline(string): script text embedded in the config. One ofsourceorinlineis required (sourcewins if both are set); omitting both is an error, as is an unreadablesourcefile.timeout_ms(integer, default5000): script execution timeout; currently stored by the Lua runtime but not yet enforced.modules_path(string, default: thesourcescript’s parent directory; none forinline): directory the sandboxedrequireresolves modules from.
type: script
config:
runtime: lua
source: scripts/enrich.lua
timeout_ms: 2000The script must define a global execute(ctx) function that returns
the (possibly modified) context table:
function execute(ctx)
ctx.request.headers["x-enriched"] = {"true"}
ctx.message.user_tier = "gold"
return ctx
endTrait Implementations§
Source§impl Plugin for ScriptPlugin
impl Plugin for ScriptPlugin
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 ScriptPlugin
impl RefUnwindSafe for ScriptPlugin
impl Send for ScriptPlugin
impl Sync for ScriptPlugin
impl Unpin for ScriptPlugin
impl UnsafeUnpin for ScriptPlugin
impl UnwindSafe for ScriptPlugin
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