This will use postgres NOTIFY/LISTEN for pubsub.
The admin server will publish an event on a specific channel whenever any resources are changed.
The graphql server (all instances of it that are running e.g. if horizontally scaled) will subscribe to the same channel and reload the schema/resolvers whenever the config for them was changed in the admin ui.
See architecture for an overview of the components at play for this https://docs.google.com/drawings/d/1OmMY1bbI8HDhlZ_cIirv7FYTEqRRV-Hh-g0ANtYEgBY/edit
NOTE: There should be a pubsub layer, with a well defined interfact, that wraps the relevant nodejs lib (e.g. https://github.com/voxpelli/node-pg-pubsub), rather than calling the lib directly. This is to faciliate a potential change to another pubsub/message broker in future if scalability concerns are founded.
More info on how to do the 'NOTIFY' bit using a TRIGGER at the postgres layer, rather than at the node.js layer. https://coussej.github.io/2015/09/15/Listening-to-generic-JSON-notifications-from-PostgreSQL-in-Go/ |
|