Skip to main content
Version: 0.12.0

A Plugin

A Plugin is a program the Core launches, admits and holds a Session with. It does the work of a domain: it reads an instrument, drives a motor, transforms data, answers a question. Yoke gives it a process supervised and restarted on a policy, a socket of its own, a way to be asked and to report, and a log. The Core never reads what a Plugin's messages mean: a payload is bytes to it.

Before it is a process, a Plugin is a file and a declaration. The file is its executable, or an image when it runs in a container. The declaration is its Manifest. Together they are what a Plugin author ships, and what an application or a device carries.

What it is made of​

PartWhat it is
an identitya namespaced name, such as com.example.greeter: who the program is. The Manifest, the operator's policy and every application name it by it
the Manifestmanifest.yaml: what the Plugin declares about itself before it runs — the commands it accepts, the questions it answers, the streams it publishes, the occurrences it reports, a capability governing each, and the classes of thing it needs to reach, such as a device or a directory (the Manifest)
the executablethe program itself, written with the library of its language; or an image, for a Plugin that runs in a container (containerised units)

A declaration grants nothing. The Manifest says what the Plugin may ask for. What it is allowed to do is what it declared and what the operator authorised, computed when it is admitted. A Plugin that declares a question nobody granted is admitted, and the question is withheld (admission, capabilities).

A plugin is authorised once, and every copy of it is covered. One application may run the same Plugin several times, as several units — camera-1 and camera-2 from one camera Plugin. The plugin is what the operator authorises; a unit is what the Core launches, addresses and supervises (vocabulary).

The declaration, in five languages​

Every library generates the Manifest from the declaration the program itself starts with, so the two cannot disagree: the program prints it when asked, and that output is the file shipped beside it. Here is the same Plugin, one question governed by one capability, in each family's library.

main.go
import "github.com/yoke-project/yoke-sdk-go/plugin"

func declaration() plugin.Declaration {
return plugin.Declaration{
ID: "com.example.greeter",
Queries: []string{"greeter.hello"},
Capabilities: []plugin.Capability{
{Name: "query.hello.answer", Governs: plugin.Object{Query: "greeter.hello"}},
},
}
}

Each of the five generates this Manifest, spelled with more or less indentation and quoting:

manifest.yaml
manifest: 1
id: com.example.greeter
protocol: 1
queries:
- id: greeter.hello
capabilities:
- name: query.hello.answer
governs:
query: greeter.hello
FamilyThe libraryA Plugin imports
Gothe module github.com/yoke-project/yoke-sdk-goplugin
Rustthe crate yoke-sdkyoke_sdk::plugin
Pythonthe package yoke-sdkyoke_sdk.plugin
Cyoke-sdk-c, released as its sourceyoke/plugin.h
C++yoke-sdk-cpp, released as its sourceyoke/plugin.hpp

The model is the same in each, and the spelling follows the language: a declaration, a start that registers, events to answer, an orderly close. Every library is held to the same conformance suite (what each family offers).

Its life​

  • The Core launches it. A Plugin started by hand has no token and is not admitted, unless a run asks for it explicitly, as a debugger needs (running it).
  • It is admitted, not merely launched. Admission checks the token, that the program describes itself as its Manifest does, that the plugin is enabled, and what it was granted (admission).
  • The Session is its one conversation with the Core, and everything it does travels on it or on a stream the Core activated (the Session, the families).
  • A Plugin that falls is restarted according to its policy, and each life of its process is a new incarnation, numbered and kept in the log. The policy is the application's, not the Plugin's.

The library does the order for you. Reading the environment, binding before registering, the heartbeat, the end of the Session: every family discharges them in the order the contract requires, so a Plugin author writes the declaration and what to do with each event.

Where a Plugin goes​

A Plugin is delivered in whichever form the application that uses it is delivered, and the files are the same two in both: the executable and the Manifest.

The executableThe Manifest
in an application's packagecomponents/ of the bundle, pinned by its digest in yoke.yamlmanifests/ of the bundle
in the service form/usr/lib/yoke/plugins/<plugin>, found from the identity/etc/yoke/plugins.d/<plugin>/manifest.yaml

The Manifest is the same file in both. Only who puts it there differs: the package's payload in the one, the distribution's package or the image in the other (an application as a service).

A Plugin is not an application​

A PluginAn application
what it isa programa description of what runs together
written inone of five languages, with its libraryYAML, with yoke-compose
identified byits plugin identity, com.example.greeterits application identity and version, com.example.hello 0.1.0
declareswhat it may do: commands, questions, streams, occurrences, needswhat runs: units, channels, parameters, an order of start
built intoan executable and a Manifesta package, <id>-<version>.yoke, or a composition in the service form
runsas one or more units, inside an instanceas an instance, which the Core runs
authorisedonce, by the operator, for every copynever: an application is checked, and its Plugins are authorised
used byany number of applications, by any authorthe hosts that install it

A Plugin is tried inside the smallest application there is: a project with one unit, run from the working directory with yoke app run --from, and nothing installed (trying it). That application exists to run the Plugin, and is a second thing beside it.