Skip to content

NexusEndpointRouteBuilderExtensions Methods

Maps Nexus services, whose operations start durable work and cancel it, per the Nexus HTTP protocol.

MapNexusOperation(IEndpointRouteBuilder, string, Delegate)

staticextension
View source
public static RouteGroupBuilder MapNexusOperation(this IEndpointRouteBuilder service, string operation, Delegate handler)
Maps the Nexus operation operation, whose handler returns durable work, such as grain.ChargeAsync(input), which a start request starts as an operation.

Parameters

serviceIEndpointRouteBuilder
The group which NexusEndpointRouteBuilderExtensions returns.
operationstring
The operation name, such as charge, of URL-unreserved characters.
handlerDelegate
A delegate which binds the operation's input, such as from the JSON request body, and other parameters like a Minimal API handler, and returns a durable grain call or a reference to an existing task, which grain.GetDurableTask<T>(id) returns, directly or through a System.Threading.Tasks.Task or System.Threading.Tasks.ValueTask. It runs for each start request, including retries, and only creates the work.

Returns

A group builder which configures the operation's start and cancel endpoints.

Exceptions

System.ArgumentException
operation is empty or has characters other than URL-unreserved ones, or handler doesn't return durable work.

MapNexusService(IEndpointRouteBuilder, string, string?)

staticextension
View source
public static RouteGroupBuilder MapNexusService(this IEndpointRouteBuilder endpoints, string service, string? scope = null)
Maps the Nexus service service, whose operations NexusEndpointRouteBuilderExtensions maps.

Parameters

endpointsIEndpointRouteBuilder
The endpoint route builder, whose prefix is the Nexus endpoint, such as /nexus.
servicestring
The service name, such as payments.v1, of URL-unreserved characters.
scopestring?
The scope of the service's operations, or null for nexus/{service}.

Returns

A group builder which maps the service's operations and configures its endpoints.

Exceptions

System.ArgumentException
service is empty or has characters other than URL-unreserved ones.