ApiSubscriptionManager
Manages real-time SSE subscriptions for sync API. Implements spec Section 10 (Real-Time Subscriptions). Production hardened with bounded channels and cleanup.
public sealed class ApiSubscriptionManager : IDisposable
Constructors
ApiSubscriptionManager
public ApiSubscriptionManager(ILogger<ApiSubscriptionManager> logger)
Creates a new subscription manager with auto-cleanup.
| Parameter | Type | Description |
|---|---|---|
logger |
ApiSubscriptionManager> |
Logger instance. |
Methods
Dispose()
public void Dispose()
Disposes resources including the cleanup timer.
Subscribe(string, string, string?)
public Channel<SyncLogEntry> Subscribe(string subscriptionId, string tableName, string? pkValue)
Subscribe to changes for a table (and optionally specific record). Uses BOUNDED channel to prevent memory exhaustion.
Parameters:
| Name | Type | Description |
|---|---|---|
subscriptionId |
String |
Unique subscription ID. |
tableName |
String |
Table to subscribe to. |
pkValue |
String |
Optional primary key for record-level subscription. |
Returns: SyncLogEntry> - Channel to read changes from.
Unsubscribe(string)
public void Unsubscribe(string subscriptionId)
Unsubscribe from changes.
Parameters:
| Name | Type | Description |
|---|---|---|
subscriptionId |
String |
Subscription ID to remove. |
NotifyChange(SyncLogEntryDto)
public void NotifyChange(SyncLogEntryDto entry)
Notify all matching subscriptions of a change.
Parameters:
| Name | Type | Description |
|---|---|---|
entry |
SyncLogEntryDto |
The change to notify about. |