Method: Aws::SdbInterface#initialize

Defined in:
lib/sdb/sdb_interface.rb

#initialize(aws_access_key_id = nil, aws_secret_access_key = nil, params = {}) ⇒ SdbInterface

Creates new RightSdb instance.

Params:

{ :server       => 'sdb.amazonaws.com'  # Amazon service host: 'sdb.amazonaws.com'(default)
  :port         => 443                  # Amazon service port: 80(default) or 443
  :protocol     => 'https'              # Amazon service protocol: 'http'(default) or 'https'
  :signature_version => '2'             # The signature version : '0', '1' or '2' (default)
  DEPRECATED :multi_thread => true|false           # Multi-threaded (connection per each thread): true or false(default)
  :connection_mode  => :default         # options are :default (will use best known option, may change in the future)
                                              :per_request (opens and closes a connection on every request to SDB)
                                              :single - one connection shared across app (same as old multi_thread=>false)
                                              :per_thread - one connection per ruby thread (same as old multi_thread=>true)
                                              :pool (uses a connection pool with a maximum number of connections - NOT IMPLEMENTED YET)
  :logger       => Logger Object        # Logger instance: logs to STDOUT if omitted
  :nil_representation => 'mynil'}       # interpret Ruby nil as this string value; i.e. use this string in SDB to represent Ruby nils (default is the string 'nil')
  :service      => '/'                   # Set this to /mdb/request.mgwsi for usage with M/DB #

Example:

sdb = Aws::SdbInterface.new('1E3GDYEOGFJPIT7XXXXXX','hgTHt68JY07JKUY08ftHYtERkjgtfERn57XXXXXX', {:connection_mode => :per_request, :logger => Logger.new('/tmp/x.log')}) #=> #<RightSdb:0xa6b8c27c>

see: docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sdb/sdb_interface.rb', line 80

def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
  @nil_rep = params[:nil_representation] ? params[:nil_representation] : DEFAULT_NIL_REPRESENTATION
  params.delete(:nil_representation)
  init({:name             => 'SDB',
        :default_host     => ENV['SDB_URL'] ? URI.parse(ENV['SDB_URL']).host : DEFAULT_HOST,
        :default_port     => ENV['SDB_URL'] ? URI.parse(ENV['SDB_URL']).port : DEFAULT_PORT,
        :default_protocol => ENV['SDB_URL'] ? URI.parse(ENV['SDB_URL']).scheme : DEFAULT_PROTOCOL,
        :default_service  => ENV['SDB_URL'] ? URI.parse(ENV['SDB_URL']).path : DEFAULT_SERVICE},
       #             :service_endpoint => ENV['SDB_URL'] ? URI.parse(ENV['SDB_URL']).path   : DEFAULT_ENDPOINT },
       aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'],
       aws_secret_access_key || ENV['AWS_SECRET_ACCESS_KEY'],
       params)
end