Class: Aws::Plugins::Retries::ClockSkew Private
- Inherits:
-
Object
- Object
- Aws::Plugins::Retries::ClockSkew
- Defined in:
- lib/aws-sdk-core/plugins/retries/clock_skew.rb
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.
Constant Summary collapse
- CLOCK_SKEW_THRESHOLD =
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.
five minutes
5 * 60
Instance Method Summary collapse
-
#clock_correction(endpoint) ⇒ Object
private
Gets the clock_correction in seconds to apply to a given endpoint.
-
#clock_skewed?(context) ⇒ Boolean
private
Determines whether a request has clock skew by comparing the current time against the server’s time in the response.
-
#estimated_skew(endpoint) ⇒ Object
private
The estimated skew factors in any clock skew from the service along with any network latency.
-
#initialize ⇒ ClockSkew
constructor
private
A new instance of ClockSkew.
-
#update_clock_correction(context) ⇒ Object
private
Called only on clock skew related errors Update the stored clock skew correction value for an endpoint from the server’s time in the response.
-
#update_estimated_skew(context) ⇒ Object
private
Called for every request Update our estimated clock skew for the endpoint from the servers time in the response.
Constructor Details
#initialize ⇒ ClockSkew
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 ClockSkew.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 12 def initialize @mutex = Mutex.new # clock_corrections are recorded only on errors # and only when time difference is greater than the # CLOCK_SKEW_THRESHOLD @endpoint_clock_corrections = Hash.new(0) # estimated_skew is calculated on every request # and is used to estimate a TTL for requests @endpoint_estimated_skews = Hash.new(nil) end |
Instance Method Details
#clock_correction(endpoint) ⇒ 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.
Gets the clock_correction in seconds to apply to a given endpoint
26 27 28 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 26 def clock_correction(endpoint) @mutex.synchronize { @endpoint_clock_corrections[endpoint.to_s] } end |
#clock_skewed?(context) ⇒ Boolean
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.
Determines whether a request has clock skew by comparing the current time against the server’s time in the response
44 45 46 47 48 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 44 def clock_skewed?(context) server_time = server_time(context.http_response) !!server_time && (Time.now.utc - server_time).abs > CLOCK_SKEW_THRESHOLD end |
#estimated_skew(endpoint) ⇒ 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.
The estimated skew factors in any clock skew from the service along with any network latency. This provides a more accurate value for the ttl, which should represent when the client will stop waiting for a request. Estimated Skew should not be used to correct clock skew errors it should only be used to estimate TTL for a request
37 38 39 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 37 def estimated_skew(endpoint) @mutex.synchronize { @endpoint_estimated_skews[endpoint.to_s] } end |
#update_clock_correction(context) ⇒ 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.
Called only on clock skew related errors Update the stored clock skew correction value for an endpoint from the server’s time in the response
54 55 56 57 58 59 60 61 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 54 def update_clock_correction(context) endpoint = context.http_request.endpoint now_utc = Time.now.utc server_time = server_time(context.http_response) if server_time && (now_utc - server_time).abs > CLOCK_SKEW_THRESHOLD set_clock_correction(endpoint, server_time - now_utc) end end |
#update_estimated_skew(context) ⇒ 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.
Called for every request Update our estimated clock skew for the endpoint from the servers time in the response
67 68 69 70 71 72 73 74 75 |
# File 'lib/aws-sdk-core/plugins/retries/clock_skew.rb', line 67 def update_estimated_skew(context) endpoint = context.http_request.endpoint now_utc = Time.now.utc server_time = server_time(context.http_response) return unless server_time @mutex.synchronize do @endpoint_estimated_skews[endpoint.to_s] = server_time - now_utc end end |