class OperationHandler(ABC, Generic[
Known subclasses: nexusrpc.handler._operation_handler.SyncOperationHandler
Base class for an operation handler in a Nexus service implementation.
To define a Nexus operation handler, create a method on your service handler class
that takes self
and returns an instance of OperationHandler
, and apply
the @nexusrpc.handler.operation_handler
decorator.
To create an operation handler that is limited to returning synchronously, use
@nexusrpc.handler.SyncOperationHandler
to create the
instance of OperationHandler
from the start method.
Method | cancel |
Cancel the operation. |
Method | fetch |
Return information about the current status of the operation. |
Method | fetch |
Return the result of the operation. |
Method | start |
Start the operation, completing either synchronously or asynchronously. |
CancelOperationContext
, token: str
) -> None | Awaitable[ None]
:
¶
nexusrpc.handler._operation_handler.SyncOperationHandler
Cancel the operation.
FetchOperationInfoContext
, token: str
) -> OperationInfo | Awaitable[ OperationInfo]
:
¶
nexusrpc.handler._operation_handler.SyncOperationHandler
Return information about the current status of the operation.
FetchOperationResultContext
, token: str
) -> OutputT | Awaitable[ OutputT]
:
¶
nexusrpc.handler._operation_handler.SyncOperationHandler
Return the result of the operation.
StartOperationContext
, input: InputT
) -> StartOperationResultSync[ OutputT] | Awaitable[ StartOperationResultSync[ OutputT]] | StartOperationResultAsync | Awaitable[ StartOperationResultAsync]
:
¶
nexusrpc.handler._operation_handler.SyncOperationHandler
Start the operation, completing either synchronously or asynchronously.
Returns the result synchronously, or returns an operation token. Which path is taken may be decided at operation handling time.