Return error 503 if RethinkDB is down when built as RethinkDB-based controller.

This commit is contained in:
Adam Ierymenko 2018-07-11 10:42:31 -07:00
commit f94aea8119
6 changed files with 20 additions and 12 deletions

View file

@ -263,9 +263,13 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Identity &myId,co
std::unique_ptr<R::Connection> rdb;
while (_run == 1) {
try {
if (!rdb)
if (!rdb) {
_connected = 0;
rdb = R::connect(this->_host,this->_port,this->_auth);
}
if (rdb) {
_connected = 1;
R::Array batch;
R::Object tmpobj;
@ -434,6 +438,11 @@ bool RethinkDB::waitForReady()
return true;
}
bool RethinkDB::isReady()
{
return ((_ready)&&(_connected));
}
void RethinkDB::save(nlohmann::json *orig,nlohmann::json &record)
{
if (!record.is_object()) // sanity check