Skip to content

Simplify code to use pgsql-http requests directly, instead of pg_notify#14

Merged
spwoodcock merged 2 commits intomainfrom
feat/pgsql-http
Dec 17, 2025
Merged

Simplify code to use pgsql-http requests directly, instead of pg_notify#14
spwoodcock merged 2 commits intomainfrom
feat/pgsql-http

Conversation

@spwoodcock
Copy link
Copy Markdown
Member

@spwoodcock spwoodcock commented Dec 17, 2025

Fixes #13 Fixes #2 Fixes #7 Fixes #9 Fixes #3
Closes #12
Also used as an alternative to #1

First off, huge thanks to @BrunoXIII-Gav who got the ball rolling for this PR.
I incorporated his fix for the duplicate webhook calls to fix #7 - thank you for that!

This PR

As described in the issue:

Currently

We are using a pg_notify and listener combo.

  1. Audit event occurs
  2. Db scanner sees this and triggers a pg_notify
  3. Notify passes through event info
  4. The Go listener receives event info and sends data to webhook via URL via http request.

Changed

To a simply http-request-from-db approach.

  • Very little Go code now. Its mostly just present as a CLI to install and uninstall triggers from the db.
  • Triggers in the db are present for the audits table.
  • We filter the event types with configured webhook endpoints (as we do currently).
  • The main change is that we make the http request directly from the database, instead of sending the data to the Go code for sending.

This significantly simplifies code and maintainability.

Using the pgsql-http extension

  • It's not included by default in postgres.
  • To install on Debian, it's as simple as apt install postgresql-14-http, changing the version as needed.
  • In the readme I link to some pre-built container images that simply extend postgres v14-v18 and add in this extension. Feel free to replace your current image with these if needed, else do a custom build.

@spwoodcock
Copy link
Copy Markdown
Member Author

@renatocava @JoacoG @BrunoXIII-Gav hopefully this solves any issues you may have been having with an entirely different approach.

Please feel free to test this out and provide feedback 🙏 Any contribution is also really welcome, as I probably need to drop working on this for a few months as I have many other high priority projects right now. Thanks!

@spwoodcock spwoodcock merged commit 9bb2576 into main Dec 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment