Alternera.PluginHosts.Definition (alternera_plugin_hosts v0.9.0)

Copy Markdown View Source

A document of operations written in a step, not read from a host's files (a Camel step's routes "written here"), and how it reaches the host's members: by content, so the proxy keeps no member, restart or release in step with what it holds.

Its identity is its hash: the tenant, the text and the values it reads, so two tenants, two revisions and an unsaved draft are three documents, and a changed value is a new one. A call names the hash; a member that does not hold it answers unknown_definition, and the caller sends the document in a define frame (Host.define/3) to that member and calls again, once (PluginHosts.Pool, PluginHosts.HttpCall). A member that restarted, or a reload that removed what it held, learns it on the next call that needs it.

Only a kind that takes definitions (c:PluginHosts.Kind.definitions?/0) and a host whose entry has written_routes accept one (PluginHosts.written_routes?/3).

The values are the tenant variables the text references, each resolved (Plugin.Secret.values/4), secrets included: they travel beside the text, which is never substituted. The struct's Inspect leaves them out, and scrub/2 takes the secrets out of what the host says back. The hash is keyed with the installation's fingerprint key (Alternera.Plugin.Host.fingerprint_key/0), as a saved output's fingerprint is: it names a definition in calls, route ids and recorded headers, and a plain digest of a known text would let a short secret be guessed from it.

Summary

Functions

The define frame's payload.

The document text of tenant, reading values (a name, or secret.NAME, to its text), with its hash: 32 lower-case hex digits of the HMAC-SHA-256 of all three under the fingerprint key.

value (text, or a map or list of it at any depth) with the definition's secret values replaced by their references (Plugin.Secret.scrub/2); nil passes.

Whether a call's error says the member does not hold the definition it named.

Types

t()

@type t() :: %Alternera.PluginHosts.Definition{
  hash: String.t(),
  tenant: String.t(),
  text: String.t(),
  values: %{required(String.t()) => String.t()}
}

Functions

frame(definition)

@spec frame(t()) :: map()

The define frame's payload.

new(tenant, text, values \\ %{})

@spec new(String.t() | nil, String.t(), %{required(String.t()) => String.t()}) :: t()

The document text of tenant, reading values (a name, or secret.NAME, to its text), with its hash: 32 lower-case hex digits of the HMAC-SHA-256 of all three under the fingerprint key.

scrub(value, arg2)

@spec scrub(term(), t() | nil) :: term()

value (text, or a map or list of it at any depth) with the definition's secret values replaced by their references (Plugin.Secret.scrub/2); nil passes.

unknown?(arg1)

Whether a call's error says the member does not hold the definition it named.