Assembly: OptimaJet.Workflow.Api

Interface IHubOperationBuilder

OptimaJet.Workflow.Api.Configuration.IHubOperationBuilder

Registers callbacks for client invocations of one library-owned hub.

public interface IHubOperationBuilder

Methods

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
callback
Func<IHubOperationContext, HubOperationResult>
The preparation callback.

Returns

Type
Description
IHubOperationBuilder
This 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
callback
Func<IHubOperationContext, Boolean>
The authorization callback.

Returns

Type
Description
IHubOperationBuilder
This 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
callback
Func<IHubOperationContext, Object, Object>
The result transformation.

Returns

Type
Description
IHubOperationBuilder
This 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
callback
Func<IHubOperationContext, HubOperationResult, HubOperationResult>
The transformation, which must return a non-null completion.

Returns

Type
Description
IHubOperationBuilder
This 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
callback
Func<IHubOperationContext, Exception, HubOperationResult>
The recovery callback.

Returns

Type
Description
IHubOperationBuilder
This 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.