THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
Execute a precompiled Hub using the existing application and scopes.
| Async Static Method | _error |
Send a controlled error without exposing application exception text. |
| Method | __init__ |
Compile trusted Hub metadata before accepting network messages. |
| Method | _bind |
Publish connection primitives into an independent scope. |
| Async Method | _build |
Construct a fresh Hub and attach its scoped connection primitives. |
| Async Method | _disconnect |
Run the final hook without allowing it to prevent socket cleanup. |
| Async Method | _invoke |
Execute one remote method inside its own contextvars-backed scope. |
| Async Method | _receive |
Keep the sole reader available while invocations execute concurrently. |
| Async Method | _start |
Validate admission before allocating an invocation task. |
| Async Method | _stream |
Deliver each item before advancing the producer and close its iterator. |
| Async Method | serve |
Run one Hub connection and release all resources before returning. |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _app |
Undocumented |
| Instance Variable | _dispatch |
Undocumented |
| Instance Variable | _hub |
Undocumented |
| Instance Variable | _manager |
Undocumented |
| Instance Variable | _protocol |
Undocumented |
RealtimeConnection, invocation_id: str, code: str, *, streaming: bool = False):
(source)
¶
Send a controlled error without exposing application exception text.
| Parameters | |
connection:RealtimeConnection | Response destination. |
invocationstr | Previously validated correlation ID. |
code:str | Stable error classification. |
streaming:bool, optional | Whether to terminate a stream instead of a scalar invocation. |
| Returns | |
None | Release active invocation ownership and send a terminal error, or skip delivery when the connection is closing or already closed. |
| Raises | |
ConnectionError | If connection cleanup starts before the write acquires ownership. |
asyncio.CancelledError | If terminal error delivery is cancelled. |
IApplication, manager: IConnectionManager, hub: type[ Hub], protocol: str = 'json'):
(source)
¶
Compile trusted Hub metadata before accepting network messages.
| Parameters | |
app:IApplication | Existing application and dependency container. |
manager:IConnectionManager | Shared worker-local registry and targeting service. |
hub:type[Hub] | Application-declared Hub class. |
protocol:str, optional | JSON or MessagePack selected by the route. |
| Returns | |
None | Store runtime dependencies and compile dispatch and codec metadata. |
| Raises | |
TypeError | If the Hub class, remote descriptors or annotations are unsupported. |
ValueError | If remote names, aliases, protocol or message size are invalid. |
Publish connection primitives into an independent scope.
| Parameters | |
scope:ScopeManager | Active connection or invocation scope. |
connection:RealtimeConnection | Owner of network state. |
| Returns | |
None | Register the socket, context, connection, client and group proxies, and HTTP kernel marker in the supplied scope. |
Construct a fresh Hub and attach its scoped connection primitives.
| Parameters | |
connection:RealtimeConnection | Connection used for lifecycle and client targeting. |
| Returns | |
Hub | Fresh instance with constructor injection resolved. |
Run the final hook without allowing it to prevent socket cleanup.
| Parameters | |
connection:RealtimeConnection | Already unregistered connection. |
code:int | Observed or locally selected closure code. |
reason:str | Peer reason where available. |
| Returns | |
None | Bound the disconnect hook to five seconds, log hook failures and close the socket if it remains open. |
| Raises | |
asyncio.CancelledError | If the final hook or socket closure is cancelled. |
RealtimeConnection, method: RemoteMethod, envelope: Invoke, auth: AuthenticationContext):
(source)
¶
Execute one remote method inside its own contextvars-backed scope.
| Parameters | |
connection:RealtimeConnection | Owner of tasks and response delivery. |
method:RemoteMethod | Boot-compiled callable and binding metadata. |
envelope:Invoke | Validated client values, never executable metadata. |
auth:AuthenticationContext | Fresh authentication context with independent authorization cache. |
| Returns | |
None | Resolve dependencies, execute the method and send its result or a sanitized error after invocation-scope cleanup. |
| Raises | |
asyncio.CancelledError | If the invocation is cancelled after attempting its error response. |
Keep the sole reader available while invocations execute concurrently.
| Parameters | |
connection:RealtimeConnection | Ready connection with finite owned task registries. |
| Returns | |
tuple[int, str] | Peer close code and reason, or (1000, "") when local reading stops. |
| Raises | |
ProtocolError | If decoding fails or an active invocation identifier is reused. |
WebSocketDisconnected | If socket operations report a disconnected peer. |
asyncio.CancelledError | If the connection reader is cancelled. |
Validate admission before allocating an invocation task.
| Parameters | |
connection:RealtimeConnection | Connection owning the invocation ID namespace. |
envelope:Invoke | Structurally validated client invocation. |
| Returns | |
None | Register an admitted invocation task or send a controlled rejection. |
| Raises | |
ProtocolError | If an active invocation ID is reused. |
RealtimeConnection, invocation_id: str, source: AsyncIterable[ object]):
(source)
¶
Deliver each item before advancing the producer and close its iterator.
| Parameters | |
connection:RealtimeConnection | Connection providing natural send backpressure. |
invocationstr | Correlation ID selected at admission. |
source:AsyncIterable[object] | Application-produced asynchronous stream. |
| Returns | |
None | Send correlated stream items and await iterator closure when an aclose method is available. |
| Raises | |
TypeError, ValueError | If a stream item cannot be encoded by the selected codec. |
ConnectionError | If connection cleanup has started during delivery. |
asyncio.CancelledError | If streaming is cancelled while producing, sending or closing. |
Run one Hub connection and release all resources before returning.
| Parameters | |
socket:WebSocket | Socket already registered in a kernel connection scope. |
| Returns | |
None | Run connection hooks and message handling, then release owned work, registry membership and socket resources. |
| Raises | |
RuntimeError | If called without the application's active connection scope. |
asyncio.CancelledError | If the connection owner is cancelled without a recorded failure. |