dyna 0.2.0 → 0.2.1.beta1
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/README.md +5 -0
- data/lib/dyna/dsl/table.rb +11 -0
- data/lib/dyna/version.rb +1 -1
- data/lib/dyna/wrapper/dynamo_db_wrapper.rb +1 -0
- data/lib/dyna/wrapper/table.rb +45 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 669330ed5cbadd2aea1b3e817c75ba8722b4f748263e46f2fd34646f0f845077
|
4
|
+
data.tar.gz: 6c7328927257bb47470f73d0ea1321f862d51e78b288c63cb116adb5e9255e42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33231b298694a199242a453677490991888e52bf34e4e117224c052a00a014b0858b9105affa7bc1ebd8d14d93345fa226bef4eb7e1e555205ec54bdc7679396
|
7
|
+
data.tar.gz: b196f73160cc775568cf8ee6b75973ebeea8d65629312bf14566c2502ba9e72f11ce8f70059ba85d0a4cc91071dfa1841cbc7cd87635f6a891095df58dedf0bb
|
data/README.md
CHANGED
data/lib/dyna/dsl/table.rb
CHANGED
@@ -13,6 +13,10 @@ module Dyna
|
|
13
13
|
:table_name => table_name,
|
14
14
|
:scalable_targets => [],
|
15
15
|
:scaling_policies => [],
|
16
|
+
:time_to_live_specification => {
|
17
|
+
enabled: false,
|
18
|
+
attribute_name: nil,
|
19
|
+
}
|
16
20
|
})
|
17
21
|
instance_eval(&block)
|
18
22
|
end
|
@@ -100,6 +104,13 @@ module Dyna
|
|
100
104
|
}
|
101
105
|
end
|
102
106
|
|
107
|
+
def time_to_live_specification(enabled:, attribute_name:)
|
108
|
+
@result.time_to_live_specification = {
|
109
|
+
enabled: enabled,
|
110
|
+
attribute_name: attribute_name,
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
103
114
|
class LocalSecondaryIndex
|
104
115
|
attr_accessor :result
|
105
116
|
|
data/lib/dyna/version.rb
CHANGED
data/lib/dyna/wrapper/table.rb
CHANGED
@@ -31,6 +31,9 @@ module Dyna
|
|
31
31
|
wait_until_table_is_active
|
32
32
|
update_stream_specification(dsl_stream_specification(dsl))
|
33
33
|
end
|
34
|
+
unless time_to_live_eql?(dsl)
|
35
|
+
update_time_to_live(dsl)
|
36
|
+
end
|
34
37
|
unless auto_scaling_eql?(dsl)
|
35
38
|
update_auto_scaling(dsl)
|
36
39
|
end
|
@@ -65,6 +68,23 @@ module Dyna
|
|
65
68
|
end
|
66
69
|
|
67
70
|
private
|
71
|
+
|
72
|
+
def aws_time_to_live
|
73
|
+
@ttl ||= @ddb.describe_time_to_live(table_name: @table.table_name).time_to_live_description
|
74
|
+
end
|
75
|
+
|
76
|
+
def time_to_live_eql?(dsl)
|
77
|
+
wait_until_table_is_active
|
78
|
+
ttl = aws_time_to_live
|
79
|
+
unless %w/ENABLED DISABLED/.include?(ttl.time_to_live_status)
|
80
|
+
raise "time to live status is #{ttl.time_to_live_status} and must be ENABLED or DISABLED to apply"
|
81
|
+
end
|
82
|
+
same_status = dsl.time_to_live_specification.enabled.to_s == 'false' && ttl.time_to_live_status == 'DISABLED' || dsl.time_to_live_specification.enabled.to_s == 'true' && ttl.time_to_live_status == 'ENABLED'
|
83
|
+
same_name = dsl.time_to_live_specification.attribute_name.to_s == ttl.attribute_name
|
84
|
+
|
85
|
+
same_status && same_name
|
86
|
+
end
|
87
|
+
|
68
88
|
def auto_scaling_eql?(dsl)
|
69
89
|
scalable_targets_eql?(dsl) && scaling_policies_eql?(dsl)
|
70
90
|
end
|
@@ -302,6 +322,31 @@ module Dyna
|
|
302
322
|
@options.updated = true
|
303
323
|
end
|
304
324
|
end
|
325
|
+
|
326
|
+
def update_time_to_live(dsl)
|
327
|
+
params = { table_name: @table.table_name }
|
328
|
+
if dsl.time_to_live_specification.enabled.to_s == 'true'
|
329
|
+
params[:time_to_live_specification] = {
|
330
|
+
enabled: dsl.time_to_live_specification.enabled,
|
331
|
+
attribute_name: dsl.time_to_live_specification.attribute_name,
|
332
|
+
}
|
333
|
+
else
|
334
|
+
params[:time_to_live_specification] = {
|
335
|
+
enabled: false,
|
336
|
+
attribute_name: aws_time_to_live.attribute_name,
|
337
|
+
}
|
338
|
+
end
|
339
|
+
|
340
|
+
log(:info, " table: #{@table.table_name}(update time to live)".green, false)
|
341
|
+
log(:info, " => enabled: #{params[:time_to_live_specification][:enabled]}".cyan, false)
|
342
|
+
log(:info, " => attribute_name: #{params[:time_to_live_specification][:attribute_name]}".cyan, false)
|
343
|
+
|
344
|
+
unless @options.dry_run
|
345
|
+
log(:debug, params, false)
|
346
|
+
@ddb.update_time_to_live(params)
|
347
|
+
@options.updated = true
|
348
|
+
end
|
349
|
+
end
|
305
350
|
end
|
306
351
|
end
|
307
352
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dyna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -183,9 +183,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- - "
|
186
|
+
- - ">"
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
188
|
+
version: 1.3.1
|
189
189
|
requirements: []
|
190
190
|
rubyforge_project:
|
191
191
|
rubygems_version: 2.7.6
|