Skip to main content
Version: 0.16.0

The interface library

A program outside the Core speaks one of three contracts, and each language offers a library per contract it covers, over a base the three share.

LibraryIts partyIts lifecycle
plugina Plugin unitlaunched by the Core, admitted, holds one Session per incarnation
interfacean interface client — a panel, a browser's back end, a remote toolattaches to a channel, is admitted by reaching it, and is arbitrated against other channels
administrativetooling, or a person's sessionreaches a socket, whose mode is the whole of its authority

A panel links the interface library and not the administrative one, so an interface acquires no administrative reach is a fact about what is in the binary.

What the base holds, and what it does not​

The base holdsIt does not hold
connecting, and the transport's own framinganything a subscription needs
the envelope, and correlationthe shape of an admission
a refusal — code, message, detail — in the language's error idioma channel's attachment, or its suspension
the addresses a party may computea capability, a stream's tolerances, a channel's grade
the contract version each library statesany operation of any contract

What the interface library does​

ItHow
computes an addressa managed interface is handed its channel's socket in YOKE_SOCKET; in an application instance a channel's socket derives from the instance's name under the account's runtime directory; in the service form, from the runtime directory. A channel name that could choose where the socket is is refused
attachesto a local socket by its path, or to host:port over TLS 1.3 against the roots the caller supplies. A Core speaking another version of the contract is refused before any operation
presents a credential firston a channel whose class takes one: an account and its secret, or a token an earlier authentication issued. The answer carries the session token, the caller's to keep
surfaces the openingwhat the channel may address and observe, the standing subscription, and the contract's version (attaching)
carries every operation as one callread, subscribe, confirm, command, ask, start and stop a stream, subscribe to a stream, reclaim — each answered on its own, all on the one connection (the operations)
reports a refusal by its codeexactly as the contract enumerates it; a channel's suspension carries the grade and the channel it is suspended in favour of

What it never does, in any language:

  • it never retries and never reconnects — an attachment that ended has ended;
  • it never confirms on the author's behalf — a confirmation states what the author has processed, and only the author knows that;
  • it never sends what the author did not ask for.

An author who has learnt the model in one language has learnt it in all of them; only the spelling changes. The lifecycle, the ways of failing, the refusals and the ordering a library delivers are the same in every one; the shape of the API is the language's own.

In C++​

yoke-sdk-cpp is released as its source. An archive of the tagged tree, which cmake --install turns into the library, its headers, a CMake package and a pkg-config file; no package manager is involved.

find_package(yoke-sdk-cpp 0.7 REQUIRED)
target_link_libraries(panel PRIVATE yoke::yoke-cpp)
#include <yoke/interface.hpp>

namespace yi = yoke::iface;

auto attachment = yi::Attachment::attach(yi::managed(getenv));
for (const auto &record : attachment->picture().records()) { /* compose */ }
std::string answer = attachment->ask("pipeline", "spectrum.identify", spectrum);
the headeryoke/interface.hpp, namespace yoke::iface; the contract's generated messages are installed beside it, as yoke::interface::v1
a refusalyoke::Refusal, with its code and detail; yoke::iface::Suspended for a suspended channel
the endyoke::iface::Ended, from any call once the attachment has ended
threadsone of the library's own per attachment, reading what the Core sends, and one more at a routable address carrying the TLS; every member may be called from any thread
what it builds againstprotobuf, gRPC for C++, and OpenSSL 3

The reference panel is written this way: a Qt client of the local projection, linking the published library like anyone's, and composing its window from the opening picture alone.

In Rust​

yoke-sdk is one crate on crates.io, carrying the base and both libraries as modules: the interface library is yoke_sdk::interface.

yoke-sdk = "0.5"
use yoke_sdk::interface::{self, Attachment, Options};

let address = interface::managed(|name| std::env::var(name).ok())?;
let attachment = Attachment::attach(&address.to_string_lossy(), Options::new()).await?;
for record in &attachment.picture.records { /* compose */ }
let answer = attachment.ask("pipeline", "spectrum.identify", &spectrum).await?;
the moduleyoke_sdk::interface; the contract's generated messages are yoke_sdk::base::yoke_proto::interface::v1
a refusalyoke_sdk::base::Error::Refusal, carrying its code, its message and what it names: a subject, an item or a suspension
the endinterface::is_ended(&error), true of any call once the attachment has ended
concurrencyasync on Tokio; one task of the library's own reads what the Core sends, and every method takes &self
TLS 1.3rustls, built with no code for an earlier version, so a channel at a routable address cannot be reached below 1.3
what it builds againstno system library: the crate and what Cargo resolves for it

In Python​

yoke-sdk is one wheel on PyPI, carrying the base and both libraries: the interface library is yoke_sdk.interface.

pip install "yoke-sdk>=0.5"
import os
from yoke_sdk import interface

address = interface.managed(os.environ.get)
attachment = await interface.Attachment.attach(address)
for record in attachment.picture.records: ... # compose
answer = await attachment.ask("pipeline", "spectrum.identify", spectrum)
the moduleyoke_sdk.interface; the contract's generated messages are in yoke.interface.v1
a refusalyoke_sdk.base.Refusal, with its code, its message and what it names: a subject, an item or a suspension
the endyoke_sdk.interface.Ended, from any call once the attachment has ended
concurrencyasyncio; every method is a coroutine
TLS 1.3the standard library's ssl, with 1.3 as its floor and its ceiling, because the gRPC the wheel builds on cannot be held to one version: a pump carries the plaintext to a local socket gRPC speaks on
what it builds againstgrpcio and protobuf, from the wheel's own requirements

In C​

yoke-sdk-c is released as its source, like the C++ family: an archive of the tagged tree, which cmake --install turns into the library, its headers, a CMake package and a pkg-config file. Unlike the plugin library's, the interface contract's generated headers are installed beside it, because its functions surface the contract's messages.

find_package(yoke-sdk-c 0.6 REQUIRED)
target_link_libraries(panel PRIVATE yoke::yoke-c)
#include <yoke/interface.h>

char *address = NULL;
yoke_interface_managed(&address, getenv_of_the_process, NULL, &err);
yoke_attachment *a = yoke_attach(address, NULL, &err);
const Yoke__Interface__V1__Snapshot *picture = yoke_picture(a); /* compose */
Yoke__Interface__V1__Response *answer = NULL;
yoke_ask(a, "pipeline", "spectrum.identify", spectrum, len, &answer, &err);
the headeryoke/interface.h; the contract's messages are protobuf-c's, Yoke__Interface__V1__…
a refusala yoke_error with its code, its message and what it names: a subject, an item or a suspension; the function returns -1
the endany call answers an error whose message says the attachment ended; a wait returns YOKE_WAIT_FAILED
threadsone of the library's own per attachment, reading what the Core sends, and one more at a routable address carrying the TLS; every function may be called from any thread
what it builds againstgRPC's core C API, protobuf-c and OpenSSL 3