mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 03:21:58 +08:00
25 lines
498 B
JavaScript
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,
|
|
};
|