Files
talk/services/pubsub.js
T
Wyatt Johnson a2536eb41b updated pubsub
2017-08-30 09:06:48 -06:00

25 lines
498 B
JavaScript

const {RedisPubSub} = require('graphql-redis-subscriptions');
const {createClient} = require('./redis');
/**
* getClient returns the pubsub singleton for this instance.
*/
let pubsub = null;
const getClient = () => {
if (pubsub !== null) {
return pubsub;
}
// Create the new PubSub client, we only need one per instance of Talk.
pubsub = new RedisPubSub({
publisher: createClient(),
subscriber: createClient(),
});
return pubsub;
};
module.exports = {
getClient,
};