Skip to main content
Table of Contents

Interface IDurableTimers

Namespace
Stratara.Abstractions.Timers
Assembly
Stratara.Abstractions.dll

Durable, owner-checked, one-shot timers. A timer belongs to an owner — an aggregate, a process, a unit of work — and fires once at its due time, in one place per cluster, surviving restarts. When it fires, the owner is checked first: a timer whose owner is gone unregisters itself and does nothing. The operation that ends an owner cancels its timers in the same call.

public interface IDurableTimers
Extension Methods

Remarks

The timers are stored in the cluster's reminder table and nowhere else. The due time is part of the timer's identity, so registering the same owner and purpose again replaces the earlier timer. Delivery is at least once: a handler that throws sees the timer again after the retry period the host configured, and a handler must tolerate that.

Methods

CancelAllAsync(string, CancellationToken)

Cancels every timer of an owner — the call the operation that ends the owner makes.

Task CancelAllAsync(string ownerId, CancellationToken cancellationToken = default)

Parameters

ownerId string

The owner.

cancellationToken CancellationToken

Propagated to the cancellation.

Returns

Task

CancelAsync(string, string, CancellationToken)

Cancels one timer of an owner. Cancelling a timer that does not exist is not an error.

Task CancelAsync(string ownerId, string purpose, CancellationToken cancellationToken = default)

Parameters

ownerId string

The owner.

purpose string

The purpose the timer was registered with.

cancellationToken CancellationToken

Propagated to the cancellation.

Returns

Task

ListAsync(string, CancellationToken)

Lists the timers an owner currently has, for diagnostics and tests.

Task<IReadOnlyList<TimerRegistration>> ListAsync(string ownerId, CancellationToken cancellationToken = default)

Parameters

ownerId string

The owner.

cancellationToken CancellationToken

Propagated to the lookup.

Returns

Task<IReadOnlyList<TimerRegistration>>

The registrations, or an empty list.

RegisterAsync(TimerRegistration, CancellationToken)

Registers a timer, replacing any timer with the same owner and purpose.

Task RegisterAsync(TimerRegistration registration, CancellationToken cancellationToken = default)

Parameters

registration TimerRegistration

The owner, purpose and due time.

cancellationToken CancellationToken

Propagated to the registration.

Returns

Task

A task that completes when the timer is registered.

Exceptions

ArgumentException

The purpose is empty, contains @, or is longer than the timer store holds (130 characters).