Create small Postgres NOTIFY/LISTEN webhook service for ODK Central #1841
Labels
backend
Related to backend code
effort:medium
Likely a day or two
enhancement
New feature or request
ODK
Any requests for optimizing ODK
priority:high
Should be addressed as a priority
Milestone
Is your feature request related to a problem? Please describe.
odk_entities
with fieldsentity_id
andstatus
.To achieve notifications that the submission was made in ODK we have three options:
I will describe the middleware based approach below.
Describe the solution you'd like
Short term solution:
/statuses
endpoint to retrieve the entities.Long term solution:
entity_def
table in the ODK Central database:Example:
data
column to our listening Golang service./projects/ID/update-entites
. It will receive the Entity ID and status fields, then update the status in the FMTM database.Blogs about simple LISTEN / NOTIFY service in Golang:
https://brojonat.com/posts/go-postgres-listen-notify/
https://ds0nt.com/postgres-streaming-listen-notify-go
https://brandur.org/notifier
It's also useful to take notes from the psycopg implementation of this: https://www.psycopg.org/psycopg3/docs/advanced/async.html#detecting-disconnections
While it could be nice to implement a more generic pub/sub server like this https://blog.geomusings.com/2023/07/13/a-simple-webhook-interface-for-notify/, I think it's overkill.
We can deploy the very small single Go binary alongside the ODK Central deployment in the compose stack & it will trigger a webhook call whenever an Entity is updated / on submission.
Alternatives
The text was updated successfully, but these errors were encountered: