Skip to content

DurableIdempotencyKeyHandler

class

Namespace: Orleans.Durable.Http

Adds an 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 : DelegatingHandler

Remarks

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

Methods