Class: SimpleDeploy::AWS::SimpleDB
- Inherits:
-
Object
- Object
- SimpleDeploy::AWS::SimpleDB
- Includes:
- Helpers
- Defined in:
- lib/simple_deploy/aws/simpledb.rb
Instance Method Summary collapse
- #create_domain(domain) ⇒ Object
- #delete(domain, key) ⇒ Object
- #delete_items(domain, key, attributes) ⇒ Object
- #domain_exists?(domain) ⇒ Boolean
- #domains ⇒ Object
-
#initialize ⇒ SimpleDB
constructor
A new instance of SimpleDB.
- #put_attributes(domain, key, attributes, options) ⇒ Object
- #retry_options ⇒ Object
- #select(query) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize ⇒ SimpleDB
Returns a new instance of SimpleDB.
10 11 12 13 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 10 def initialize @config = SimpleDeploy.config @connect = Fog::AWS::SimpleDB.new connection_args end |
Instance Method Details
#create_domain(domain) ⇒ Object
32 33 34 35 36 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 32 def create_domain(domain) with_retries() do @connect.create_domain(domain) unless domain_exists?(domain) end end |
#delete(domain, key) ⇒ Object
62 63 64 65 66 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 62 def delete(domain, key) with_retries() do @connect.delete_attributes domain, key end end |
#delete_items(domain, key, attributes) ⇒ Object
68 69 70 71 72 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 68 def delete_items(domain, key, attributes) with_retries() do @connect.delete_attributes domain, key, attributes end end |
#domain_exists?(domain) ⇒ Boolean
28 29 30 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 28 def domain_exists?(domain) domains.include? domain end |
#domains ⇒ Object
22 23 24 25 26 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 22 def domains with_retries() do @connect.list_domains.body['Domains'] end end |
#put_attributes(domain, key, attributes, options) ⇒ Object
38 39 40 41 42 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 38 def put_attributes(domain, key, attributes, ) with_retries() do @connect.put_attributes domain, key, attributes, end end |
#retry_options ⇒ Object
15 16 17 18 19 20 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 15 def {:max_retries => 3, :rescue => Excon::Errors::ServiceUnavailable, :base_sleep_seconds => 10, :max_sleep_seconds => 60} end |
#select(query) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/simple_deploy/aws/simpledb.rb', line 44 def select(query) = { 'ConsistentRead' => true } data = {} next_token = nil while true .merge! 'NextToken' => next_token chunk = with_retries() do @connect.select(query, ).body end data.merge! chunk['Items'] next_token = chunk['NextToken'] break unless next_token end data end |