CatalogStorage
PostgreSQL Work Signal
- ID:
storage.postgresql.work-signal - Summary: Processor wake-up mechanism based on PostgreSQL
LISTENandNOTIFY, with poll fallback.
Interface and Methods
| Type | Methods |
|---|---|
PostgreSqlWorkSignal | WaitForWorkOrDelayAsync, DisposeAsync |
| Inbox and outbox PostgreSQL stores | append paths trigger NOTIFY through table insert trigger |
SQL and Trigger Behavior
- Inbox and outbox v1 create scripts define:
- per-table notify function (
insert_notify_fn) - after-insert trigger (
insert_notify_trg)
- per-table notify function (
- Trigger payload is empty; event is wake-only and does not carry message data.
- If notifications are missed, processors still run on the configured poll interval.
Concurrency and Reliability
- A dedicated listener connection is opened for each work signal instance.
- Listener loop catches Npgsql and generic runtime failures, invalidates connection, then reconnects.
- Reconnect backoff is one second in
PostgreSqlWorkSignal. - Notification delivery improves wake latency but does not change correctness rules.
Index Interaction
- No dedicated index is tied to work signal.
- Processor claim performance still depends on lease index on each store table.
Observability
- No dedicated work-signal meter exists.
- Observable effect appears in processor and queue-depth metrics:
litebus.inbox.processor.statelitebus.outbox.processor.statelitebus.inbox.processor.leases_acquiredlitebus.outbox.processor.leases_acquired
- Queue-depth gauges update after diagnostics scans, not at notification time.
Test Coverage
LiteBus.Storage.IntegrationTests (PostgreSql/)
PostgreSqlInboxWorkSignalNotifyTestsandPostgreSqlOutboxWorkSignalNotifyTests: wake before poll timeout on row insert.PostgreSqlInboxWorkSignalTestsandPostgreSqlOutboxWorkSignalTests: listener reconnection after forced break.PostgreSqlInboxHostingIntegrationTests: end-to-end host wake behavior through processor background service.
LiteBus.Storage.UnitTests
- Work signal is mostly covered through integration tests; shared retry/connection behavior is indirectly exercised by PostgreSQL utility tests.