Modules
The contract every plugin implements. A plugin is a capability a pipeline step can use; the step carries the plugin's id and its settings.
The SDK's own processes, started with the :alternera_plugin_sdk
application, so the proxy and a package's tests get them alike: the
collector of the steps' memory peaks
(Plugin.Provisional.HeapPeak.Collector).
A body a pipeline holds, as the codecs hand it to the steps: in memory
({:inline, binary}) or spooled to a file in the body storage directory
({:file, path, size}, Proxy.BodySpool).
A streaming step's filter: the module a call/3 plugin declared with
use Alternera.Plugin, streams: true names when its call/3 answers
{:stream, first, {module, state}, writes}.
What sees a response body as it leaves, read-only: the module a holding
step's leave/3 names in {:observe_body, {module, state}, summary} at
its Close (Plugin.CallAdapter).
The plugin model: one callback, call(inputs, opts, context), inputs in
and writes out, and leave/3 for a plugin whose step holds something for
the rest of the exchange; and what a host asks of a plugin. The host
runs a step through run/6, which calls head/5 or body/5, gives
back what a step held through release/4, and runs a streaming step
through stream_init/3, stream_chunk/2, stream_finish/1 and
stream_abort/2; their results are the runner's own vocabulary
({:cont, message, extras} for a head, {:ok, body, summary[, extras]}
for a body, a hold, {:skip_to_after, …}, {:answer_below_close, …}).
What a plugin needs to know about a step's failure before it raises one:
the rule for an error type and the cap on a failed call's response body.
The error itself, with the pipeline's own types and what the runner
records, is Pipelines.Runner.Error, which takes both from here.
The HTTP headers an editor suggests when nothing was recorded: the common request and response header names, each with a line saying what it is, and the values typically written into each.
What the plugin SDK asks of the application around it. Resolving a
template needs two things only the running pipelines know: the tenant's
variables and the methods the tenant's pipelines allow for a request.
Reading a body needs the application's in-memory limit, and work on a
body loaded whole a claim on the application's memory. A call out of the
proxy (Plugin.Provisional.Outbound) goes through the application's forward
side, and a saved output's fingerprint (Plugin.Provisional.SavedOutput) is
keyed with the application's secret. A rate (Plugin.Provisional.Rate)
is counted by the application's counter, and a stamped secret reference
is shown unstamped by the application's rule (Outbound.unstamp/1). A
response cache step's lookup, single flight and fill
(Plugin.Provisional.ResponseCache) are the application's response
cache. The credentials a request is
sent with (Plugin.Provisional.Credentials) and the signed-in caller an
upstream is told of (Plugin.Provisional.Identity) are the
application's. A step's settings checked against the
flow (Plugin.Provisional.Checks) are checked with the application's own
conditions and cache vocabulary. A file a user uploads into a step
(Plugin.Provisional.Files) is kept in the application's storage. A map is written as YAML
(write_yaml/1) by the application's writer. A resource record is read by
its lookup key (resource_get/3) and a resource's action is run
(resource_run/5), both optional callbacks, by the application's
resources. The SDK asks
through this behaviour, so it names no module of the application. The
application names the implementation under :host
An input of the call a pipeline runs in, as a step reads it: the rule for
its name and its value at a path. Plugin.Provisional.Inputs parses and
resolves the inputs a step passes.
What a call/3 step may read.
Splits a top-level JSON array that arrives in pieces into its elements'
text, so a step can work on a large array an element at a time: the Map
plugin's each over the root and a Script's each(record) stream through
it. Pieces may be cut anywhere, inside a string
or an escape included.
A JSON text read through its index (Plugin.JsonIndex) instead of
decoded whole: a body in memory, or a body spooled to a file
(Plugin.Body), which is then read by position and never loaded.
A sparse index of a JSON text: where its large values start and end, so
a reader can find a value without decoding the text
(Plugin.JsonDoc).
The JSON paths and literals the body plugins share (Plugins.Transform,
Plugins.Map, Plugin.Location).
The places of an exchange a pipeline step reads from (its source) and writes to (its target), shared by every plugin that has one, so each addresses, validates, describes, reads and writes them the same way.
What kind of body a Content-Type names: JSON (application/json,
text/json, any +json type), XML (application/xml, text/xml, any
+xml type) or neither.
Reads a migration guides file: the Markdown a plugin declares with
use Alternera.Plugin, migration_guides: "…", and the proxy's own
shipped guides, in one format.
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for Validate, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for the Response cache, and a change to it needs a
changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
The environment a plugin gives an OS process it starts.
Provisional: added for Authorize, and a change to it needs a changelog
line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for the WebAssembly module plugin, the first plugin that keeps a file a user uploads into a step, and kept here until a second plugin uses it.
Provisional: added for the runner and Script, and a change to it needs a
changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
The one process the node's metered steps report their garbage
collections to (Plugin.Provisional.HeapPeak). It owns one trace
session for as long as it lives and is that session's tracer: putting a
process under a meter turns the session's :garbage_collection trace on
for that process, and stopping the meter turns it off, each a few
microseconds. A session per meter cost about 15 ms a step to take down
(:trace.session_destroy/1, measured with 5,300 modules loaded).
Provisional: added for the Throttle and Circuit breaker steps, and a change
to it needs a changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: added for Assert caller, and a change to it needs a changelog
line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: moved here from the Call step for plugins that pass inputs on,
and a change to it needs a changelog line but no new major
(docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do with the
context's :provisional? key.
Provisional: added for Validate JSON and the proxy's json_schema test
assertions, so that every JSON Schema check reads a schema the same way,
reports a mismatch the same way and compiles a schema once. A change to it
needs a changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: added for plugins that run processes of their own, and a
change to it needs a changelog line but no new major
(docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do with the
context's :provisional? key.
Provisional: added for Rate limit, and a change to it needs a changelog line
but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for the Response cache step, and a change to it needs a
changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: moved here from the Request step for plugins that reach
outside the proxy, and a change to it needs a changelog line but no new
major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do with
the context's :provisional? key.
Provisional: added for the Script step, and a change to it needs a
changelog line but no new major (docs/USER_PLUGINS_DESIGN.md).
Provisional: added for consuming queues from a pipeline trigger, and a
change to it needs a changelog line but no new major
(docs/USER_PLUGINS_DESIGN.md).
The heap a step's process may reach while it holds a body. The runner limits
a plugin's body phase with it when the body is past the inline threshold, and
Plugins.Script.Sandbox limits every Script run, which is why a body-sized
limit has a floor: a small body still gets room for the script's own work.
Provisional: added for Script, and a change to it needs a changelog line but
no new major (docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do
with the context's :provisional? key.
Provisional: added for the Camel step's written routes, and a change to it
needs a changelog line but no new major (docs/USER_PLUGINS_DESIGN.md). The
namespace has nothing to do with the context's :provisional? key.
Provisional: added for plugins that run processes of their own, and a
change to it needs a changelog line but no new major
(docs/USER_PLUGINS_DESIGN.md). The namespace has nothing to do with the
context's :provisional? key.
Reads a recipes file: the Markdown a plugin declares with
use Alternera.Plugin, recipes: "…", and the proxy's own recipe
files, in one format.
Reads back a save error about one row of a list in a step's settings, for an editor that shows it at that row.
A tenant secret's value, for the step that must use it in-process: an
HMAC or JWT signing key, a password a native driver takes. Every other
step leaves {{secret.NAME}} as written and the proxy puts the value in
where the request leaves it (Plugin.Template).
What a step reads, writes and resolves, derived from its stored settings
by walking the plugin's settings_schema/0.
The values a step leaves in the exchange under its id, for later steps
of the same pipeline to read (spec 056 S2): a Request's body, status
and headers, a Script's returned body and its named outputs, a
Transform's or a Map's body, a Validate's valid and errors, a pivot's
returned status and headers.
A step's To list: which of the values its plugin registers
(Alternera.Plugin's outputs/0) go where.
Resolves a template a step's settings hold (a Respond body or header,
a Fail message) against the exchange view (Plugin.Location.view/0),
the way a Rewrite value is resolved (Plugin.Variables.resolve/2):
${var.<name>} from the view's variables (${var.<name>.<path>} a value inside one), ${error.<name>} from the
error a catch or On error handles, ${steps.<id>.<output>} from the
view's step outputs (Plugin.StepOutputs, with an optional key or
path after it), ${input.<name>} from the inputs of the call the
pipeline runs in (Pipelines.CallInputs), and the request's ${method},
${path}, ${client_ip}, ${request_id} and ${timestamp}, a value
of the pipeline's path template, ${path.<name>} (Pipelines.PathParams),
and
${allowed_methods} (Pipelines.AllowedMethods); and
the tenant's variables, {{NAME}} and {{secret.NAME}}, from the view's
tenant_vars (Pipelines.TenantVars), which the runner puts on the view
of a step that references one.
What a plugin's own tests build on, with no proxy around: a well-formed
context, a way to run a step's call/3 in a phase the way the runner
does (through Plugin.CallAdapter), and the checks
of the contract as plain predicates, so they work under any test
framework. Alternera.Plugin.Test.Contract turns the predicates
into ExUnit tests.
The contract of Alternera.Plugin as ExUnit tests, for a plugin's own
suite. plugin_contract/2 writes a describe block of tests over the
predicates of Alternera.Plugin.Test, so a plugin in another Mix
project is checked the way the proxy checks its built-in ones
A Alternera.Plugin.Host for a plugin's own project, where there is no
proxy to ask. It is the SDK's default, so a plugin's tests need no setup; the
proxy names its own host in its config, which replaces it.
A message source (Alternera.Plugin.Provisional.Source) over a queue
held in memory, for tests of the code that consumes a source, with no
broker around.
The test host's response-cache fill (Alternera.Plugin.Test.Host): a
Plugin.BodyObserver that gathers the body and keeps the response in the
calling process when it ends cleanly, and keeps nothing on an abort.
Raised when a step's {{NAME}} or {{secret.NAME}} reference has no
value (Pipelines.TenantVars.resolve!/3). The runner turns it into the
step's failure with error type unresolved_variable
(Pipelines.Runner, around every call/3), so a plugin that resolves deep
inside its own code (a header rewrite, a template) needs no error path
of its own. The message names the reference, never a value.
The value types a declared parameter or context entry can have: text,
number, boolean and json.
The template language of a step's settings: ${…} placeholders and
tenant variable references resolved against the data of an exchange, and
the request facts they read. What only the running pipelines know comes
through Plugin.Host.