5 ms·
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 m
by twelve40 10y ago
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?
- kornish 10y agoPostgres 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-notification 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.
- begriffs 10y agoYou can trigger external actions by connecting PostgreSQL pubsub (LISTEN/NOTIFY) with an external job queue. https://postgrest.com/en/v0.4/intro.html#external-notification 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.)
- gnud 10y agoBe 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.
- lima 10y agohttp://debezium.io/ 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.
- ruslan_talpa 10y agoalong the same lines https://github.com/confluentinc/bottledwater-pg https://github.com/confluentinc/bottledwater-pg
- bdcravens 10y agoThis 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)