class Aws::Plugins::Retries::ClockSkew
@api private
def clock_correction(endpoint)
-
endpoint
(URI / String
) --
def clock_correction(endpoint) @mutex.synchronize { @endpoint_clock_corrections[endpoint.to_s] } end
def clock_skewed?(context)
-
context
(Seahorse::Client::RequestContext
) --
def clock_skewed?(context) server_time = server_time(context.http_response) !!server_time && (Time.now.utc - server_time).abs > CLOCK_SKEW_THRESHOLD end
def estimated_skew(endpoint)
Estimated Skew should not be used to correct clock skew errors
waiting for a request.
which should represent when the client will stop
This provides a more accurate value for the ttl,
the service along with any network latency.
The estimated skew factors in any clock skew from
def estimated_skew(endpoint) @mutex.synchronize { @endpoint_estimated_skews[endpoint.to_s] } end
def initialize
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
def server_time(response)
-
response
(Seahorse::Client::Http::Response:
) --
def server_time(response) begin Time.parse(response.headers['date']).utc rescue nil end end
def set_clock_correction(endpoint, correction)
-
correction
(Number
) -- -
endpoint
(URI / String
) --
def set_clock_correction(endpoint, correction) @mutex.synchronize do @endpoint_clock_corrections[endpoint.to_s] = correction end end
def update_clock_correction(context)
-
context
(Seahorse::Client::RequestContext
) --
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
def update_estimated_skew(context)
-
context
(Seahorse::Client::RequestContext
) --
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