mediocregopher/radix

report back ping error from NewPool func to fail-safe the caller object

MoDa89 opened this issue · 4 comments

Hi @mediocregopher,

Is it possible if there's any future update for V3 to include error reporting to the pool's ErrCh in p.atIntervalDo(args..) method's callable for pool's PingInterval event, as below ?

371 }
372 if p.opts.pingInterval > 0 && size > 0 {
373 p.atIntervalDo(p.opts.pingInterval, func() { p.Do(Cmd(nil, "PING")) }) // if possible to be replaced with
//err := p.Do(Cmd(nil,"PING"))
// if err != nil { p.err(err) }
374 }
375 if p.opts.refillInterval > 0 && size > 0 {
376 p.atIntervalDo(p.opts.refillInterval, p.doRefill)
377 }

the thing is that I'm using radix's conn-pool as a persistent conn-object and the server I'm building is highly-dependant on redis being live and kicking. So, it would be awesome to report a ping error back to the pool's ErrCh, which I'd a place a listener for in my server to crash it whenever the pool senses that redis failed to pong.

Thank you.

Hi @MoDa89, I'm open to that change if you'd like to implement it. I think the best way would be to add a new callback to PoolTrace and then hook that up to the ping routine if it's been set.

Hi @mediocregopher,

Thank you for your response, and sorry form my late one.

I was proposing if it's ok to just call the pool's available err() method inside the (atIntervalDo)'s callable, as the condition is already set for ping action, can it be done like this?, as I don't know about tracing package and never dealt with it.

Regards.

@MoDa89 I would prefer to use tracing for this. The ErrCh mechanism is older than the tracing, and is far less precise. By using tracing people can get events only for cases they actually care about, or get none at all. You can look at how other traces within Pool work to get a feel for it, it's really quite simple from an implementation and usage perspective.

@MoDa89 I'm going to close this, feel free to re-open if you'd like to continue with the conversation.