DurableIdempotencyKeyHandler
Namespace: Orleans.Durable.Http
Idempotency-Key header which identifies the running durable task to each request that a durable task sends, so every attempt and replay of the task sends the same key. public sealed class DurableIdempotencyKeyHandler : DelegatingHandlerRemarks
The key is a hash of the service, the grain which runs the task, the task's identifier, and its DurableTaskContext: 43 URL-safe base64 characters which are equal for every attempt and replay of one run of the task, and distinct for every other task, including a later run of the same task identifier, whose earlier keys a server may still hold. A step which sends one request, such as DurableTask.Run(ct => client.PostAsJsonAsync(...)), therefore makes that request idempotent at servers which honor the header, including a retry of the step after a failure or a deactivation. A step which sends several requests to different operations gives each its own step, such as with DurableTaskExtensions, or sets their keys itself.
A request with a safe method, such as GET, a request which already carries the header, and a request which code outside a durable task sends are unchanged. Register the handler before handlers which retry requests, so their retries carry the key.
Constructors
DurableIdempotencyKeyHandler(IGrainContextAccessor, IOptions<ClusterOptions>)Adds anIdempotency-Keyheader which identifies the running durable task to each request that a durable task sends, so every attempt and replay of the task sends the same key.
Methods
Send(HttpRequestMessage, CancellationToken)Sends an HTTP request to the inner handler to send to the server.SendAsync(HttpRequestMessage, CancellationToken)Sends an HTTP request to the inner handler to send to the server as an asynchronous operation.
