class documentation

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 start Start the operation, completing either synchronously or asynchronously.
@abstractmethod
def cancel(self, ctx: CancelOperationContext, token: str) -> None | Awaitable[None]:
@abstractmethod
def start(self, ctx: StartOperationContext, input: InputT) -> StartOperationResultSync[OutputT] | StartOperationResultAsync | Awaitable[StartOperationResultSync[OutputT] | StartOperationResultAsync]:

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.