| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Agent.Turn
Description
Named runner circuits that tie free dual ends into a turn.
A turn is a runner observation: it commits one token, then blocks on one
frame. Framing lives port-side (StdPorts stream marks);
the queue retry is the blocking boundary. No polling, no backoff — the
halt is decided by content, not inferred from quiet.
The correlation between a command and its response is carried by the
TurnToken envelope, not by pipe adjacency. The mediator's residual
state holds the pending command; a response matches when its thread
cites the command's id. This makes zero-frame and two-frame failures
detectable in-band rather than by positional guess.
Mark-carrying turns must use a Linear channel policy; weakening policies
can drop a command or response and break correlation.
turn e :: IO (Loop (,) (K IO) Text Text) turnTimeout u e :: IO (Loop (,) (K IO) Text (Maybe Text))
Synopsis
- data TurnToken a = TurnToken {
- turnBody :: a
- turnThread :: [PostId]
- data TurnState a = TurnState {}
- turnProcess :: Process (TurnToken a) (Maybe (TurnToken a, TurnToken a))
- turn :: Poles (K IO) (TurnToken Text) (TurnToken Text) -> IO (Trace (,) (K IO) Text Text)
- turnTimeout :: Int -> Poles (K IO) (TurnToken Text) (TurnToken Text) -> IO (Trace (,) (K IO) Text (Maybe Text))
Turn envelope
A turn envelope. Commands are sent with an empty turnThread; the
turn assigns them a fresh id. Responses must carry that id in their
turnThread to be matched with the pending command.
Constructors
| TurnToken | |
Fields
| |
Turn process
Residual state of the turn mediator. nextId supplies fresh command
ids; pending holds the command awaiting its response.
turnProcess :: Process (TurnToken a) (Maybe (TurnToken a, TurnToken a)) Source #
Process that correlates responses with the pending command by thread.
- A token with empty thread is treated as a command: it receives the next id and is stored as the pending command.
- A token with non-empty thread is treated as a response: it matches when its thread equals the pending command's id, emitting the pair.