toy-dynamo 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/toy/dynamo/querying.rb +16 -7
- data/lib/toy/dynamo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b009000e9ef292d89e89f980ff8696d92990f861
|
4
|
+
data.tar.gz: 29e1c1455056be654a8757834493f45c906e3ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fcef06c3655d1ad8d845616ed95b1a00d813705dd268255eb3b3109e5912fa78fc57ac715db5f505e9e9a5aa4b7be7f094acf067b9f7a3c0a01e6b37f3d1a0f
|
7
|
+
data.tar.gz: 768bef23ff4fb4cbf4298c1c9070f47ea437ff0347ddbcad253c95938c24c53e7d4c4bfa45750a9be3c21a7bca53da1ed4fac0b3af8fe879f461edce69878698
|
data/lib/toy/dynamo/querying.rb
CHANGED
@@ -4,7 +4,7 @@ module Toy
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
# Failsafe
|
7
|
-
MAX_BATCH_ITERATIONS =
|
7
|
+
MAX_BATCH_ITERATIONS = 99_999
|
8
8
|
DEFAULT_BATCH_SIZE = 100
|
9
9
|
|
10
10
|
module ClassMethods
|
@@ -77,16 +77,16 @@ module Toy
|
|
77
77
|
end
|
78
78
|
|
79
79
|
#:count=>10, :scanned_count=>10, :last_evaluated_key=>{"guid"=>{:s=>"11f82550-5c5d-11e3-9b55-d311a43114ca"}}}
|
80
|
+
# :manual_batching => true|false
|
81
|
+
# return results with last_evaluated_key instead of automatically looping through (useful to throttle or )
|
80
82
|
def scan(options={})
|
81
|
-
results = dynamo_table.scan(options)
|
82
83
|
aggregated_results = []
|
83
84
|
|
84
85
|
batch_size = options.delete(:batch) || DEFAULT_BATCH_SIZE
|
85
86
|
max_results_limit = options[:limit]
|
86
|
-
|
87
|
-
options.merge!(:limit => batch_size)
|
88
|
-
end
|
87
|
+
options[:limit] = batch_size
|
89
88
|
|
89
|
+
results = dynamo_table.scan(options)
|
90
90
|
response = Response.new(results)
|
91
91
|
|
92
92
|
results[:member].each do |result|
|
@@ -94,7 +94,7 @@ module Toy
|
|
94
94
|
aggregated_results << load(attrs[dynamo_table.hash_key[:attribute_name]], attrs)
|
95
95
|
end
|
96
96
|
|
97
|
-
if response.more_results?
|
97
|
+
if response.more_results? && !options[:manual_batching]
|
98
98
|
results_returned = response.count
|
99
99
|
batch_iteration = 0
|
100
100
|
while response.more_results? && batch_iteration < MAX_BATCH_ITERATIONS
|
@@ -116,7 +116,16 @@ module Toy
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
if options[:manual_batching]
|
120
|
+
response_hash = {
|
121
|
+
:results => aggregated_results,
|
122
|
+
:last_evaluated_key => results[:last_evaluated_key]
|
123
|
+
}
|
124
|
+
response_hash.merge!(:consumed_capacity => results[:consumed_capacity]) if results[:consumed_capacity]
|
125
|
+
response_hash
|
126
|
+
else
|
127
|
+
aggregated_results
|
128
|
+
end
|
120
129
|
end
|
121
130
|
|
122
131
|
end # ClassMethods
|
data/lib/toy/dynamo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toy-dynamo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cary Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|