dynamodb_framework 1.8.0 → 1.9.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a38a1f91daf2b721a7f09e6f4ff5d9a796f8d0b22f09908d46717f96e9a0661b
|
4
|
+
data.tar.gz: 46d2c82a0ab2042abaf0e3dd317038eda3861e40006ac4eed1067b9da9d4fd01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e4c59111999afe7ae06282a121e0c46c2ac5935dc006e2630d83a4c26a9afd760d9a7f120c720e4471d633f4f4db83d5609bb0b1b48aaebf517b8b8a6698208
|
7
|
+
data.tar.gz: 2e3161f248e86fe8d65145c9b9483b0f7f90f179a8fd1c93e60b4b7c6eaf571387754c9dabb89def3b015755f61d87e9faad66a1267ca5454b9cfce00562f937
|
@@ -116,6 +116,33 @@ module DynamoDbFramework
|
|
116
116
|
DynamoDbFramework.logger.info "[#{self.class}] -Table: [#{table_name}] updated."
|
117
117
|
end
|
118
118
|
|
119
|
+
def update_ttl_attribute(table_name, enabled, attribute_name)
|
120
|
+
table = {
|
121
|
+
:table_name => table_name,
|
122
|
+
:time_to_live_specification => {
|
123
|
+
:enabled => enabled,
|
124
|
+
:attribute_name => attribute_name
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
DynamoDbFramework.logger.info "[#{self.class}] -Updating TTL Attribute: #{attribute_name}."
|
129
|
+
dynamodb.client.update_time_to_live(table)
|
130
|
+
|
131
|
+
# wait for table to be updated
|
132
|
+
DynamoDbFramework.logger.info "[#{self.class}] -Waiting for table: [#{table_name}] to be updated."
|
133
|
+
wait_until_ttl_changed(table_name)
|
134
|
+
|
135
|
+
DynamoDbFramework.logger.info "[#{self.class}] -Table: [#{table_name}] updated."
|
136
|
+
end
|
137
|
+
|
138
|
+
def get_ttl_status(table_name)
|
139
|
+
table = {
|
140
|
+
:table_name => table_name
|
141
|
+
}
|
142
|
+
|
143
|
+
dynamodb.client.describe_time_to_live(table)['time_to_live_description']
|
144
|
+
end
|
145
|
+
|
119
146
|
def drop_index(table_name, index_name)
|
120
147
|
unless has_index?(table_name, index_name)
|
121
148
|
return
|
@@ -236,6 +263,24 @@ module DynamoDbFramework
|
|
236
263
|
|
237
264
|
end
|
238
265
|
|
266
|
+
def wait_until_ttl_changed(table_name)
|
267
|
+
|
268
|
+
end_time = wait_timeout
|
269
|
+
while Time.now < end_time do
|
270
|
+
|
271
|
+
status = get_ttl_status(table_name)['time_to_live_status']
|
272
|
+
|
273
|
+
if status == 'ENABLED' || status == 'DISABLED'
|
274
|
+
return
|
275
|
+
end
|
276
|
+
|
277
|
+
sleep(5)
|
278
|
+
end
|
279
|
+
|
280
|
+
raise "Timeout occurred while waiting for table: #{table_name}, to update TTL status."
|
281
|
+
|
282
|
+
end
|
283
|
+
|
239
284
|
def create(table_name, attributes, partition_key, range_key = nil, read_capacity = 20, write_capacity = 10, global_indexes = nil, billing_mode = 'PROVISIONED')
|
240
285
|
|
241
286
|
if exists?(table_name)
|
@@ -117,6 +117,56 @@ RSpec.describe DynamoDbFramework::TableManager do
|
|
117
117
|
|
118
118
|
end
|
119
119
|
|
120
|
+
it 'can update the TTL attribute' do
|
121
|
+
|
122
|
+
exists = subject.exists?('update_ttl_test')
|
123
|
+
|
124
|
+
if exists
|
125
|
+
subject.drop('update_ttl_test')
|
126
|
+
end
|
127
|
+
|
128
|
+
builder = DynamoDbFramework::AttributesBuilder.new
|
129
|
+
builder.add(:ttl_date, :N)
|
130
|
+
|
131
|
+
subject.create('update_ttl_test', builder.attributes, :ttl_date)
|
132
|
+
|
133
|
+
subject.update_ttl_attribute('update_ttl_test', true, 'ttl_date')
|
134
|
+
|
135
|
+
expect(subject.get_ttl_status('update_ttl_test')['time_to_live_status']).to eq('ENABLED')
|
136
|
+
|
137
|
+
subject.drop('update_ttl_test')
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'can disable the TTL attribute' do
|
142
|
+
|
143
|
+
exists = subject.exists?('update_ttl_test')
|
144
|
+
|
145
|
+
if exists
|
146
|
+
subject.drop('update_ttl_test')
|
147
|
+
end
|
148
|
+
|
149
|
+
builder = DynamoDbFramework::AttributesBuilder.new
|
150
|
+
builder.add(:ttl_date, :N)
|
151
|
+
|
152
|
+
subject.create('update_ttl_test', builder.attributes, :ttl_date)
|
153
|
+
|
154
|
+
subject.update_ttl_attribute('update_ttl_test', true, 'ttl_date')
|
155
|
+
|
156
|
+
subject.update_ttl_attribute('update_ttl_test', false, 'ttl_date')
|
157
|
+
|
158
|
+
expect(subject.get_ttl_status('update_ttl_test')['time_to_live_status']).to eq('DISABLED')
|
159
|
+
|
160
|
+
subject.drop('update_ttl_test')
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'handles timeouts when dynamodb fails to respond' do
|
165
|
+
allow(subject).to receive('wait_timeout').and_return(Time.now)
|
166
|
+
|
167
|
+
expect{subject.wait_until_ttl_changed('update_ttl_test')}.to raise_error("Timeout occurred while waiting for table: update_ttl_test, to update TTL status.")
|
168
|
+
end
|
169
|
+
|
120
170
|
it 'can drop an existing global secondary index' do
|
121
171
|
|
122
172
|
exists = subject.exists?('drop_index_test')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
|
-
rubygems_version: 3.0.
|
168
|
+
rubygems_version: 3.0.8
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: A lightweight framework to provide managers for working with aws dynamodb
|