-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
Motivation
Redis Client (createClient
) currently emits connect
, ready
, and end
events as per documentation
const { createClient } = require('@redis/client');
(async () => {
const client = await createClient({ name: 'myCache', url: 'redis://10.1.2.3:12345' })
.on('connect', () => console.log('Redis connected'))
.on('ready', () => console.log('Redis ready'))
.on('end', () => console.log('Redis disconnected'))
.on('error', err => console.error('Redis Error', err))
.on('reconnecting', () => console.log('Redis reconnecting'))
.connect();
console.log(`client.isOpen: ${client.isOpen}, client.isReady: ${client.isReady}`);
console.log('Get testKey', await client.get('testKey'));
client.close();
})()
Results in
Redis connected
Redis ready
client.isOpen: true, client.isReady: true
Get test key null
Redis disconnected
However, Sentinel currently does not emit any of those events
const { createSentinel } = require('@redis/client');
(async () => {
const client = await createSentinel({ name: 'myCache', sentinelRootNodes: [{ host: '10.1.2.3', port: 26379 }]})
.on('connect', .... [same as above]
Results in
client.isOpen: true, client.isReady: true
Get test key null
Only error
seems to be emitted.
I understand that "connect" and "ready" status for Sentinel might be ambiguous - is it connected to the Sentinel? and/or the node?
But Sentinel itself also have isOpen
and isReady
properties. At least, the events can track these properties.
Motivation: Application using this library can handle startup, error, and reconnect events easier
Basic Code Example
Metadata
Metadata
Assignees
Labels
No labels