A need's channel
For each need of class unit, the Core binds a channel for the Plugin unit that declared it: a local
socket on which that unit is the one client of the unit its need is bound to. It speaks the interface
contract, the same one every other channel speaks, so the using unit needs no library but its family's
interface library, and the unit used answers it as it answers any client.
What it is
| Property | Value |
|---|---|
| contract | the interface contract, the typed local projection |
| path | needs/<unit>/<need>.sock, under the instance's runtime directory |
| mode | 0600, the directory needs/<unit>/ 0700, both the account running the Core's |
| bound by | the Core, when the using unit is launched and before the process starts |
| removed | when that incarnation ends, by every route an incarnation ends on |
| clients | one: the using unit. A second attachment is refused channel.in_use |
| control | always held by its one client: nothing prevails over it and it never yields |
| declared in a description | never: the composing document binds the need to a unit, and the channel follows |
${bind.<need>} resolves to the path. For a containerised unit the socket is mounted at the same
absolute path on both sides, as the Core's own socket is. The using unit learns the path and nothing
else: not the name of the unit behind it, which it reads from the channel's opening.
One channel per need, per incarnation. A unit with two unit needs has two channels; four copies of one
Plugin have four channels for one need, each under its own unit's directory.
What it sees, and what it may address
Its subjects are the unit bound and nothing else. The opening, a read and a subscribe hold that one
unit and the channel itself; every other unit, the instance and the other channels are subject.unknown.
| Operation | On a need's channel |
|---|---|
read, subscribe, confirm | over the bound unit's subjects |
query | a type listed in the need's questions in the using Plugin's Manifest, and granted |
stream.start, stream.stop, stream.subscribe, stream.unsubscribe | a stream listed in the need's streams, and granted |
command | refused, use.command: a unit never instructs another |
authenticate, reclaim | refused operation.unknown: a local socket needs no credential, and a channel nothing prevails over has nothing to reclaim |
Three checks are made, in this order, after those every channel makes (the operations):
| Checked | Refusal |
|---|---|
| the subject is the bound unit | subject.unknown |
the operation is not command, and the object is listed in the need's uses | use.command, use.undeclared |
| the object is declared by the bound unit, and the use is granted to the using Plugin | scope.undeclared, scope.withheld |
A use refused at the last two is reported with the event unit.use.refused on the using unit, carrying
the need, the object and the code.
A question asked on it
A question on a need's channel may name a cause: the identifier of a question the using unit was
delivered and has not answered yet.
cause | chain | deadline |
|---|---|---|
| absent | a new one | now + 30 s |
| names an outstanding question of this unit | that question's | that question's deadline − 500 ms |
| names anything else | refused, use.cause.unknown | — |
| leaves less than 100 ms | refused, deadline.exhausted, the bound unit never asked | — |
The Core waits for the answer until the deadline, and answers the asker unit.unanswered past it, as for
any question. A question from a declared channel never carries a cause: only a unit answers a question,
so only a unit's question can have been caused by one. Each question with a cause is reported with the
event unit.question.chained on the unit asked, carrying the chain, the asker and the type — never the
payload, never the answer.
A chain may be as long as the application makes it; the gate refuses an application whose uses close a cycle, at any length.
A stream it holds
A stream is held while a need's channel has a delivery of it open: started by that channel or found flowing, and subscribed by it.
| A stop arriving from | While the stream is held |
|---|---|
| a declared channel | refused, stream.held, the detail naming the holding unit |
| the holding need's channel itself | stops it, unless another need's channel also holds it, which refuses stream.held |
| the administrative surface | stops it, and every delivery is told unit.stream.stopped with the reason operator |
A stream started by a need's channel and no longer held by any keeps flowing, as a stream started by a client that detached does: holding prevents a stop and starts nothing.
When the unit bound restarts
The using unit's delivery ends and nothing else does. Its channel stays bound, its outstanding questions
and open deliveries end with unit.no_session, and the using unit is not restarted. Its library attaches
again and resubscribes, as any interface client returns; a stream it held is started again where the new
incarnation is not already emitting it.
What is kept
| Kept | Never kept |
|---|---|
unit.use.refused: the need, the object, the code | a question's payload, an answer, a frame |
unit.question.chained: the chain, the asker, the type | what a token or a reading held |
channel.attached and its ending, as for any channel |
An answer and a frame are delivered and written nowhere — not in the log store, not in an event, not in the Core's captured output.