# alternera_plugin_command

The Command pipeline plugin (`Alternera.Plugins.Command`): a step that
calls an operation of a command plugin host, a program in any language that
speaks the plugin hosts' protocol. It is built on the plugin hosts'
runtime, `alternera_plugin_hosts`, and is experimental: installed only
while `:alternera, :experimental_plugins` is true.

Whoever runs the proxy configures the hosts, under the package's own
application, with the program as given; each belongs to one tenant, named
by its slug:

    config :alternera_plugin_command,
      hosts: [
        %{name: "pricing", executable: "/opt/pricing/bin/host", protocol: :msgpack, tenant: "acme",
          pool: %{min: 0, max: 8, idle_minutes: 30}}
      ]

Each host is a pool of copies of the program (defaults `min: 1, max: 4,
idle_minutes: 10`): `min` run always, more start up to `max` while every
one is busy, and one beyond `min` stops after `idle_minutes` without a
call. At `min: 0` nothing runs until a call, or the step editor, needs a
copy. A call goes to any copy, so the program keeps no state between
calls that another copy would need.

An entry's `variables` (`["PRICING_URL", "secret.PRICING_KEY"]`) sends the
values of those tenant variables to each copy in a `variables` frame
before its hello, never in its environment: a wrapper around a program
configured by its environment reads the frame and sets its child's
environment itself.

The package's application starts a `PluginHosts.Supervisor` for the
Command kind. The step editor is `Plugins.Command.Editor`. `test/` here
checks the contract with the SDK's kit; the proxy's
`command_run_test.exs` runs a step against a real command host. The
internals section is `docs/internals.adoc`.

## Licence

Licensed under the Apache License, Version 2.0 (`LICENSE`, `NOTICE`).
Alternera itself, the proxy this package plugs into, is under the Elastic
License 2.0.
