Starting it
A Plugin starts as a Plugin project, which the composer makes from a template its family publishes.
The project is a directory with one file at its root, yoke-plugin.yaml, which names the Plugin and
says how it is built, and two directories beside it: plugin/, the Plugin's source in the language's
own kind, and try/, a small application that runs it. The family's library is an ordinary dependency
of the source, obtained the way the language obtains any other.
Choose its identity
A Plugin is known by a namespaced identity, such as com.example.greeter, written as a reversed
domain you control followed by the Plugin's own name. The Manifest, the operator's grants and every
application that runs the Plugin name it by that identity, so it is chosen once and kept across
versions: a different identity is a different Plugin, and nothing granted to the old one reaches it
(the Manifest).
Make the project
- Go
- Rust
- Python
- C
- C++
yoke-compose new plugin com.example.greeter --language go
yoke-compose new plugin com.example.greeter --language rust
Python has no template in this release. A Python Plugin will be handed on as an image, and its template comes with that; until then a Python Plugin is started by hand, as the end of this page shows, and every later page keeps a Python tab for it.
yoke-compose new plugin com.example.greeter --language c
yoke-compose new plugin com.example.greeter --language cpp
The composer obtains the family's template for its own release, checks it against the digest the
release records, and writes it into greeter/, the last part of the identity, with the identity and
the program's name filled in. It then makes try/ an application project for this machine and takes
the Plugin into it, which builds it once: before running the build the template states, it shows the
command, and it runs it because you asked for the project. In Go:
…
Taking com.example.greeter runs its author's build.
source: ..
commit: none: the source is not a git tree
in: plugin/
command: CGO_ENABLED=0 GOOS=linux GOARCH="$YOKE_GOARCH" GOFLAGS=-mod=mod go build -trimpath -o "$YOKE_OUT/greeter" .
Run it? yes (--yes)
greeter made: a Plugin project of com.example.greeter in go, and try/ an application taking it
| Option | Is |
|---|---|
--dir <d> | where to make it, instead of greeter/; it must not exist |
--program <p> | the program's name, instead of the identity's last part |
What it made
greeter/
├── yoke-plugin.yaml what the Plugin is, and how it is built
├── README.md
├── plugin/ the Plugin's source, and its Manifest kept beside it
│ └── com.example.greeter.yaml
├── try/ an application that runs the Plugin
│ ├── yoke.yaml
│ ├── manifests/
│ ├── components/
│ └── plugins.yaml
└── .github/workflows/manifest.yml
yoke-plugin.yaml is read by every step after this one, and only what it names is the Plugin. In Go:
plugin: 1
id: com.example.greeter
language: go
program: greeter
manifest: plugin/com.example.greeter.yaml
build:
in: plugin/
run: CGO_ENABLED=0 GOOS=linux GOARCH="$YOKE_GOARCH" GOFLAGS=-mod=mod go build -trimpath -o "$YOKE_OUT/greeter" .
architectures: [x86_64, aarch64]
| Field | Is |
|---|---|
id | the Plugin's identity, kept across versions |
language | its family |
program | the name of the executable the build writes |
manifest | where the Manifest is kept, in the source |
build.in, build.run | where the build runs, and the command, in the language's own idiom; it writes the program into $YOKE_OUT |
architectures | what its author builds it for |
It names no version. A Plugin's version is the tag its source is published at (handing it on).
The family's library is already a dependency of plugin/, at the release that goes with your
composer:
- Go
- Rust
- Python
- C
- C++
plugin/go.mod requires github.com/yoke-project/yoke-sdk-go, and plugin/main.go imports its
plugin package. Go fetches it at the first build.
plugin/Cargo.toml depends on the crate yoke-sdk at one version, with Tokio beside it, and
plugin/src/main.rs uses its plugin module. Cargo fetches them at the first build.
By hand: the package yoke-sdk, installed in an environment of the Plugin's own, as the end of this page shows.
plugin/CMakeLists.txt finds the library installed, at its release's version, or fetches it at that
release's tag and builds the part the Plugin needs. Either way the libraries it links against —
gRPC's C API, protobuf-c, OpenSSL and json-c — come from the host's development packages
(what you need). plugin/main.c includes yoke/plugin.h.
plugin/CMakeLists.txt finds the library installed, at its release's version, or fetches it at that
release's tag and builds the part the Plugin needs. Either way the libraries it links against —
gRPC's C++ API, protobuf and OpenSSL — come from the host's development packages
(what you need). plugin/main.cpp includes yoke/plugin.hpp.
plugin/ holds a program that starts, says it is ready, and waits: a Plugin that declares nothing.
The next page replaces it with the greeter.
Which template
The template is the one published with the composer's own release, so a composer and the library it starts a Plugin with were released together. A composer you built from source is no release, and says so: name the release whose templates to use, or an archive you obtained yourself, which the composer reads without the network and whose digest it prints for you to check.
yoke-compose new plugin com.example.greeter --language go --release 0.14.1
A template's archive is published with its family's library, as
yoke-plugin-template-<family>-<version>.tar.gz among the files of a release of
github.com/yoke-project/yoke-sdk-<family>. The form above prints the address it obtained, which is
the one to take for the same template; for Go at 0.14.1 it is the library's 0.8.1:
curl --proto '=https' --tlsv1.2 -sSfLO https://github.com/yoke-project/yoke-sdk-go/releases/download/v0.8.1/yoke-plugin-template-go-0.8.1.tar.gz
yoke-compose new plugin com.example.greeter --language go --template yoke-plugin-template-go-0.8.1.tar.gz
A Plugin to compare with: the repository github.com/yoke-project/yoke-reference holds a clock
written as a Plugin in Go, in Rust and in Python, each built against its published library alone.
The same, by hand
Without the composer, a Plugin is a directory of the language's own kind — a Go module, a Cargo package, a Python program with its environment, a CMake project — with the family's library as a dependency. The later pages keep these paths too, at their end.
- Go
- Rust
- Python
- C
- C++
The Go family's library is the module github.com/yoke-project/yoke-sdk-go, and a Plugin imports its
plugin package.
mkdir greeter && cd greeter
go mod init example.com/greeter
go get github.com/yoke-project/yoke-sdk-go@latest
greeter/
├── go.mod
├── go.sum
└── main.go written on the next page
The Rust family's library is the crate yoke-sdk, and a Plugin uses its plugin module. It is
asynchronous, on Tokio.
cargo new greeter && cd greeter
cargo add yoke-sdk
cargo add tokio --features rt-multi-thread,macros,signal
[package]
name = "greeter"
version = "0.1.0"
edition = "2024"
[dependencies]
tokio = { version = "1", features = ["rt-multi-thread", "macros", "signal"] }
yoke-sdk = "0.7.1"
greeter/
├── Cargo.toml
├── Cargo.lock
└── src/
└── main.rs written on the next page
The Python family's library is the package yoke-sdk, and a Plugin imports its plugin module. It
is asynchronous, on asyncio. Install it in an environment that belongs to the Plugin, not to the
system:
mkdir greeter && cd greeter
python3 -m venv .venv
.venv/bin/pip install yoke-sdk
greeter/
├── .venv/ the Plugin's environment, holding yoke-sdk and what it requires
└── greeter.py written on the next page
The C family's library is released as its source: an archive that CMake builds and installs, with a
package find_package resolves and a file for pkg-config. Install it once, here under ~/.local,
without the harnesses that only its own tests need:
curl -fsSLO https://github.com/yoke-project/yoke-sdk-c/releases/download/v0.7.2/yoke-sdk-c-0.7.2-source.tar.gz
tar -xzf yoke-sdk-c-0.7.2-source.tar.gz
cmake -S yoke-sdk-c-0.7.2 -B yoke-sdk-c-build -DCMAKE_BUILD_TYPE=Release -DYOKE_SDK_C_TESTING=OFF
cmake --build yoke-sdk-c-build -j
cmake --install yoke-sdk-c-build --prefix ~/.local
Then the Plugin is a CMake project that finds it; a Plugin includes yoke/plugin.h:
mkdir greeter && cd greeter
cmake_minimum_required(VERSION 3.25)
project(greeter LANGUAGES C)
find_package(yoke-sdk-c 0.7.2 REQUIRED)
add_executable(greeter greeter.c)
target_link_libraries(greeter PRIVATE yoke::yoke-c)
greeter/
├── CMakeLists.txt
└── greeter.c written on the next page
The C++ family's library is released as its source: an archive that CMake builds and installs, with
a package find_package resolves and a file for pkg-config. Install it once, here under ~/.local,
without the harnesses that only its own tests need:
curl -fsSLO https://github.com/yoke-project/yoke-sdk-cpp/releases/download/v0.8.1/yoke-sdk-cpp-0.8.1-source.tar.gz
tar -xzf yoke-sdk-cpp-0.8.1-source.tar.gz
cmake -S yoke-sdk-cpp-0.8.1 -B yoke-sdk-cpp-build -DCMAKE_BUILD_TYPE=Release -DYOKE_SDK_CPP_TESTING=OFF
cmake --build yoke-sdk-cpp-build -j
cmake --install yoke-sdk-cpp-build --prefix ~/.local
Then the Plugin is a CMake project that finds it; a Plugin includes yoke/plugin.hpp:
mkdir greeter && cd greeter
cmake_minimum_required(VERSION 3.25)
project(greeter LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
find_package(yoke-sdk-cpp 0.8.1 REQUIRED)
add_executable(greeter greeter.cpp)
target_link_libraries(greeter PRIVATE yoke::yoke-cpp)
greeter/
├── CMakeLists.txt
└── greeter.cpp written on the next page
The versions shown are the families' newest at the time of writing. Each family is released on its own, and a newer one speaks the same contract (what each family offers).