Table of Contents

Interface IMessageTtlManager

Namespace
DotCompute.Abstractions.Messaging
Assembly
DotCompute.Abstractions.dll

Manages message TTL enforcement and expiration handling.

public interface IMessageTtlManager : IAsyncDisposable
Inherited Members

Properties

ExpiredCount

Gets the number of messages that have expired while being tracked.

long ExpiredCount { get; }

Property Value

long

TrackedCount

Gets the number of messages currently being tracked.

int TrackedCount { get; }

Property Value

int

Methods

CancelTracking(Guid)

Stops tracking a message.

bool CancelTracking(Guid trackingId)

Parameters

trackingId Guid

The tracking ID from TrackAsync<TMessage>(TMessage, Func<TMessage, Task>, CancellationToken).

Returns

bool

True if tracking was cancelled.

GetRemainingTtl<TMessage>(TMessage)

Gets the remaining TTL for a message.

TimeSpan? GetRemainingTtl<TMessage>(TMessage message) where TMessage : IRingKernelMessage

Parameters

message TMessage

The message to check.

Returns

TimeSpan?

Remaining time, or TimeSpan.Zero if expired, or null if no TTL.

Type Parameters

TMessage

The message type.

IsExpired<TMessage>(TMessage)

Checks if a message has expired.

bool IsExpired<TMessage>(TMessage message) where TMessage : IRingKernelMessage

Parameters

message TMessage

The message to check.

Returns

bool

True if the message has expired.

Type Parameters

TMessage

The message type.

TrackAsync<TMessage>(TMessage, Func<TMessage, Task>, CancellationToken)

Tracks a message for TTL enforcement.

Task<Guid> TrackAsync<TMessage>(TMessage message, Func<TMessage, Task> onExpired, CancellationToken cancellationToken = default) where TMessage : IRingKernelMessage

Parameters

message TMessage

The message to track.

onExpired Func<TMessage, Task>

Callback when the message expires.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<Guid>

A tracking ID that can be used to cancel tracking.

Type Parameters

TMessage

The message type.

Events

MessageExpired

Occurs when a tracked message expires.

event EventHandler<MessageExpiredEventArgs>? MessageExpired

Event Type

EventHandler<MessageExpiredEventArgs>