Skip to content

ProcessLocalDeliveryLease Class

The lease inside one process, which is the whole of its reach: it excludes the threads of this instance from each other and nothing else. A second instance of the application holds its own dictionary and sees none of these claims, so every instance believes it holds every lease.

C#
public sealed class ProcessLocalDeliveryLease : Abblix.SharedSignals.Transmitter.IDeliveryLease

Inheritance System.Object → ProcessLocalDeliveryLease

Implements IDeliveryLease

Remarks

The name says the boundary because that is the only thing a reader must not get wrong. It is the honest default for a single instance and for tests, and it is the wrong one the moment a deployment scales out - AddSharedSignalsRedisDeliveryLease is the implementation that spans instances, and a deployment already sharing its outbox needs it.

Constructors

ProcessLocalDeliveryLease(TimeProvider) Constructor

The lease inside one process, which is the whole of its reach: it excludes the threads of this instance from each other and nothing else. A second instance of the application holds its own dictionary and sees none of these claims, so every instance believes it holds every lease.

C#
public ProcessLocalDeliveryLease(System.TimeProvider timeProvider);

Parameters

timeProvider System.TimeProvider

The clock the deadlines are read from; a test hands in a fake.

Remarks

The name says the boundary because that is the only thing a reader must not get wrong. It is the honest default for a single instance and for tests, and it is the wrong one the moment a deployment scales out - AddSharedSignalsRedisDeliveryLease is the implementation that spans instances, and a deployment already sharing its outbox needs it.

Methods

ProcessLocalDeliveryLease.TryAcquireAsync(string, TimeSpan, CancellationToken) Method

Claims name for at most duration.

C#
public System.Threading.Tasks.Task<System.IAsyncDisposable?> TryAcquireAsync(string name, System.TimeSpan duration, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

name System.String

What is being claimed. Callers scope it themselves, so two kinds of work over one stream do not collide.

duration System.TimeSpan

How long the claim holds without being released. It bounds two opposite costs: too short cuts a legitimate pass off and the work is redone next time, too long parks the work for the remainder after the holder dies. Both are safe, so err on whichever the deployment minds less.

cancellationToken System.Threading.CancellationToken

Cancels the I/O a shared implementation performs.

Implements TryAcquireAsync(string, TimeSpan, CancellationToken)

Returns

System.Threading.Tasks.Task<System.IAsyncDisposable>
A handle that releases the claim when disposed, or null when someone else holds it - which is an ordinary outcome and not a failure. Releasing is conditional on still holding it, so a handle disposed after its deadline cannot revoke the claim of whoever took over.