uc3-dmp-dynamo 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-dynamo/client.rb +11 -10
- data/lib/uc3-dmp-dynamo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b80170988e25aef1241fd264b2e3e6640420851e8c16209946a53067eda0d16a
|
4
|
+
data.tar.gz: 0e88dba2cae7cb9bc5427f474eb3230ff627f806e433ea43ce1d7a3ff2de9ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1384e8054db8fb6121631b3c7f32dc5180a6136115a84672613882af1edc07310cb069ab93d9c35e9126fdc993fd21e609c6a6d05b92f4b846da631c666a3658
|
7
|
+
data.tar.gz: 98a6e2672a64efe161ca4d1893bed31a4da2252d2e22f3ec93b8cf4c638b32c5c6187b1b277b4d19c96068bc394166c5d03f11687d6a69390bbbeea7264833c8
|
@@ -16,21 +16,20 @@ module Uc3DmpDynamo
|
|
16
16
|
MSG_MISSING_TABLE = 'No Dynamo Table defined! Looking for `ENV[\'DYNAMO_TABLE\']`'
|
17
17
|
MSG_DYNAMO_ERROR = 'Dynamo DB Table Error - %{msg} - %{trace}'
|
18
18
|
|
19
|
-
attr_accessor: :connection, :table
|
19
|
+
attr_accessor: :connection, :table
|
20
20
|
|
21
21
|
def initialize(**args)
|
22
22
|
@table = ENV['DYNAMO_TABLE']
|
23
23
|
raise Uc3DmpDynamoError, MSG_MISSING_TABLE if @table.nil?
|
24
24
|
|
25
|
-
@
|
26
|
-
@connection = args.fetch(:client, Aws::DynamoDB::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2')))
|
25
|
+
@connection = Aws::DynamoDB::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2'))
|
27
26
|
end
|
28
27
|
|
29
28
|
# Fetch a single item
|
30
29
|
def get_item(key:, debug: false)
|
31
30
|
raise Uc3DmpDynamoError, MSG_INVALID_KEY unless key.is_a?(Hash)
|
32
31
|
|
33
|
-
resp = @
|
32
|
+
resp = @connection.get_item(
|
34
33
|
{ table_name: @table,
|
35
34
|
key: key,
|
36
35
|
consistent_read: false,
|
@@ -38,8 +37,9 @@ module Uc3DmpDynamo
|
|
38
37
|
}
|
39
38
|
)
|
40
39
|
# If debug is enabled then write the response to the LogWriter
|
41
|
-
if debug
|
42
|
-
|
40
|
+
if debug
|
41
|
+
puts "#{SOURCE} => get_item - #{key}"
|
42
|
+
puts resp[:item].first.inspect
|
43
43
|
end
|
44
44
|
resp[:item].first
|
45
45
|
rescue Aws::Errors::ServiceError => e
|
@@ -69,11 +69,12 @@ module Uc3DmpDynamo
|
|
69
69
|
hash[key.to_sym] = args[key.to_sym]
|
70
70
|
end
|
71
71
|
|
72
|
-
resp = @
|
72
|
+
resp = @connection.query(hash)
|
73
73
|
# If debug is enabled then write the response to the LogWriter
|
74
|
-
if debug
|
75
|
-
msg = "query -
|
76
|
-
|
74
|
+
if debug
|
75
|
+
msg = "query - args: #{args}"
|
76
|
+
puts "#{SOURCE} => query - args: #{args.inspect}"
|
77
|
+
puts resp.items.inspect
|
77
78
|
end
|
78
79
|
resp.items
|
79
80
|
rescue Aws::Errors::ServiceError => e
|