Is there a way to listen to a special event when RethinkDB reconnects?

94 views Asked by At

I'm using a NodeJS application with a RethinkDB database.

When i start the server the application establish a connection with Rethink and it starts to listen to the changes in a table using RethinkDB feeds.

The problem is when RethinkDB goes down. Because of that the feed is interrupted, as the documentation of RethinkDB says, but when the DB is up again there's no way to reconnect to the feed. So changes are happening but i'm not just notice them because was lost somewhere.

What i was wondering, i wasn't able to find it in the docs, is if RethinkDB emits an event of some kind when it starts running again.

So my idea was to make my Node app to listen to that event and make the feed reconnect again as soon as it notice that event.

Is there an event of that kind that Rethink emits?

Thanks!

1

There are 1 answers

0
AudioBubble On BEST ANSWER

Seems that RethinkDBDash has something that it´s good enough for me.

r.getPoolMaster().on('healthy', (healthy) => ...);

The line above keeps track if there´s a healthy connection to RethinkDB or not.