Skip to main content

ServerlessRunner

Struct ServerlessRunner 

Source
pub struct ServerlessRunner {
    functions: Vec<LuaRuntime>,
    plugin_type: &'static str,
}
Expand description

Shared engine behind both serverless nodes: a compiled list of Lua functions run in order against the Context.

Each entry is a fully validated LuaRuntime (compiled at config load, so bad Lua fails policy compilation, not a live request). At request time the Context is threaded through every function: the table returned by one function’s execute becomes the input to the next. If any function errors, that error is propagated (routing the Context through the node’s error port); otherwise the final Context flows through the success port.

Fields§

§functions: Vec<LuaRuntime>§plugin_type: &'static str

Implementations§

Source§

impl ServerlessRunner

Source

pub fn from_config( config: &HashMap<String, Value>, plugin_type: &'static str, ) -> Result<Self, String>

Builds the runner from node config, compiling every function up front.

Accepted keys:

  • functions (array of strings, required, ≥1): each string is Lua source defining a global execute(ctx) function. Each is compiled and validated here; an empty array, a non-string entry, a Lua syntax error, or a missing execute all fail at config load.
  • phase (string, optional): accepted for APISIX compatibility but inert — placement in the graph determines phase.
  • timeout_ms (integer, default 5000): per-function execution timeout passed to the Lua runtime (stored, not yet enforced by the VM).
Source

pub fn run(&self, ctx: Context) -> Result<Context, PluginExecutionError>

Runs each function in order, threading the Context. Propagates the first error encountered.

Neither serverless-pre-function nor serverless-post-function declares a respond port (or any outcome port) — they use the default success/error pair. Each function therefore runs through LuaRuntime::execute_without_port, which rejects any second return value other than "success" (e.g. return ctx, "respond", or any other name) as LUA_BAD_PORT rather than silently dropping it: silently dropping it would let someone copy the script node’s respond idiom into a serverless function and get neither a response nor an error. The context reported on the error is the one that went into that function’s execute call (not the mutated table it returned), matching the script node’s rule that a function which did not finish making a decision keeps nothing it wrote.

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