class documentation

class Operation(Generic[InputT, OutputT]):

View In Hierarchy

Defines a Nexus operation in a Nexus service definition.

This class is for definition of operation name and input/output types only; to implement an operation, see nexusrpc.handler.operation_handler.

Example:

@nexusrpc.service
class MyNexusService:
    my_operation: nexusrpc.Operation[MyInput, MyOutput]
Class Variable input_type Undocumented
Class Variable method_name Undocumented
Class Variable name Undocumented
Class Variable output_type Undocumented
Class Variable service The service that contains this operation.
input_type: type[InputT] | None =

Undocumented

method_name: str | None =

Undocumented

name: str =

Undocumented

output_type: type[OutputT] | None =

Undocumented

service: ServiceDefinition | None =

The service that contains this operation.

nexusrpc.service and nexusrpc.handler.service_handler set this value. Each decorated class has its own operations. Thus, when a child service inherits an operation from a parent service, the operation reports the child service. The value is None when the operation is not part of a decorated class.