Nerve and siphon¶
What a kick does travels on the nerve, and each channel draws what reaches it through its siphon. Feelers explains how a channel draws a run.
octomate.nerve ¶
The nerve: what a thread does, as it happens, for whoever is watching.
In-process publish and subscribe, keyed by channel, thread or user topics, carrying wire events: the run's stream as a wire consumer sees it, and what the graph says around a run — its start and end, a move, a failure, the reflex waking and falling asleep, an authorization. Every way in and out is a stream end the nerve hands over. A kick publishes on the send end of a stream opened on the thread it was asked on, as impulses: an event and the address it happens at. The nerve pumps the other end, delivering each impulse to the channel it happens on and to the subscribers of its thread and of the asking thread, so a console follows the kick wherever a move carries it. A channel holds one subscription for all its threads and draws every run on them; it misses nothing and holds nobody up, since what it has yet to read is kept for it. A thread's subscriber — the console's live socket — reads the receive end of a stream of its own, for as long as its block runs, and one that falls further behind than its backlog reads what was held for it and is cut off, never quietly skipped ahead. Each such stream is a fiber: a pair of ends in memory today, and the one thing to replace for a stream that outlives the process. Publishing is one way and knows nothing of who subscribed, and nothing is kept for a reader that is not there: an event published to a thread nobody subscribes to goes nowhere, and a console re-reads the thread ledger when it opens.
Nerve.deliver reaches every subscriber of exactly one topic. A publisher sends
user notifications by delivering separately to each authorized user's topic.
Nerve.publish owns channel and thread routing for kicks and native tails.
Impulse
dataclass
¶
One wire event with an optional channel address and the routing metadata
used by Nerve.publish. Direct topic publication carries it unchanged.
Source code in octomate/nerve.py
ChannelTopic
dataclass
¶
ThreadTopic
dataclass
¶
UserTopic
dataclass
¶
Fiber ¶
One stream through the nerve, both ends: a kick's or a subscriber's,
holding up to buffer items its reader has yet to take.
Source code in octomate/nerve.py
Nerve ¶
The subscribers of each channel, thread and user, and what is published to them.
Source code in octomate/nerve.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
subscribers
instance-attribute
¶
subscribe ¶
The receive end of a stream of the topic's impulses, from now until
the block ends. Nothing is dropped: a reader that falls more than
backlog impulses behind reads what was held for it, and then its
stream ends.
ChannelTopic names a channel's addresses, ThreadTopic wraps one
ThreadKey, and UserTopic wraps a registered user's UUID.
Publishers choose authorized topics before publishing; the nerve does
not filter subscribers within a topic.
Source code in octomate/nerve.py
publish
async
¶
A buffered publisher for kicks and native tails, open for the block.
A kick names the thread it was asked on as origin; a native tail names
its native thread and scopes the stream to its connection. The publisher
stamps that origin on each impulse and publishes separately to its channel,
its destination thread, and its origin thread unless private. Each distinct
topic receives one publication.
Sending may wait for the pump, never for a subscriber. Everything sent before the block ends is published; closing emits no lifecycle events of its own.
Source code in octomate/nerve.py
deliver ¶
Deliver one impulse to every subscriber of exactly topic, waiting
for none. The impulse is delivered unchanged; its address, origin and
privacy flag do not select or exclude subscribers.
Source code in octomate/nerve.py
octomate.tentacles.siphon ¶
A channel's siphon: where what the nerve carries leaves for the platform.
An octopus pushes its ink out through its siphon. A channel's siphon pushes out what the nerve carries to it, through the channel's feelers — a run as a timeline when the channel streams, or its sends, batches and reply when it does not, and around runs a move's line, a failure, a send, an authorization. It holds the channel's subscription to its own addresses, and draws each thread in order in a lane of its own, so a slow thread holds up no other. A row the graph recorded comes with its id, and is marked with the platform id it was rendered as.
Siphon ¶
Draws what the nerve carries to one channel, thread by thread.
Source code in octomate/tentacles/siphon.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
start ¶
Subscribe to the channel's addresses now, so nothing published from
here on is missed, and read in the background until stop.
Source code in octomate/tentacles/siphon.py
stop
async
¶
read
async
¶
Hand each impulse to its thread's lane, opening one where none is.
Source code in octomate/tentacles/siphon.py
draw
async
¶
Draw one thread's impulses in order, and close the lane once nothing is left in it. A rendering that fails is logged and never ends the lane.
Source code in octomate/tentacles/siphon.py
feel
async
¶
Draw one impulse; a run's start draws the whole run, through its end.
Source code in octomate/tentacles/siphon.py
run
async
¶
Draw one agent run from the lane, up to its end: as a timeline when the channel streams, else quietly. What a failed rendering left unread is drained, so the lane resumes after the run.
Source code in octomate/tentacles/siphon.py
quietly
async
¶
A run on a channel that does not stream: its sends, batches and authorizations as they come, then its reply once. Answers the platform id the reply was posted as.
Source code in octomate/tentacles/siphon.py
mark
async
¶
Name the platform message a recorded row was rendered as.