Interface IHubOperationBuilder
OptimaJet.Workflow.Api.Configuration.IHubOperationBuilder
Registers callbacks for client invocations of one library-owned hub.
Namespace: OptimaJet.Workflow.Api.Configuration
public interface IHubOperationBuilderMethods
IHubOperationBuilder OnBefore(Func<IHubOperationContext, ValueTask<HubOperationResult?>> callback) #Adds argument preparation. Null continues; a result skips remaining before/authorization callbacks and the method, then runs OnAfter.
Parameters
Name
Type
Description
callbackFunc<IHubOperationContext, HubOperationResult>The preparation callback.
Returns
Type
Description
IHubOperationBuilderThis builder.
Remarks
Only this stage permits ReplaceArguments. Transport binding and ASP.NET authorization run first.
IHubOperationBuilder OnAuthorize(Func<IHubOperationContext, ValueTask<bool>> callback) #Adds authorization over the final arguments. The first false produces a failed completion and skips remaining authorization callbacks and the method.
Parameters
Name
Type
Description
callbackFunc<IHubOperationContext, Boolean>The authorization callback.
Returns
Type
Description
IHubOperationBuilderThis builder.
Remarks
Runs even when built-in security is disabled. Do not mutate arguments in this stage.
IHubOperationBuilder OnAfterSuccess(Func<IHubOperationContext, object?, ValueTask<object?>> callback) #Adds a transformation of the original method's non-null result, preserving its declared payload type.
Parameters
Name
Type
Description
callbackFunc<IHubOperationContext, Object, Object>The result transformation.
Returns
Type
Description
IHubOperationBuilderThis builder.
Remarks
Skipped for void/null returns, failures, short circuits and exception fallbacks. A stream is one return object; its items are outside this pipeline.
IHubOperationBuilder OnAfter(Func<IHubOperationContext, HubOperationResult, ValueTask<HubOperationResult>> callback) #Adds a transformation of the final completion, including short circuits, authorization denial and recovered exceptions.
Parameters
Name
Type
Description
callbackFunc<IHubOperationContext, HubOperationResult, HubOperationResult>The transformation, which must return a non-null completion.
Returns
Type
Description
IHubOperationBuilderThis builder.
IHubOperationBuilder OnException(Func<IHubOperationContext, Exception, ValueTask<HubOperationResult?>> callback) #Adds exception recovery. Null passes the original exception to the next callback; a completion handles it.
Parameters
Name
Type
Description
callbackFunc<IHubOperationContext, Exception, HubOperationResult>The recovery callback.
Returns
Type
Description
IHubOperationBuilderThis builder.
Remarks
Covers callbacks and method invocation, not binding, serialization, connection lifecycle or stream enumeration. Connection cancellation and protected tenant/process failures bypass recovery. Unhandled errors preserve their stack. Recovery failures do not re-enter recovery. A fallback before OnAfter passes through it once; a fallback for an OnAfter error is sent directly.
Remarks
Stages run in order: OnBefore, OnAuthorize, method, OnAfterSuccess, OnAfter. Each stage preserves registration order. Repeated selection shares the builder; freezing rejects further changes. Callbacks wrap method invocation, not connection lifecycle, outgoing events, or stream enumeration. Resolve scoped dependencies from the invocation context's Services.