orangeqs.juice.task_manager._remote#

Task-manager side of remote services: the ack gate and Reverse Channel.

Module Contents#

Classes#

AckResult

Outcome of the acknowledgement gate and the frame it maps to.

RemoteConnection

A registered remote connection in the Task Manager.

RemoteRegistry

In-memory table of currently-acknowledged remotes, keyed by name.

RemoteChannelHandler

The Reverse Channel endpoint a remote connects to.

RemotePubBridgeHandler

Bridges a remote’s Events publishes onto the internal ZMQ bus.

RemoteSubBridgeHandler

Streams internal ZMQ bus events out to a subscribing remote.

Functions#

acknowledge

Gate a connecting remote by its declared name.

API#

class orangeqs.juice.task_manager._remote.AckResult#

Outcome of the acknowledgement gate and the frame it maps to.

accepted: bool#

None

error: str | None#

None

to_frame() dict[str, Any]#

Return the confirmation frame sent back to the remote.

orangeqs.juice.task_manager._remote.acknowledge(name: str, *, declared_remotes: collections.abc.Iterable[str], managed_services: collections.abc.Iterable[str]) orangeqs.juice.task_manager._remote.AckResult#

Gate a connecting remote by its declared name.

A remote is admitted iff it’s declared in the juice config and not colliding with a a local service name.

class orangeqs.juice.task_manager._remote.RemoteConnection(handler: orangeqs.juice.task_manager._remote.RemoteChannelHandler, name: str)#

A registered remote connection in the Task Manager.

async request_raw(task_id: str, message: str | bytes) asyncio.Future[dict[str, Any]]#

Push a raw task frame down the channel; return a future for its result.

resolve_result(data: dict[str, Any]) None#

Resolve the pending future for an incoming result frame by id.

close() None#

Mark closed and fail every in-flight pushed task.

is_closed() bool#

Whether this connection can no longer be used.

class orangeqs.juice.task_manager._remote.RemoteRegistry#

In-memory table of currently-acknowledged remotes, keyed by name.

register(connection: orangeqs.juice.task_manager._remote.RemoteConnection) None#

Register a connection, replacing (and closing) any prior one for its name.

deregister(connection: orangeqs.juice.task_manager._remote.RemoteConnection) None#

Remove a connection if it is still the registered one for its name.

get(name: str) orangeqs.juice.task_manager._remote.RemoteConnection | None#

Return the live connection for a name, or None.

class orangeqs.juice.task_manager._remote.RemoteChannelHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: tornado.websocket.WebSocketHandler

The Reverse Channel endpoint a remote connects to.

initialize(registry: orangeqs.juice.task_manager._remote.RemoteRegistry, declared_remotes: collections.abc.Callable[[], collections.abc.Iterable[str]], managed_services: collections.abc.Callable[[], collections.abc.Iterable[str]]) None#

Wire the handler to the registry and config sources.

declared_remotes / managed_services are callables so the gate reads current config per connection, not a boot-time snapshot. This ensures that newly added remote configs are applied instantly on new connections.

check_origin(origin: str) bool#

Allow cross-origin connections; auth happens at the edge.

on_message(message: str | bytes) None#

Handle the announcement, then result frames from pushed tasks.

on_close() None#

Deregister and fail in-flight pushed tasks when the remote disconnects.

class orangeqs.juice.task_manager._remote.RemotePubBridgeHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: tornado.websocket.WebSocketHandler

Bridges a remote’s Events publishes onto the internal ZMQ bus.

initialize(publish_frame: collections.abc.Callable[[list[bytes]], collections.abc.Awaitable[None]]) None#

Wire the bus publish path (a long-lived, slow-joiner-safe publisher).

check_origin(origin: str) bool#

Allow cross-origin connections; auth happens at the edge.

async on_message(message: str | bytes) None#

Relay one multipart publish frame onto the internal bus.

class orangeqs.juice.task_manager._remote.RemoteSubBridgeHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: tornado.websocket.WebSocketHandler

Streams internal ZMQ bus events out to a subscribing remote.

initialize(sub_socket_factory: collections.abc.Callable[[], Any]) None#

Store the socket factory; the socket opens once the WS is established.

check_origin(origin: str) bool#

Allow cross-origin connections; auth happens at the edge.

open(*args: Any, **kwargs: Any) None#

Subscribe to the bus and forward frames from a background task.

on_close() None#

Stop the forward loop and close the subscribe socket.