Class DurableQueueChannelDecorator
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
innerIChannelqueueDiscordMessageBufferloggerILogger
Properties
ChannelType
Unique channel type identifier (e.g., "discord", "signal", "web").
public string ChannelType { get; }
Property Value
DisplayName
Display name for this channel instance.
public string DisplayName { get; }
Property Value
IsConnected
Whether the channel is currently connected and healthy.
public bool IsConnected { get; }
Property Value
Methods
ConnectAsync(CancellationToken)
Connects to the messaging platform.
public Task ConnectAsync(CancellationToken ct = default)
Parameters
Returns
DisconnectAsync(CancellationToken)
Gracefully disconnects.
public Task DisconnectAsync(CancellationToken ct = default)
Parameters
Returns
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
conversationIdstringmessageIdstringemojistringctCancellationToken
Returns
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
registryICommandRegistryctCancellationToken
Returns
SendMessageAsync(string, string, CancellationToken)
Sends a message to the specified conversation/thread.
public Task SendMessageAsync(string conversationId, string content, CancellationToken ct = default)
Parameters
conversationIdstringcontentstringctCancellationToken
Returns
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
conversationIdstringcontentstringattachmentsIReadOnlyList<OutboundAttachment>ctCancellationToken
Returns
StartAsync(CancellationToken)
Implements IHostedService.StartAsync — starts the background queue drainer.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
StopAsync(CancellationToken)
Implements IHostedService.StopAsync.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Events
MessageReceived
Raised when a new inbound message arrives.
public event Func<ChannelMessage, Task>? MessageReceived
Event Type
Remarks
Uses Func<ChannelMessage, Task> instead of EventHandler to support async handlers.