处理 cloudant 数据库连接失败

Handle cloudant db connection failure

我正在开发后端节点应用程序,我们正在使用 "nodejs-cloudant" 模块调用 Cloudant 数据库。我遇到了间歇性问题,其中数据库出现故障并中断了流程。

所以这让我想知道是否有一种方法可以处理连接失败并在完全失败之前尝试固定次数的重试。

我在研究时发现了 "retry" 插件。但仔细想想,它只处理我们得到 HTTP 429 错误代码的场景,对应于最大尝试次数。

有办法吗?

如果需要,您可以复制 retry 插件并根据需要修改逻辑:https://github.com/cloudant/nodejs-cloudant/blob/master/plugins/retry.js#L65

更多信息:
https://github.com/cloudant/nodejs-cloudant#the-retry-plugin
https://github.com/cloudant/nodejs-cloudant#request-plugins