[英]How to programmatically get model id from google-cloud-automl with node.js client library
[英]How to override the retry configuration for Google Cloud Tasks Node.js Client
我一直在尝试探索是否有办法重试createTask函数 。 原因是因为我不时会遇到截止日期超出错误:
错误:4 DEADLINE_EXCEEDED:Object.onReceiveStatus上的Object.exports.createStatusError(/srv/node_modules/grpc/src/common.js:91:15)截止日期超过(/srv/node_modules/grpc/src/client_interceptors.js:1204 :28)在InterceptingListener._callNext(/srv/node_modules/grpc/src/client_interceptors.js:568:42)处于InterceptingListener.onReceiveStatus(/srv/node_modules/grpc/src/client_interceptors.js:618:8)的回调中( /srv/node_modules/grpc/src/client_interceptors.js:845:24)
阅读createTask函数后面的代码,我发现默认的超时配置只有10秒。
目前,我已经尝试通过执行以下操作将超时延长到30秒(我相信这是最大值):
try {
console.log("Sending task %j", task);
const callOptions = {
timeout: 30000
};
// Send create task request.
const [response] = await client.createTask(request, callOptions);
const name = response.name;
console.log(`Created task ${name}`);
} catch (error) {
console.error("CREATE_TASK_ERROR::", error);
}
它似乎有效。 但是,如果API无法在30秒内响应,我还想了解此案例。
我试过这段代码:
try {
console.log("Sending task %j", task);
const callOptions = {
timeout: 2000, // I've set it to 2 seconds to be able to reproduce the deadline exceeded error easily
retry: {
initial_retry_delay_millis: 100,
retry_delay_multiplier: 1.3,
max_retry_delay_millis: 60000,
initial_rpc_timeout_millis: 20000,
rpc_timeout_multiplier: 1.0,
max_rpc_timeout_millis: 20000,
total_timeout_millis: 300000
}
};
// Send create task request.
const [response] = await client.createTask(request, callOptions);
const name = response.name;
console.log(`Created task ${name}`);
} catch (error) {
console.error("CREATE_TASK_ERROR::", error);
}
但我没有看到createTask正在重试。 但根据此处的评论,我们应该能够覆盖默认设置,包括重试。
我究竟做错了什么? 请帮忙。
似乎callOptions是错误的。
const callOptions = {
timeout: 2000, // I've set it to 2 seconds to be able to reproduce the deadline exceeded error easily
retry: {
backoffSettings: {
initialRetryDelayMillis: 100,
retryDelayMultiplier: 1.3,
maxRetryDelayMillis: 60000,
initialRpcTimeoutMillis: 20000,
// rpc_timeout_multiplier: 1.0, not exists
maxRpcTimeoutMillis: 20000,
totalTimeoutMillis: 300000
}
}
};
看到:
但我认为使用cli设置重试参数更好。
看到:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.