ProtocolDistributed5.9.0
DistributedTargetInvocationResultHandler
Protocol a distributed invocation execution’s result handler.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
protocol DistributedTargetInvocationResultHandler
An instance conforming to this type must be passed when invoking executeDistributedTarget(on:target:invocationDecoder:handler:)
while handling an incoming distributed call.
The handler will then be invoked with the return value (or error) that the invoked target returned (or threw).
Protocol requirements
Similar to the DistributedActorSystem
and its remoteCall
and remoteCallVoid
protocol requirements, the DistributedTargetInvocationResultHandler
contains a method which is not possible to express in source due to advanced use of generics combined with associated types. Specifically, the onReturn
method is not expressed in source as protocol requirement, but will be treated by the compiler as-if they were.
In addition to the compiler offering compile errors if this witnesses is missing in an adopting type, we present its signature here for reference:
/// Ad-hoc protocol requirement
///
/// Invoked when the distributed target execution returns successfully.
/// The `value` is the return value of the executed distributed invocation target.
func onReturn<Success: SerializationRequirement>(value: Success) async throws
Requirements
associatedtype SerializationRequirement
The serialization requirement that the value passed to
onReturn
is required to conform to.func onReturnVoid(
) async throws Invoked when the distributed target execution of a
Void
returning function has completed successfully.func onThrow<Err>(error: Err
) async throws Invoked when the distributed target execution of a target has thrown an error.