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.
| Library | Its party | Its lifecycle |
|---|---|---|
| plugin | a Plugin unit | launched by the Core, admitted, holds one Session per incarnation |
| interface | an interface client — a panel, a browser's back end, a remote tool | attaches to a channel, is admitted by reaching it, and is arbitrated against other channels |
| administrative | tooling, or a person's session | reaches 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 holds | It does not hold |
|---|---|
| connecting, and the transport's own framing | anything a subscription needs |
| the envelope, and correlation | the shape of an admission |
| a refusal — code, message, detail — in the language's error idiom | a channel's attachment, or its suspension |
| the addresses a party may compute | a capability, a stream's tolerances, a channel's grade |
| the contract version each library states | any operation of any contract |
What the interface library does
| It | How |
|---|---|
| computes an address | a 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 |
| attaches | to 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 first | on 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 opening | what the channel may address and observe, the standing subscription, and the contract's version (attaching) |
| carries every operation as one call | read, 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 code | exactly 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.5 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 header | yoke/interface.hpp, namespace yoke::iface; the contract's generated messages are installed beside it, as yoke::interface::v1 |
| a refusal | yoke::Refusal, with its code and detail; yoke::iface::Suspended for a suspended channel |
| the end | yoke::iface::Ended, from any call once the attachment has ended |
| threads | one 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 against | protobuf, 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.