class documentation

A client for invoking Nexus operations.

Warning

This API is experimental and unstable.

Example:

nexus_client = workflow.create_nexus_client(
    endpoint=my_nexus_endpoint,
    service=MyService,
)
handle = await nexus_client.start_operation(
    operation=MyService.my_operation,
    input=MyOperationInput(value="hello"),
    schedule_to_close_timeout=timedelta(seconds=10),
)
result = await handle.result()
Async Method execute_operation Execute a Nexus operation and return its result.
Async Method start_operation Start a Nexus operation and return its handle.
@overload
@abstractmethod
async def execute_operation(self, operation: nexusrpc.Operation[InputT, OutputT], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> OutputT:
@overload
@abstractmethod
async def execute_operation(self, operation: str, input: Any, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> OutputT:
@overload
@abstractmethod
async def execute_operation(self, operation: Callable[[ServiceHandlerT, temporalio.nexus.WorkflowRunOperationContext, InputT], Awaitable[temporalio.nexus.WorkflowHandle[OutputT]]], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> OutputT:
@overload
@abstractmethod
async def execute_operation(self, operation: Callable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], Awaitable[OutputT]], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> OutputT:
@overload
@abstractmethod
async def execute_operation(self, operation: Callable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], OutputT], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> OutputT:
@abstractmethod
(source)

Execute a Nexus operation and return its result.

Parameters
operation:AnyThe Nexus operation.
input:AnyThe Nexus operation input.
output_type:type[OutputT] | NoneThe Nexus operation output type.
schedule_to_close_timeout:timedelta | NoneTimeout for the entire operation attempt.
headers:Mapping[str, str] | NoneHeaders to send with the Nexus HTTP request.
Returns
AnyThe operation result.
@overload
@abstractmethod
async def start_operation(self, operation: nexusrpc.Operation[InputT, OutputT], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> NexusOperationHandle[OutputT]:
@overload
@abstractmethod
async def start_operation(self, operation: str, input: Any, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> NexusOperationHandle[OutputT]:
@overload
@abstractmethod
async def start_operation(self, operation: Callable[[ServiceHandlerT, temporalio.nexus.WorkflowRunOperationContext, InputT], Awaitable[temporalio.nexus.WorkflowHandle[OutputT]]], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> NexusOperationHandle[OutputT]:
@overload
@abstractmethod
async def start_operation(self, operation: Callable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], Awaitable[OutputT]], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> NexusOperationHandle[OutputT]:
@overload
@abstractmethod
async def start_operation(self, operation: Callable[[ServiceHandlerT, nexusrpc.handler.StartOperationContext, InputT], OutputT], input: InputT, *, output_type: type[OutputT] | None = None, schedule_to_close_timeout: timedelta | None = None, headers: Mapping[str, str] | None = None) -> NexusOperationHandle[OutputT]:
@abstractmethod
(source)

Start a Nexus operation and return its handle.

Parameters
operation:AnyThe Nexus operation.
input:AnyThe Nexus operation input.
output_type:type[OutputT] | NoneThe Nexus operation output type.
schedule_to_close_timeout:timedelta | NoneTimeout for the entire operation attempt.
headers:Mapping[str, str] | NoneHeaders to send with the Nexus HTTP request.
Returns
AnyA handle to the Nexus operation. The result can be obtained as `python await handle.result() `