Observe and change a running session¶
Attach to a live session to inspect traffic and control individual nodes. Addresses identify a node, direction, and optional port: source.in, source.out, or source.in.context.
Run the control example¶
With the MS2 native profile:
The complete example creates source → sink, subscribes before publishing, and checks the downstream result after every decision. Its executed scope is in-process control. Remote control and Entry have separate setup and transport limits.
| Operation | Effect |
|---|---|
await ctrl.subscribe("source.out") |
Observe original output before an interceptor rewrites it |
await ctrl.subscribe_in("source.in") |
Observe live input |
await ctrl.publish("source.in", data) |
Enqueue input for processing |
await ctrl.publish_out("source.out.external", data) |
Publish to control-bus output subscribers; does not run the downstream graph |
ctrl.intercept("source.out", deadline_ms=...) |
Receive an output decision request |
await request.replace(Data.from_text(...)) |
Replace the value delivered downstream |
await request.drop() / pass_through() |
Discard or forward that output |
An input publication acknowledgement is not a processing result. Wait for the downstream event, application completion marker, or RPC reply you need. Taps are live observation channels, not durable replay logs. Subscribe first and close each iterator with aclose() when leaving early.
Set an interception deadline¶
An excerpt for an already attached control client:
import asyncio
from remotemedia.control import Data
async def replace_one(ctrl):
async with ctrl.intercept("source.out", deadline_ms=2000) as decisions:
await ctrl.publish("source.in", "original")
decision = await asyncio.wait_for(anext(decisions), 5)
await decision.replace(Data.from_text("rewritten"))
The example uses a long decision window for a tutorial; the API's default is 50 ms. The reviewed runtime forwards the original value when a decision expires. Keep slow network or model work out of a short interception window. Inspect the sink to verify a replacement: an output tap on source still sees the original.
Override node state¶
NodeState.DISABLED stops normal processing; BYPASS forwards input without running the node; ENABLED requests normal processing. await ctrl.clear_node_state("source") removes the override. The example verifies no disabled output during a 200 ms window, then verifies bypass and reset with distinct inputs. This observation is not a universal queue-flush or timing guarantee.
Carry identity deliberately¶
The checkout accepts metadata={"request_id": "docs-1"} on publication. The tested in-process input tap returns empty metadata for that value; the example records this limitation instead of asserting preservation. Do not use this path as proof of end-to-end identity propagation.
For participant identity, the shared-session example checks the participant attached to recv_event() outputs. In Scaling, the admitted member is bound to its ticket. Treat application correlation metadata and authenticated participant identity as different fields.
Next¶
Call worker methods and application tools when you need a correlated result or callback lifecycle.
Source references: remotemedia-sdk/clients/python/remotemedia/control/client.py · remotemedia-sdk/clients/python/remotemedia/control/data.py · remotemedia-sdk/clients/python/remotemedia/control/transport.py · remotemedia-sdk-base/src/transport/session_control.rs (base revision; reviewed with local changes)