Re:PostgREST – A fully RESTful API from any existing Postgre...
by twelve40 on Sunday March 26, 2017 @02:11AM
(#13959475)
I guess this is like a lower-level version of Parse (on a different, transactional stack too). Pretty cool. I wonder though, often times I have cases that are mostly CRUD but with a little extra: e.g., "create this object and kick off a Stripe payment", or "create this object and send an MQ message". With Parse, you just write Node triggers to do that. Would I have to dig through Haskell code (or hire Haskell developers) to do the same here, or does postgrest support an easier way to do that?
[ Parent
| on HN ]
Re:PostgREST – A fully RESTful API from any existing Postgre...
by begriffs on Sunday March 26, 2017 @02:17AM
(#13959496)
You can trigger external actions by connecting PostgreSQL pubsub (LISTEN/NOTIFY) with an external job queue. https://postgrest.com/en/v0.4/intro.html#external-notificati...
A NOTIFY SQL command can be sent out from either a stored procedure or a table trigger. (The docs could use some examples of this, but that's the idea.)
Re:PostgREST – A fully RESTful API from any existing Postgre...
by gnud on Sunday March 26, 2017 @03:37AM
(#13959668)
Be aware that Postgres' NOTIFY is not stored/queued in any way. If your external client is not listening, it will get lost.
I would instead have the trigger insert a row into a "pending tasks" table - and then send a NOTIFY.
Re:PostgREST – A fully RESTful API from any existing Postgre...
by lima on Sunday March 26, 2017 @08:44AM
(#13960468)
http://debezium.io/ is a better way to do this.
It uses the logical decoding feature to get all row changes and writes them to a Kafka queue.
This means it can pick up where it left when it crashes.
Re:PostgREST – A fully RESTful API from any existing Postgre...
by ruslan_talpa on Sunday March 26, 2017 @11:58AM
(#13961386)
along the same lines https://github.com/confluentinc/bottledwater-pg
Re:PostgREST – A fully RESTful API from any existing Postgre...
by bdcravens on Sunday March 26, 2017 @02:22AM
(#13959507)
This is meant to be only a data layer; it's not a full backend. Presumably your application events are handled at a different layer in your stack.
That said, you could add event handling inside of Postgresql via triggers and one of the supported procedural languages (like PL/Python)
Re:PostgREST – A fully RESTful API from any existing Postgre...
by kornish on Sunday March 26, 2017 @02:15AM
(#13959491)
Postgres supports async notifications, so you could just write a little service which gets a message when a record changes, and put the Stripe logic there. https://postgrest.com/en/v0.4/intro.html#external-notificati...
Not as simple as Parse, I guess, but that's a tradeoff of using lower-level technology.