Azure Storage NodeJS 修改默认超时设置
Azure Storage NodeJS modify default timeout settings
我想知道我是否可以更改 Azure Storage BlobService 的默认超时设置。从文档中我可以看到默认设置是:
获取 blob、获取页面范围或获取阻止列表的调用允许每兆字节 2 分钟完成。如果一个操作平均每兆字节花费的时间超过 2 分钟,它将超时。
写入 blob、块或页面的调用允许每兆字节 10 分钟完成。如果一个操作平均每兆字节花费的时间超过 10 分钟,它将超时。
查看源代码,我看到 BlobService.getServiceProperties 和 setServiceProperties 列出了这两个参数:
- @param {int} [options.timeoutIntervalInMs] 用于请求的服务器超时间隔,以毫秒为单位。
- @param {int} [options.maximumExecutionTimeInMs] 发出此请求时使用的所有可能重试的最长执行时间(以毫秒为单位)。最大执行时间间隔从客户端开始构建请求的时间开始。在执行请求时和执行重试之前间歇性地检查最大执行时间。
这两个参数是否等于上面的项目?
现在,当我尝试使用以下代码使用 getServiceProperties 时,除了日志记录、指标和 cors 数据外,我没有得到任何信息。 Github 页面
上说的是什么
blobSvc.getServiceProperties(function(error, result, response) {
if (!error) {
console.log('Result: ', result);
console.log('Response: ', response);
} else {
console.log(error);
}
});
Result: { Logging:
{ Version: '1.0',
Delete: false,
Read: false,
Write: false,
RetentionPolicy: { Enabled: false } },
HourMetrics:
{ Version: '1.0',
Enabled: true,
IncludeAPIs: true,
RetentionPolicy: { Enabled: true, Days: 7 } },
MinuteMetrics:
{ Version: '1.0',
Enabled: false,
RetentionPolicy: { Enabled: false } },
Cors: {} }
Response: { isSuccessful: true,
statusCode: 200,
body:
{ StorageServiceProperties:
{ Logging: [Object],
HourMetrics: [Object],
MinuteMetrics: [Object],
Cors: '' } },
headers:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/xml',
server: 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0',
'x-ms-request-id': '45a3cfeb-0001-0127-0cf7-0149a8000000',
'x-ms-version': '2015-02-21',
date: 'Thu, 08 Oct 2015 18:32:36 GMT',
connection: 'close' },
md5: undefined }
所以我想我真的对文档之间的不匹配以及是否有可能修改任何超时设置感到困惑。
超时设置不是 'properties associated with the service',而是 'properties associated with a call to the Storage Library'。 timeoutIntervalInMs 设置和 maximumExecutionTimeInMs 设置是您可以在 'options' 对象上设置的参数,几乎每个操作(包括上传和下载 blob)都可以传入。因此,如果您想修改给定操作的超时,只需在调用库时在 'options' 对象上传递所需的设置即可。
'timeoutIntervalInMs' 是发送到 Azure 存储服务的请求中的超时。这是服务在超时前尝试完成请求所花费的时间。这是您在此处提到的文档中的设置 -
https://msdn.microsoft.com/en-us/library/azure/dd179431.aspx
如果对存储客户端的调用向存储服务发出多个 HTTP(S) 请求,则每次调用都会传递此值。
'maximumExecutionTimeInMs' 是客户端超时。这是由存储客户端在单个 API 调用发出的所有存储请求中跟踪的。例如,如果您在客户端中配置了重试,则在每次可能的重试之前都会检查此值,如果自第一个请求开始以来已经超过 'maximumExecutionTimeInMs',则不会继续重试。
希望这是有道理的。
带有超时选项的示例调用是:
var options = { maximumExecutionTimeInMs: 1000 };
blobSvc.createBlockBlobFromLocalFile('mycontainer', 'myblob', 'test.txt', options, function(error, result, response) {
if(!error) {
// file uploaded
}
});
您可能还想在以下网址查看 API 及其选项:http://azure.github.io/azure-storage-node/BlobService.html
我想知道我是否可以更改 Azure Storage BlobService 的默认超时设置。从文档中我可以看到默认设置是:
获取 blob、获取页面范围或获取阻止列表的调用允许每兆字节 2 分钟完成。如果一个操作平均每兆字节花费的时间超过 2 分钟,它将超时。
写入 blob、块或页面的调用允许每兆字节 10 分钟完成。如果一个操作平均每兆字节花费的时间超过 10 分钟,它将超时。
查看源代码,我看到 BlobService.getServiceProperties 和 setServiceProperties 列出了这两个参数:
- @param {int} [options.timeoutIntervalInMs] 用于请求的服务器超时间隔,以毫秒为单位。
- @param {int} [options.maximumExecutionTimeInMs] 发出此请求时使用的所有可能重试的最长执行时间(以毫秒为单位)。最大执行时间间隔从客户端开始构建请求的时间开始。在执行请求时和执行重试之前间歇性地检查最大执行时间。
这两个参数是否等于上面的项目?
现在,当我尝试使用以下代码使用 getServiceProperties 时,除了日志记录、指标和 cors 数据外,我没有得到任何信息。 Github 页面
上说的是什么blobSvc.getServiceProperties(function(error, result, response) {
if (!error) {
console.log('Result: ', result);
console.log('Response: ', response);
} else {
console.log(error);
}
});
Result: { Logging:
{ Version: '1.0',
Delete: false,
Read: false,
Write: false,
RetentionPolicy: { Enabled: false } },
HourMetrics:
{ Version: '1.0',
Enabled: true,
IncludeAPIs: true,
RetentionPolicy: { Enabled: true, Days: 7 } },
MinuteMetrics:
{ Version: '1.0',
Enabled: false,
RetentionPolicy: { Enabled: false } },
Cors: {} }
Response: { isSuccessful: true,
statusCode: 200,
body:
{ StorageServiceProperties:
{ Logging: [Object],
HourMetrics: [Object],
MinuteMetrics: [Object],
Cors: '' } },
headers:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/xml',
server: 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0',
'x-ms-request-id': '45a3cfeb-0001-0127-0cf7-0149a8000000',
'x-ms-version': '2015-02-21',
date: 'Thu, 08 Oct 2015 18:32:36 GMT',
connection: 'close' },
md5: undefined }
所以我想我真的对文档之间的不匹配以及是否有可能修改任何超时设置感到困惑。
超时设置不是 'properties associated with the service',而是 'properties associated with a call to the Storage Library'。 timeoutIntervalInMs 设置和 maximumExecutionTimeInMs 设置是您可以在 'options' 对象上设置的参数,几乎每个操作(包括上传和下载 blob)都可以传入。因此,如果您想修改给定操作的超时,只需在调用库时在 'options' 对象上传递所需的设置即可。
'timeoutIntervalInMs' 是发送到 Azure 存储服务的请求中的超时。这是服务在超时前尝试完成请求所花费的时间。这是您在此处提到的文档中的设置 - https://msdn.microsoft.com/en-us/library/azure/dd179431.aspx 如果对存储客户端的调用向存储服务发出多个 HTTP(S) 请求,则每次调用都会传递此值。
'maximumExecutionTimeInMs' 是客户端超时。这是由存储客户端在单个 API 调用发出的所有存储请求中跟踪的。例如,如果您在客户端中配置了重试,则在每次可能的重试之前都会检查此值,如果自第一个请求开始以来已经超过 'maximumExecutionTimeInMs',则不会继续重试。
希望这是有道理的。
带有超时选项的示例调用是:
var options = { maximumExecutionTimeInMs: 1000 };
blobSvc.createBlockBlobFromLocalFile('mycontainer', 'myblob', 'test.txt', options, function(error, result, response) {
if(!error) {
// file uploaded
}
});
您可能还想在以下网址查看 API 及其选项:http://azure.github.io/azure-storage-node/BlobService.html