Table of Contents

Class DurableQueueChannelDecorator

Namespace
JD.AI.Channels.Queue
Assembly
JD.AI.Channels.Queue.dll

Decorator that adds a durable SQLite WAL queue in front of any IChannel. Inbound messages are immediately written to the queue and acknowledged to Discord; a background worker drains the queue and dispatches to registered handlers.

This means Discord messages are never lost even if the agent or gateway restarts, and burst traffic is buffered safely on disk.

public sealed class DurableQueueChannelDecorator : IChannel, IAsyncDisposable, ICommandAwareChannel, IHostedService
Inheritance
DurableQueueChannelDecorator
Implements
Inherited Members

Constructors

DurableQueueChannelDecorator(IChannel, DiscordMessageBuffer, ILogger)

public DurableQueueChannelDecorator(IChannel inner, DiscordMessageBuffer queue, ILogger logger)

Parameters

inner IChannel
queue DiscordMessageBuffer
logger ILogger

Properties

ChannelType

Unique channel type identifier (e.g., "discord", "signal", "web").

public string ChannelType { get; }

Property Value

string

DisplayName

Display name for this channel instance.

public string DisplayName { get; }

Property Value

string

IsConnected

Whether the channel is currently connected and healthy.

public bool IsConnected { get; }

Property Value

bool

Methods

ConnectAsync(CancellationToken)

Connects to the messaging platform.

public Task ConnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DisconnectAsync(CancellationToken)

Gracefully disconnects.

public Task DisconnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

ReactAsync(string, string, string, CancellationToken)

Adds a reaction emoji to a message. Not all channels support this — default is no-op.

public Task ReactAsync(string conversationId, string messageId, string emoji, CancellationToken ct = default)

Parameters

conversationId string
messageId string
emoji string
ct CancellationToken

Returns

Task

RegisterCommandsAsync(ICommandRegistry, CancellationToken)

Registers admin commands for queue inspection and management. Call this during gateway startup after ICommandRegistry is populated.

public Task RegisterCommandsAsync(ICommandRegistry registry, CancellationToken ct = default)

Parameters

registry ICommandRegistry
ct CancellationToken

Returns

Task

SendMessageAsync(string, string, CancellationToken)

Sends a message to the specified conversation/thread.

public Task SendMessageAsync(string conversationId, string content, CancellationToken ct = default)

Parameters

conversationId string
content string
ct CancellationToken

Returns

Task

SendMessageWithAttachmentsAsync(string, string?, IReadOnlyList<OutboundAttachment>, CancellationToken)

Sends a message with file attachments. Channels that don't support attachments fall back to sending the text content only.

public Task SendMessageWithAttachmentsAsync(string conversationId, string? content, IReadOnlyList<OutboundAttachment> attachments, CancellationToken ct = default)

Parameters

conversationId string
content string
attachments IReadOnlyList<OutboundAttachment>
ct CancellationToken

Returns

Task

StartAsync(CancellationToken)

Implements IHostedService.StartAsync — starts the background queue drainer.

public Task StartAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

StopAsync(CancellationToken)

Implements IHostedService.StopAsync.

public Task StopAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

Events

MessageReceived

Raised when a new inbound message arrives.

public event Func<ChannelMessage, Task>? MessageReceived

Event Type

Func<ChannelMessage, Task>

Remarks

Uses Func<ChannelMessage, Task> instead of EventHandler to support async handlers.