event_manager
event_manager · Loosely coupled PostgreSQL event trigger and queue system with synchronous or asynchronous processing.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100542 | event_manager | event_manager | 0.1 | FEAT | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
event_manager version 0.1 implements loosely coupled DML-trigger processing with an event queue followed by a work queue. A work-item query turns an INSERT, UPDATE, or DELETE event into JSON parameters; an action then runs local SQL synchronously or is processed asynchronously by the separate event_manager daemon.
Core Workflow
The extension is installed by a superuser in its fixed event_manager schema. The following psql-oriented skeleton registers a synchronous local action; use the identifiers returned by \gset in the final insert:
For asynchronous processing, start the upstream service with at least one event worker and one work worker (-E 1 -W 1). Remote HTTP actions cannot run synchronously.
Important Objects
event_manager.tb_event_table: registers source tables watched by generated row triggers.event_manager.tb_event_table_work_item: associates operations, an optional when-function, a parameter-producing query, an action, and synchronous/asynchronous mode.event_manager.tb_action: stores local DML orGET,POST, andPUTHTTP actions plus static parameters.event_manager.tb_event_queueandevent_manager.tb_work_queue: hold event snapshots and executable action parameters.event_manager.tb_setting: persists extension GUC values and applies them to the current database.?pk_value?,?op?,?OLD.column?,?NEW.column?, and named session-GUC bind tokens: inject event state into work-item queries; those queries must returnjsonbaliased asparameters.
Operational Notes
The version 0.1 schema stores source primary-key values as integer, so it is not a generic queue for UUID, composite, or bigint keys. Synchronous actions execute in the triggering transaction; asynchronous actions run later and therefore have different rollback and visibility semantics. Failed queue entries are marked failed and are not retried automatically. If unlogged queues are selected during installation, crash recovery truncates them and they are not replicated.
Writes to tb_action, tb_event_table_work_item, and tb_setting can cause arbitrary SQL, outbound HTTP, trigger creation, or database-level configuration changes. Restrict those tables to trusted administrators and validate bind-token substitution because the official guide explicitly warns of SQL-injection risk. The source tree contains version 0.2 documentation and upgrade SQL, but the reviewed control default is 0.1; do not assume 0.2 configuration-manager or worker-scaling behavior until that upgrade is installed and tested.