Node.js 退避/重试节点JS AWS Lambda中的Elasticsearch索引
我正在使用AWS lambda中的“promise retry”节点js模块重试调用elasticsearch的.index函数来插入数据 我试图通过将客户机(从中调用.index)requestTimeout设置为1ms来测试重试。我知道这个错误是有效的,因为我可以在没有任何重试语法的情况下捕获它 我的代码如下所示,它反映了模块自述中的示例:Node.js 退避/重试节点JS AWS Lambda中的Elasticsearch索引,node.js,aws-lambda,promise,Node.js,Aws Lambda,Promise,我正在使用AWS lambda中的“promise retry”节点js模块重试调用elasticsearch的.index函数来插入数据 我试图通过将客户机(从中调用.index)requestTimeout设置为1ms来测试重试。我知道这个错误是有效的,因为我可以在没有任何重试语法的情况下捕获它 我的代码如下所示,它反映了模块自述中的示例: promiseRetry(function(retry, number) { debug("attempt " + numb
promiseRetry(function(retry, number) {
debug("attempt " + number);
return dataClient.index(indexParams)
.catch(retry);
})
.then(function(value) {
debug("the value is " + value);
}, function(error) {
debug("the error is " + error);
});
我在此设置上尝试了许多其他变体,包括:
- 将dataClient.index放入函数并在该函数中返回其值,然后在上述代码中使用该函数,而不是直接调用.index
- 如上所述,但返回一个承诺并在上述代码中使用
- 使Promisery中的函数异步,并在上面更改return为wait