proto
¤
TailCall
¤
Bases: Exception
The current coroutine is aborted and scheduling reset to be replaced with the call embedded in this exception.
Input
¤
Input(req: RunRequest)
The input to a primitive function.
Functions always take a single argument of type Input. When the function is run for the first time, it receives the input. When the function is a coroutine that's resuming after a yield point, it receives the results of the yield directive. Use the is_first_call and is_resume properties to differentiate between the two cases.
This class is intended to be used as read-only.
input_arguments
¤
input_arguments() -> Tuple[Tuple[Any, ...], Dict[str, Any]]
Returns positional and keyword arguments carried by the input.
Arguments
dataclass
¤
Arguments(args: Tuple[Any, ...], kwargs: Dict[str, Any])
A container for positional and keyword arguments.
Output
dataclass
¤
Output(proto: RunResponse)
The output of a primitive function.
This class is meant to be instantiated and returned by authors of functions to indicate the follow up action they need to take. Use the various class methods create an instance of this class. For example Output.value() or Output.poll().
value
classmethod
¤
Terminally exit the function with the provided return value.
error
classmethod
¤
Terminally exit the function with the provided error.
tail_call
classmethod
¤
Terminally exit the function, and instruct the orchestrator to tail call the specified function.
exit
classmethod
¤
exit(
result: Optional[CallResult] = None,
tail_call: Optional[Call] = None,
status: Status = Status.OK,
) -> Output
Terminally exit the function.
poll
classmethod
¤
poll(
coroutine_state: Any = None,
calls: Optional[List[Call]] = None,
min_results: int = 1,
max_results: int = 10,
max_wait_seconds: Optional[int] = None,
) -> Output
Suspend the function with a set of Calls, instructing the orchestrator to resume the function with the provided state when call results are ready.
Call
dataclass
¤
Call(
function: str,
input: Optional[Any] = None,
endpoint: Optional[str] = None,
correlation_id: Optional[int] = None,
)
Instruction to call a function.
Though this class can be built manually, it is recommended to use the with_call method of a Function instead.
CallResult
dataclass
¤
CallResult(
correlation_id: Optional[int] = None,
output: Optional[Any] = None,
error: Optional[Error] = None,
dispatch_id: DispatchID = "",
)
Result of a Call.
Error
dataclass
¤
Error(
status: Status,
type: str,
message: str,
value: Optional[Exception] = None,
traceback: Optional[bytes] = None,
)
Error when running a function.
This is not a Python exception, but potentially part of a CallResult or Output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status |
Status
|
categorization of the error. |
required |
type |
str
|
arbitrary string, used for humans. |
required |
message |
str
|
arbitrary message. |
required |
value |
Optional[Exception]
|
arbitrary exception from which the error is derived. Optional. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
Neither type or message was provided or status is invalid. |
from_exception
classmethod
¤
Create an Error from a Python exception, using its class qualified named as type.
The status tries to be inferred, but can be overridden. If it is not provided or cannot be inferred, it defaults to TEMPORARY_ERROR.