dynamodb_framework 1.7.0 → 1.8.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
- SHA1:
3
- metadata.gz: e8d0250d290cb006f3cbfecaffcd35a3c61819c7
4
- data.tar.gz: 98398a2a0aae655ef04ba9ccd01155bd320c5cf1
2
+ SHA256:
3
+ metadata.gz: 92cddfb4858c3bc9d655d4ddb353d437a4bb3e417695c23053ce426be35d3056
4
+ data.tar.gz: cc8e3f7286350e88f09b7a9f68efb57d7220a82c6cc513e54bcb110182e10e3d
5
5
  SHA512:
6
- metadata.gz: d46aac43125f003b06522522790d87dcf201728af48f80e64effe39812bb53a83895aefd331b341b6e4437788f2de9642d74c126b257d8991e2feeaae2d67e69
7
- data.tar.gz: 71428f806932374f1c52a81f04f9cddc6aaafcdce0c11e0c6899825bd12644b663a319b5dbe93a212a164fc9238ef35596306d53df93e0c97ae3d30f3593524d
6
+ metadata.gz: bd3de1be8d514d5af939c48737d0316c02bb27367fba8b7819c43a7f30e529b88529f975716eca5e005f24449a201a09c260c247a4b4668ce9a9dc520e659ee3
7
+ data.tar.gz: a441ff92489712e5218d20e6957508426aa9445a9dc91cfdee727dce1f23e7accd26928e142d348a16148fee6a88e3bc2bbd037dd4870e57d826abff12d72167
@@ -46,7 +46,7 @@ module DynamoDbFramework
46
46
  self.instance_variable_set(:@range_key, { field: field, type: type })
47
47
  end
48
48
 
49
- def create(store: DynamoDbFramework.default_store, read_capacity: 25, write_capacity: 25, submit: true)
49
+ def create(store: DynamoDbFramework.default_store, read_capacity: 25, write_capacity: 25, submit: true, billing_mode: 'PROVISIONED')
50
50
  unless self.instance_variable_defined?(:@table)
51
51
  raise DynamoDbFramework::Index::InvalidConfigException.new('Table must be specified.')
52
52
  end
@@ -84,10 +84,10 @@ module DynamoDbFramework
84
84
 
85
85
  range_key_field = range_key[:field] unless range_key == nil
86
86
 
87
- index =table_manager.create_global_index(full_index_name, partition_key[:field], range_key_field, read_capacity, write_capacity)
87
+ index =table_manager.create_global_index(full_index_name, partition_key[:field], range_key_field, read_capacity, write_capacity, billing_mode)
88
88
 
89
89
  if submit
90
- table_manager.add_index(table_name, builder.attributes, index)
90
+ table_manager.add_index(table_name, builder.attributes, index, billing_mode)
91
91
  end
92
92
 
93
93
  index
@@ -66,7 +66,7 @@ module DynamoDbFramework
66
66
 
67
67
  end
68
68
 
69
- def add_index(table_name, attributes, global_index)
69
+ def add_index(table_name, attributes, global_index, billing_mode = 'PROVISIONED')
70
70
 
71
71
  attribute_definitions = []
72
72
 
@@ -79,7 +79,8 @@ module DynamoDbFramework
79
79
  :attribute_definitions => attribute_definitions,
80
80
  :global_secondary_index_updates => [
81
81
  :create => global_index
82
- ]
82
+ ],
83
+ :billing_mode => billing_mode
83
84
  }
84
85
 
85
86
  dynamodb.client.update_table(table)
@@ -235,7 +236,7 @@ module DynamoDbFramework
235
236
 
236
237
  end
237
238
 
238
- def create(table_name, attributes, partition_key, range_key = nil, read_capacity = 20, write_capacity = 10, global_indexes = nil)
239
+ def create(table_name, attributes, partition_key, range_key = nil, read_capacity = 20, write_capacity = 10, global_indexes = nil, billing_mode = 'PROVISIONED')
239
240
 
240
241
  if exists?(table_name)
241
242
  return
@@ -257,11 +258,17 @@ module DynamoDbFramework
257
258
  :table_name => table_name,
258
259
  :attribute_definitions => attribute_definitions,
259
260
  :key_schema => key_schema,
261
+ :billing_mode => billing_mode
262
+ }
263
+
264
+ unless billing_mode == 'PAY_PER_REQUEST'
265
+ table = table.merge(
260
266
  :provisioned_throughput => {
261
- :read_capacity_units => read_capacity,
262
- :write_capacity_units => write_capacity
267
+ :read_capacity_units => read_capacity,
268
+ :write_capacity_units => write_capacity
263
269
  }
264
- }
270
+ )
271
+ end
265
272
 
266
273
  if global_indexes != nil
267
274
  table[:global_secondary_indexes] = global_indexes
@@ -316,11 +323,17 @@ module DynamoDbFramework
316
323
  :table_name => table_name,
317
324
  :attribute_definitions => attribute_definitions,
318
325
  :key_schema => key_schema,
326
+ :billing_mode => options[:billing_mode] || 'PROVISIONED'
327
+ }
328
+
329
+ unless options[:billing_mode] == 'PAY_PER_REQUEST'
330
+ table = table.merge(
319
331
  :provisioned_throughput => {
320
- :read_capacity_units => options[:read_capacity],
321
- :write_capacity_units => options[:write_capacity]
332
+ :read_capacity_units => options[:read_capacity],
333
+ :write_capacity_units => options[:write_capacity]
322
334
  }
323
- }
335
+ )
336
+ end
324
337
 
325
338
  if options[:global_indexes] != nil
326
339
  table[:global_secondary_indexes] = options[:global_indexes]
@@ -338,7 +351,7 @@ module DynamoDbFramework
338
351
  DynamoDbFramework.logger.info "[#{self.class}] - Table: [#{table_name}] created."
339
352
  end
340
353
 
341
- def create_global_index(name, partition_key, range_key = nil, read_capacity = 20, write_capacity = 10)
354
+ def create_global_index(name, partition_key, range_key = nil, read_capacity = 20, write_capacity = 10, billing_mode = 'PROVISIONED')
342
355
 
343
356
  key_schema = []
344
357
 
@@ -352,13 +365,18 @@ module DynamoDbFramework
352
365
  :key_schema => key_schema,
353
366
  :projection => {
354
367
  :projection_type => :ALL
355
- },
356
- :provisioned_throughput => {
357
- :read_capacity_units => read_capacity,
358
- :write_capacity_units => write_capacity,
359
368
  }
360
369
  }
361
370
 
371
+ if billing_mode == 'PROVISIONED'
372
+ index = index.merge(
373
+ :provisioned_throughput => {
374
+ :read_capacity_units => read_capacity,
375
+ :write_capacity_units => write_capacity,
376
+ }
377
+ )
378
+ end
379
+
362
380
  return index
363
381
  end
364
382
 
@@ -1,3 +1,3 @@
1
1
  module DynamoDbFramework
2
- VERSION = '1.7.0'
2
+ VERSION = '1.8.0'
3
3
  end
@@ -1,3 +1,8 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter '/spec/'
4
+ end
5
+
1
6
  require "rubygems"
2
7
  require "bundler"
3
8
  require 'aws-sdk-core'
@@ -9,12 +14,7 @@ require_relative '../spec/example_table'
9
14
  require_relative '../spec/example_index'
10
15
  require 'pry'
11
16
 
12
- require 'simplecov'
13
- SimpleCov.start do
14
- add_filter '/spec/'
15
- end
16
-
17
- DYNAMODB_STORE_ENDPOINT = 'http://dynamodb:8000'
17
+ DYNAMODB_STORE_ENDPOINT = ENV.fetch('DYNAMODB_ENDPOINT', 'http://localhost:8000')
18
18
 
19
19
  Aws.config[:credentials] = Aws::Credentials.new('test_key', 'test_secret')
20
20
  Aws.config[:region] = 'eu-west-1'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamodb_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-09 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +111,7 @@ dependencies:
111
111
  description: A lightweight framework to provide managers for working with aws dynamodb
112
112
  (incuding local version).
113
113
  email:
114
- - vaughanbritton@gmail.com
114
+ - vaughan.britton@sage.com
115
115
  executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
@@ -132,16 +132,16 @@ files:
132
132
  - lib/dynamodb_framework/dynamodb_table_manager.rb
133
133
  - lib/dynamodb_framework/hash_helper.rb
134
134
  - lib/dynamodb_framework/version.rb
135
- - spec/dynamodb_index_spec.rb
136
- - spec/dynamodb_migration_manager_spec.rb
137
- - spec/dynamodb_namespace_migration_manager_spec.rb
138
- - spec/dynamodb_query_spec.rb
139
- - spec/dynamodb_repository_spec.rb
140
- - spec/dynamodb_table_manager_spec.rb
141
- - spec/dynamodb_table_spec.rb
135
+ - spec/dynamodb_framework/dynamodb_index_spec.rb
136
+ - spec/dynamodb_framework/dynamodb_migration_manager_spec.rb
137
+ - spec/dynamodb_framework/dynamodb_namespace_migration_manager_spec.rb
138
+ - spec/dynamodb_framework/dynamodb_query_spec.rb
139
+ - spec/dynamodb_framework/dynamodb_repository_spec.rb
140
+ - spec/dynamodb_framework/dynamodb_table_manager_spec.rb
141
+ - spec/dynamodb_framework/dynamodb_table_spec.rb
142
+ - spec/dynamodb_framework/hash_helper_spec.rb
142
143
  - spec/example_index.rb
143
144
  - spec/example_table.rb
144
- - spec/hash_helper_spec.rb
145
145
  - spec/spec_helper.rb
146
146
  - spec/test_item.rb
147
147
  - spec/test_migration_script1.rb
@@ -165,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.5.1
168
+ rubygems_version: 3.0.2
170
169
  signing_key:
171
170
  specification_version: 4
172
171
  summary: A lightweight framework to provide managers for working with aws dynamodb