Class: Aws::Plugins::Retries::RetryQuota Private
- Inherits:
-
Object
- Object
- Aws::Plugins::Retries::RetryQuota
- Defined in:
- lib/aws-sdk-core/plugins/retries/retry_quota.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Used in ‘standard’ and ‘adaptive’ retry modes.
Constant Summary collapse
- INITIAL_RETRY_TOKENS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
500- RETRY_COST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
14- LEGACY_RETRY_COST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
TODO: Remove when new retries become default
5- NO_RETRY_INCREMENT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1- THROTTLING_RETRY_COST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5- TIMEOUT_RETRY_COST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
TODO: Remove when new retries become default
10
Instance Method Summary collapse
-
#checkout_capacity(error_inspector) ⇒ Integer
private
check if there is sufficient capacity to retry and return it.
-
#initialize(opts = {}) ⇒ RetryQuota
constructor
private
A new instance of RetryQuota.
-
#release(capacity_amount) ⇒ Object
private
capacity_amount refers to the amount of capacity requested from the last retry.
Constructor Details
#initialize(opts = {}) ⇒ RetryQuota
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RetryQuota.
17 18 19 20 21 |
# File 'lib/aws-sdk-core/plugins/retries/retry_quota.rb', line 17 def initialize(opts = {}) @mutex = Mutex.new @max_capacity = opts.fetch(:max_capacity, INITIAL_RETRY_TOKENS) @available_capacity = @max_capacity end |
Instance Method Details
#checkout_capacity(error_inspector) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
check if there is sufficient capacity to retry and return it. If there is insufficient capacity return 0
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/aws-sdk-core/plugins/retries/retry_quota.rb', line 27 def checkout_capacity(error_inspector) @mutex.synchronize do # TODO: Remove gate and keep only the new_retries branch capacity_amount = if RetryErrors.new_retries? error_inspector.throttling_error? ? THROTTLING_RETRY_COST : RETRY_COST else error_inspector.networking? ? TIMEOUT_RETRY_COST : LEGACY_RETRY_COST end # unable to acquire capacity return 0 if capacity_amount > @available_capacity @available_capacity -= capacity_amount capacity_amount end end |
#release(capacity_amount) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
capacity_amount refers to the amount of capacity requested from the last retry. It can either be RETRY_COST, THROTTLING_RETRY_COST/TIMEOUT_RETRY_COST, or unset.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aws-sdk-core/plugins/retries/retry_quota.rb', line 47 def release(capacity_amount) # Implementation note: The release() method is called for # every API call. In the common case where the request is # successful and we're at full capacity, we can avoid locking. # We can't exceed max capacity so there's no work we have to do. return if @available_capacity == @max_capacity @mutex.synchronize do @available_capacity += capacity_amount || NO_RETRY_INCREMENT @available_capacity = [@available_capacity, @max_capacity].min end end |