class AWS::DynamoDB::Client

Client class for Amazon DynamoDB.

Constants

API_VERSION
CACHEABLE_REQUESTS

@private

REGION_US_E1

@private

TARGET_PREFIX

@private

Public Class Methods

new(*args) click to toggle source

@private

# File lib/aws/dynamo_db/client.rb, line 34
def initialize *args

  super

  # If the signer does not provide a session token, then we will
  # replace it with another signer that manages an AWS STS session.
  # This session will auto renew whenever it has expired and will
  # be shared across threads.
  if config.signer.session_token.nil?
    @signer = Core::SessionSigner.for(config) 
  end

end

Protected Instance Methods

extract_error_details(response) click to toggle source

end client methods ##

# File lib/aws/dynamo_db/client.rb, line 833
def extract_error_details response
  if response.http_response.status == 413
    ['RequestEntityTooLarge', 'Request entity too large']
  else
    super
  end
end
possible_expired_credentials?(response) click to toggle source

Returns true if we get an access denied error from the service AND our signer is capible of getting new short-term credentials

# File lib/aws/dynamo_db/client.rb, line 881
def possible_expired_credentials? response
  signer.respond_to?(:refresh_session) and
  response.error.is_a?(Errors::ExpiredTokenException)
end
rebuild_http_request(response) click to toggle source
# File lib/aws/dynamo_db/client.rb, line 851
def rebuild_http_request response
  # called when a request is going to be retried, in case of 
  # expired credentials we should refresh the session
  signer.refresh_session if possible_expired_credentials?(response)
  super
end
should_retry?(response) click to toggle source
# File lib/aws/dynamo_db/client.rb, line 841
def should_retry? response 
  if possible_expired_credentials?(response)
    true
  elsif response.error.is_a?(Errors::ProvisionedThroughputExceededException)
    config.dynamo_db_retry_throughput_errors?
  else
    super
  end
end
sleep_durations(response) click to toggle source
# File lib/aws/dynamo_db/client.rb, line 858
def sleep_durations response

  retry_count = 
    if possible_expired_credentials?(response)
      config.max_retries == 0 ? 0 : 1
    else
      config.max_retries { 10 }
    end

  # given a retry_count of 10, the sleep durations will look like:
  # 0, 50, 100, 200, 400, 800, 1600, 3200, 6400, 12800 (milliseconds)
  (0...retry_count).map do |n|
    if n == 0
      0
    else
      50 * (2 ** (n - 1)) / 1000.0
    end
  end

end