awful 0.0.95 → 0.0.96
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/dynamodb.rb +45 -10
- data/lib/awful/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: 20cf14fecdfbb426f917378fdb87a71c3d03b06d
|
4
|
+
data.tar.gz: 08cc9b0dc46451f3d57156272996521bcd5044ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b38dbe10ec76867dcdcad38513053d6394aabef26d46b79f15ad2a34c2513e129823a3e0096c223a247c413cae5ddeaaa2555c2c445036a85ced8be5915cffc
|
7
|
+
data.tar.gz: d0aea0c0acbe2ad27c93e55eeadd1fabe2e5fec205ce5e45294a57a651032e6c86ebac64aa881ad8082ea813a56bc9f8f67a901ebcd744b5c520589b0f5027c0
|
data/lib/awful/dynamodb.rb
CHANGED
@@ -82,18 +82,53 @@ module Awful
|
|
82
82
|
end
|
83
83
|
|
84
84
|
desc 'throughput NAME', 'get or update provisioned throughput for table NAME'
|
85
|
-
method_option :read_capacity_units, aliases: '-r', type: :numeric, default: nil,
|
86
|
-
method_option :write_capacity_units, aliases: '-w', type: :numeric, default: nil,
|
85
|
+
method_option :read_capacity_units, aliases: '-r', type: :numeric, default: nil, desc: 'Read capacity units'
|
86
|
+
method_option :write_capacity_units, aliases: '-w', type: :numeric, default: nil, desc: 'Write capacity units'
|
87
|
+
method_option :gsi, aliases: '-g', type: :array, default: [], desc: 'GSIs to update'
|
88
|
+
method_option :all, type: :boolean, default: false, desc: 'Update all GSIs for the table'
|
89
|
+
method_option :table, type: :boolean, default: true, desc: 'Update througput on table'
|
87
90
|
def throughput(name)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
table = dynamodb.describe_table(table_name: name).table
|
92
|
+
|
93
|
+
## current is hash of current provisioned throughput
|
94
|
+
current = table.provisioned_throughput.to_h
|
95
|
+
table.global_secondary_indexes.each do |gsi|
|
96
|
+
current[gsi.index_name] = gsi.provisioned_throughput.to_h
|
97
|
+
end
|
98
|
+
|
99
|
+
## if no updates requested, just print throughput and return table details
|
100
|
+
unless options[:read_capacity_units] or options[:write_capacity_units]
|
101
|
+
puts YAML.dump(stringify_keys(current))
|
102
|
+
return table
|
96
103
|
end
|
104
|
+
|
105
|
+
## parameters for update request
|
106
|
+
params = { table_name: name }
|
107
|
+
|
108
|
+
## add table throughput unless told not to
|
109
|
+
params[:provisioned_throughput] = {
|
110
|
+
read_capacity_units: options[:read_capacity_units] || current[:read_capacity_units],
|
111
|
+
write_capacity_units: options[:write_capacity_units] || current[:write_capacity_units]
|
112
|
+
} if options[:table]
|
113
|
+
|
114
|
+
## list of requested GSIs, or all for this table
|
115
|
+
gsis = options[:gsi]
|
116
|
+
gsis = table.global_secondary_indexes.map(&:index_name) if options[:all]
|
117
|
+
params[:global_secondary_index_updates] = gsis.map do |gsi|
|
118
|
+
{
|
119
|
+
update: {
|
120
|
+
index_name: gsi,
|
121
|
+
provisioned_throughput: {
|
122
|
+
read_capacity_units: options[:read_capacity_units] || current[gsi][:read_capacity_units],
|
123
|
+
write_capacity_units: options[:write_capacity_units] || current[gsi][:write_capacity_units]
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
## make the update request
|
130
|
+
params.reject! { |_,v| v.empty? } # sdk hates empty global_secondary_index_updates
|
131
|
+
dynamodb.update_table(params)
|
97
132
|
end
|
98
133
|
|
99
134
|
desc 'enable_streams NAME', 'enable/disable streams on the table'
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.96
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|