neumino / rethinkdbdash

An advanced Node.js driver for RethinkDB with a connection pool, support for streams etc.
MIT License
848 stars 109 forks source link

how to use r.getPoolMaster().on('healthy' with a rethinkdb-proxy #353

Closed mariosouto closed 6 years ago

mariosouto commented 7 years ago

Hi!

I'm using RethinkDB feeds with a NodeJS application in order to keep track on the changes in the database.

When RethinkDB goes down i use

r.getPoolMaster().on('healthy'

to keep track if RethinkDB is alive or not, and rejoin the feeds.

This works just fine. When RethinkDB goes down it emits a healthy event with the value of false and another one with the value of true when it goes up.

But now i need to use a RethinkDB-Proxy in front of my RethinkDB instance and i'm making my Node app connect to the Proxy. The problem is that when i use a Proxy and RethinkDB goes down, it's not emitting the healthy event or at least i don't get it bc i'm connected to the Proxy.

Is there a way to make the Proxy emit this event? Or to capture it from my instance? Or any other possible approach?

Hope i was clear enough

Thanks!

neumino commented 7 years ago

Hum, what happens if:

mariosouto commented 7 years ago

@neumino I'll try this out and let you know

mariosouto commented 6 years ago

@neumino Nope, it doesn't. Also it doesn't emit the healthy event 😕 . If i do this directly to the DB works like a charm but it's not the same with the proxy

neumino commented 6 years ago

Hum yea that what I thought would happen.

The healthy event is based on the connection itself. Since the connection to the proxy is always fine the driver things that everything works fine. That's a bug in how the RethinkDB proxy doesn't properly propagate the error upstream

mariosouto commented 6 years ago

I'm closing this bc seems to be more a RethinkDB issue. Thanks for the help anyway