Skip to content

Commit f800cf7

Browse files
author
zackcao
committed
[合规重试]普通接口请求支持重试策略
1 parent d06e929 commit f800cf7

File tree

11 files changed

+998
-682
lines changed

11 files changed

+998
-682
lines changed

include/cos_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const char kReqHeaderDate[] = "Date";
5151
const char kReqHeaderServer[] = "Server";
5252
const char kReqHeaderXCosReqId[] = "x-cos-request-id";
5353
const char kReqHeaderXCosTraceId[] = "x-cos-trace-id";
54+
const char kReqHeaderXCosSdkRetry[] = "x-cos-sdk-retry";
5455

5556
// Response Header
5657
const char kRespHeaderLastModified[] = "Last-Modified";

include/op/base_op.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#ifndef COS_CPP_SDK_V5_INCLUDE_OP_BASE_OP_H_
33
#define COS_CPP_SDK_V5_INCLUDE_OP_BASE_OP_H_
44

5-
#include <inttypes.h>
65
#include <stdint.h>
76

87
#include <map>
@@ -11,6 +10,7 @@
1110
#include "cos_config.h"
1211
#include "op/cos_result.h"
1312
#include "trsf/transfer_handler.h"
13+
#include "util/base_op_util.h"
1414

1515
namespace qcloud_cos {
1616

@@ -22,7 +22,7 @@ class BaseOp {
2222
/// \brief BaseOp构造函数
2323
///
2424
/// \param cos_conf Cos配置
25-
explicit BaseOp(const SharedConfig& cos_conf) : m_config(cos_conf) {}
25+
explicit BaseOp(const SharedConfig& cos_conf) : m_config(cos_conf), m_op_util(m_config) {}
2626

2727
BaseOp() {}
2828

@@ -51,12 +51,8 @@ class BaseOp {
5151

5252
bool IsDomainSameToHost() const;
5353

54-
bool UseDefaultDomain() const;
55-
5654
bool IsDefaultHost(const std::string &host) const;
5755

58-
std::string ChangeHostSuffix(const std::string &host);
59-
6056
/// \brief 封装了cos Service/Bucket/Object 相关接口的通用操作,
6157
/// 包括签名计算、请求发送、返回内容解析等
6258
///
@@ -128,6 +124,28 @@ class BaseOp {
128124
protected:
129125
bool CheckConfigValidation() const;
130126
SharedConfig m_config;
127+
BaseOpUtil m_op_util;
128+
129+
private:
130+
CosResult NormalRequest(
131+
const std::string& host, const std::string& path, const BaseReq& req,
132+
const std::map<std::string, std::string>& additional_headers,
133+
const std::map<std::string, std::string>& additional_params,
134+
const std::string& req_body, bool check_body, BaseResp* resp,
135+
const uint32_t &request_retry_num, bool is_ci_req = false);
136+
137+
CosResult DownloadRequest(const std::string& host, const std::string& path,
138+
const BaseReq& req, BaseResp* resp, std::ostream& os,
139+
const uint32_t &request_retry_num,
140+
const SharedTransferHandler& handler = nullptr);
141+
142+
CosResult UploadRequest(
143+
const std::string& host, const std::string& path, const BaseReq& req,
144+
const std::map<std::string, std::string>& additional_headers,
145+
const std::map<std::string, std::string>& additional_params,
146+
std::istream& is, BaseResp* resp, const uint32_t &request_retry_num, const SharedTransferHandler& handler = nullptr);
147+
148+
bool NoNeedRetry(const CosResult &result);
131149
};
132150

133151
} // namespace qcloud_cos

include/util/retry_util.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)