AWS SDK for C++  1.9.2
AWS SDK for C++
RetryStrategy.h
Go to the documentation of this file.
1 
6 #pragma once
7 
10 #include <memory>
11 
12 namespace Aws
13 {
14  namespace Http
15  {
16  class HttpResponse;
17  }
18 
19  namespace Utils
20  {
21  template<typename R, typename E>
22  class Outcome;
23  }
24 
25  namespace Client
26  {
27  enum class CoreErrors;
28  template<typename ERROR_TYPE>
29  class AWSError;
30 
31  typedef Utils::Outcome<std::shared_ptr<Aws::Http::HttpResponse>, AWSError<CoreErrors>> HttpResponseOutcome;
32 
37  {
38  public:
39  virtual ~RetryStrategy() = default;
43  virtual bool ShouldRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const = 0;
44 
48  virtual long CalculateDelayBeforeNextRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const = 0;
49 
54  virtual long GetMaxAttempts() const { return 0; }
55 
59  virtual void GetSendToken() {}
60 
64  virtual void RequestBookkeeping(const HttpResponseOutcome& /* httpResponseOutcome */) {}
65  virtual void RequestBookkeeping(const HttpResponseOutcome& /* httpResponseOutcome */, const AWSError<CoreErrors>& /* lastError */) {}
66  };
67 
75  {
76  public:
77  virtual ~RetryQuotaContainer() = default;
78  virtual bool AcquireRetryQuota(int capacityAmount) = 0;
79  virtual bool AcquireRetryQuota(const AWSError<CoreErrors>& error) = 0;
80  virtual void ReleaseRetryQuota(int capacityAmount) = 0;
81  virtual void ReleaseRetryQuota(const AWSError<CoreErrors>& lastError) = 0;
82  virtual int GetRetryQuota() const = 0;
83  };
84 
86  {
87  public:
89  virtual ~DefaultRetryQuotaContainer() = default;
90  virtual bool AcquireRetryQuota(int capacityAmount) override;
91  virtual bool AcquireRetryQuota(const AWSError<CoreErrors>& error) override;
92  virtual void ReleaseRetryQuota(int capacityAmount) override;
93  virtual void ReleaseRetryQuota(const AWSError<CoreErrors>& lastError) override;
94  virtual int GetRetryQuota() const override { return m_retryQuota; }
95 
96  protected:
99  };
100 
102  {
103  public:
104  StandardRetryStrategy(long maxAttempts = 3);
105  StandardRetryStrategy(std::shared_ptr<RetryQuotaContainer> retryQuotaContainer, long maxAttempts = 3);
106 
107  virtual void RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome) override;
108  virtual void RequestBookkeeping(const HttpResponseOutcome& httpResponseOutcome, const AWSError<CoreErrors>& lastError) override;
109 
110  virtual bool ShouldRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const override;
111 
112  virtual long CalculateDelayBeforeNextRetry(const AWSError<CoreErrors>& error, long attemptedRetries) const override;
113 
114  virtual long GetMaxAttempts() const override { return m_maxAttempts; }
115 
116  protected:
117  std::shared_ptr<RetryQuotaContainer> m_retryQuotaContainer;
119  };
120  } // namespace Client
121 } // namespace Aws
Aws::Client::RetryStrategy::GetMaxAttempts
virtual long GetMaxAttempts() const
Definition: RetryStrategy.h:54
Aws::DirectoryService::Model::LDAPSType::NOT_SET
@ NOT_SET
Aws::Client::DefaultRetryQuotaContainer::m_retryQuotaLock
Aws::Utils::Threading::ReaderWriterLock m_retryQuotaLock
Definition: RetryStrategy.h:97
Aws::Client::RetryStrategy::ShouldRetry
virtual bool ShouldRetry(const AWSError< CoreErrors > &error, long attemptedRetries) const =0
Aws::Client::DefaultRetryQuotaContainer::ReleaseRetryQuota
virtual void ReleaseRetryQuota(int capacityAmount) override
AWS_CORE_API
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25
Aws::Client::CoreErrors
CoreErrors
Definition: CoreErrors.h:21
Aws::Client::StandardRetryStrategy::GetMaxAttempts
virtual long GetMaxAttempts() const override
Definition: RetryStrategy.h:114
Aws::Client::StandardRetryStrategy::StandardRetryStrategy
StandardRetryStrategy(std::shared_ptr< RetryQuotaContainer > retryQuotaContainer, long maxAttempts=3)
Aws::Client::DefaultRetryQuotaContainer::GetRetryQuota
virtual int GetRetryQuota() const override
Definition: RetryStrategy.h:94
Aws::Client::StandardRetryStrategy
Definition: RetryStrategy.h:102
Aws::Client::StandardRetryStrategy::m_maxAttempts
long m_maxAttempts
Definition: RetryStrategy.h:118
Aws::Client::DefaultRetryQuotaContainer::m_retryQuota
int m_retryQuota
Definition: RetryStrategy.h:98
Aws::Client::DefaultRetryQuotaContainer::~DefaultRetryQuotaContainer
virtual ~DefaultRetryQuotaContainer()=default
Aws::Client::DefaultRetryQuotaContainer
Definition: RetryStrategy.h:86
Aws::Client::DefaultRetryQuotaContainer::DefaultRetryQuotaContainer
DefaultRetryQuotaContainer()
Aws::Client::RetryStrategy
Definition: RetryStrategy.h:37
ReaderWriterLock.h
Aws::Client::RetryQuotaContainer::AcquireRetryQuota
virtual bool AcquireRetryQuota(const AWSError< CoreErrors > &error)=0
Aws::Client::StandardRetryStrategy::CalculateDelayBeforeNextRetry
virtual long CalculateDelayBeforeNextRetry(const AWSError< CoreErrors > &error, long attemptedRetries) const override
Aws::Client::RetryQuotaContainer::GetRetryQuota
virtual int GetRetryQuota() const =0
Aws::Client::RetryStrategy::GetSendToken
virtual void GetSendToken()
Definition: RetryStrategy.h:59
Aws::Client::RetryQuotaContainer::ReleaseRetryQuota
virtual void ReleaseRetryQuota(int capacityAmount)=0
Aws::Client::AWSError
Definition: AWSError.h:42
Aws::Utils::Threading::ReaderWriterLock
Definition: ReaderWriterLock.h:26
Aws::Client::StandardRetryStrategy::RequestBookkeeping
virtual void RequestBookkeeping(const HttpResponseOutcome &httpResponseOutcome) override
Aws::Client::DefaultRetryQuotaContainer::AcquireRetryQuota
virtual bool AcquireRetryQuota(const AWSError< CoreErrors > &error) override
Aws::Client::RetryStrategy::~RetryStrategy
virtual ~RetryStrategy()=default
Core_EXPORTS.h
Aws::Client::StandardRetryStrategy::ShouldRetry
virtual bool ShouldRetry(const AWSError< CoreErrors > &error, long attemptedRetries) const override
Aws::Client::RetryQuotaContainer::AcquireRetryQuota
virtual bool AcquireRetryQuota(int capacityAmount)=0
Aws::Client::StandardRetryStrategy::RequestBookkeeping
virtual void RequestBookkeeping(const HttpResponseOutcome &httpResponseOutcome, const AWSError< CoreErrors > &lastError) override
Aws
Definition: AccessManagementClient.h:15
Aws::Client::DefaultRetryQuotaContainer::ReleaseRetryQuota
virtual void ReleaseRetryQuota(const AWSError< CoreErrors > &lastError) override
Aws::Client::DefaultRetryQuotaContainer::AcquireRetryQuota
virtual bool AcquireRetryQuota(int capacityAmount) override
Aws::Utils::Outcome
Definition: Outcome.h:26
Aws::Client::RetryStrategy::RequestBookkeeping
virtual void RequestBookkeeping(const HttpResponseOutcome &, const AWSError< CoreErrors > &)
Definition: RetryStrategy.h:65
Aws::Client::RetryStrategy::RequestBookkeeping
virtual void RequestBookkeeping(const HttpResponseOutcome &)
Definition: RetryStrategy.h:64
Aws::Client::RetryStrategy::CalculateDelayBeforeNextRetry
virtual long CalculateDelayBeforeNextRetry(const AWSError< CoreErrors > &error, long attemptedRetries) const =0
Aws::Client::RetryQuotaContainer
Definition: RetryStrategy.h:75
Aws::Client::RetryQuotaContainer::ReleaseRetryQuota
virtual void ReleaseRetryQuota(const AWSError< CoreErrors > &lastError)=0
Aws::Client::RetryQuotaContainer::~RetryQuotaContainer
virtual ~RetryQuotaContainer()=default
Aws::Client::HttpResponseOutcome
Utils::Outcome< std::shared_ptr< Aws::Http::HttpResponse >, AWSError< CoreErrors > > HttpResponseOutcome
Definition: AWSClient.h:77
Aws::Client::StandardRetryStrategy::m_retryQuotaContainer
std::shared_ptr< RetryQuotaContainer > m_retryQuotaContainer
Definition: RetryStrategy.h:117
Aws::Client::StandardRetryStrategy::StandardRetryStrategy
StandardRetryStrategy(long maxAttempts=3)