Skip to main content

Module serverless_pre_function

Module serverless_pre_function 

Source
Expand description

The serverless-pre-function node — runs one or more inline Lua functions against the Context, threading it through each in sequence.

Port of APISIX’s serverless-pre-function plugin. In APISIX the two serverless plugins (serverless-pre-function / serverless-post-function) are identical except for the phase they run in; here they share all logic (ServerlessRunner) and differ only in their registered node-type name.

§Deviations from APISIX

  • Function contract. APISIX functions are return function(conf, ctx) ... end chunks invoked with (conf, ctx). featherbit reuses the script plugin’s Lua runtime, so each function is a script that defines a global function execute(ctx) ... return ctx end, receiving and returning the marshalled Context table (see the script plugin docs for the table shape). This is the same contract as the script node.
  • Phase by graph position. APISIX’s phase field selects a request lifecycle phase. featherbit expresses phase through placement in the policy graph: a serverless-pre-function node is wired before the upstream node, a serverless-post-function node after it. The phase config key is accepted for compatibility but is inert.

Structs§

ServerlessPreFunctionPlugin
The serverless-pre-function node. Runs its Lua functions before the upstream call (by convention of its graph placement).
ServerlessRunner
Shared engine behind both serverless nodes: a compiled list of Lua functions run in order against the Context.