2022-11-11 11:16:50 +11:00
|
|
|
import { createClient } from 'redis';
|
2025-02-24 03:48:10 +02:00
|
|
|
import { logger } from '../../logger';
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2019-05-11 19:13:41 -05:00
|
|
|
function createPublisher({ redisURL, redisOptions = {} }): any {
|
2025-02-24 03:48:10 +02:00
|
|
|
const client = createClient({ url: redisURL, ...redisOptions });
|
|
|
|
|
client.on('error', err => { logger.error('RedisPubSub Publisher client error', { error: err }) });
|
|
|
|
|
client.on('connect', () => {});
|
|
|
|
|
client.on('reconnecting', () => {});
|
|
|
|
|
client.on('ready', () => {});
|
|
|
|
|
return client;
|
2016-03-10 14:27:00 -08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 19:13:41 -05:00
|
|
|
function createSubscriber({ redisURL, redisOptions = {} }): any {
|
2025-02-24 03:48:10 +02:00
|
|
|
const client = createClient({ url: redisURL, ...redisOptions });
|
|
|
|
|
client.on('error', err => { logger.error('RedisPubSub Subscriber client error', { error: err }) });
|
|
|
|
|
client.on('connect', () => {});
|
|
|
|
|
client.on('reconnecting', () => {});
|
|
|
|
|
client.on('ready', () => {});
|
|
|
|
|
return client;
|
2016-03-10 14:27:00 -08:00
|
|
|
}
|
|
|
|
|
|
2016-10-28 12:06:35 -04:00
|
|
|
const RedisPubSub = {
|
2016-03-10 14:27:00 -08:00
|
|
|
createPublisher,
|
2018-09-01 13:58:06 -04:00
|
|
|
createSubscriber,
|
|
|
|
|
};
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
export { RedisPubSub };
|