orangeqs.juice.orchestration.remote_gateway#

JupyterHub-side remote gateway: /hub/tasks, /hub/pub, /hub/sub edges.

Module Contents#

Classes#

AckedNames

In-memory acked-names -> live /hub/tasks connection map.

RemoteTasksHandler

/hub/tasks: the remote’s identity socket, reverse-proxied to the task mgr.

RemotePubHandler

/hub/pub: relay a remote’s published events onto the internal bus.

RemoteSubHandler

/hub/sub: stream internal bus events out to a subscribing remote.

Functions#

acked_names

Return the process-wide acked-names registry.

extra_handlers

Return handler routes for c.JupyterHub.extra_handlers (under /hub/).

API#

class orangeqs.juice.orchestration.remote_gateway.AckedNames#

In-memory acked-names -> live /hub/tasks connection map.

register(name: str, connection: Any) None#

Record that name holds connection as its live task socket.

deregister(name: str, connection: Any) None#

Drop name iff connection is still its registered socket.

is_live(name: str) bool#

Whether name currently holds a live acknowledged task socket.

orangeqs.juice.orchestration.remote_gateway.acked_names() orangeqs.juice.orchestration.remote_gateway.AckedNames#

Return the process-wide acked-names registry.

class orangeqs.juice.orchestration.remote_gateway.RemoteTasksHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: tornado.websocket.WebSocketHandler

/hub/tasks: the remote’s identity socket, reverse-proxied to the task mgr.

backend_route: ClassVar[str]#

‘remote-channel’

initialize(acked: orangeqs.juice.orchestration.remote_gateway.AckedNames | None = None, authenticate: collections.abc.Callable[[str | None], collections.abc.Awaitable[bool]] | None = None) None#

Wire the handler to the acked-names registry and edge-token validator.

property ping_interval: float#

Seconds between server-initiated keepalive pings.

property ping_timeout: float#

Seconds to await a pong before closing the socket as half-open.

check_origin(origin: str) bool#

Auth is by edge token, not origin, so allow cross-origin connections.

async prepare() None#

Validate the edge token before the WS upgrade, once per connection.

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

Dial the backend and pump backend->client frames.

async on_message(message: str | bytes) None#

Forward a client frame to the backend the first frame is the announcement.

on_close() None#

Drop the acked entry (half-open or clean close both mean “remote gone”).

class orangeqs.juice.orchestration.remote_gateway.RemotePubHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: orangeqs.juice.orchestration.remote_gateway._WebSocketProxyHandler

/hub/pub: relay a remote’s published events onto the internal bus.

backend_route#

‘remote-pub’

class orangeqs.juice.orchestration.remote_gateway.RemoteSubHandler(application: tornado.web.Application, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)#

Bases: orangeqs.juice.orchestration.remote_gateway._WebSocketProxyHandler

/hub/sub: stream internal bus events out to a subscribing remote.

backend_route#

‘remote-sub’

orangeqs.juice.orchestration.remote_gateway.extra_handlers() list[tuple[str, type[tornado.web.RequestHandler]]]#

Return handler routes for c.JupyterHub.extra_handlers (under /hub/).