event_tracer 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/event_tracer/config.rb +3 -0
- data/lib/event_tracer/dynamo_db/client.rb +7 -2
- data/lib/event_tracer/dynamo_db/worker.rb +9 -2
- data/lib/event_tracer/version.rb +1 -1
- data/lib/event_tracer.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 335d4c810b2a3e378d826518f8e8c6c2a8a1310f029401381ac2f407437554ca
|
4
|
+
data.tar.gz: 95971a338ad15cb6f5f74bb78f10f59dfba0918c7578a3e1057f8d11e5dc7bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 473b42b4728e7233bdddaa4d85c681b33b41c71c26eb78ee9578c332f878e78234e6007b37c6c120e0adf13eaa8dd87e18f09d2069cfe7ca578e2ef8f1fc6079
|
7
|
+
data.tar.gz: 5a58acc598909419d8164a4cfb46c2c9695b12faee98bdf2ae937648dc964c4c70e04c78e8a2395ed133a245ca86d4ac7d471972a7e72510267d2bcb754b1e56
|
data/lib/event_tracer/config.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module EventTracer
|
2
2
|
module DynamoDB
|
3
3
|
class Client
|
4
|
-
|
5
|
-
|
4
|
+
class << self
|
5
|
+
extend Gem::Deprecate
|
6
|
+
|
7
|
+
def call
|
8
|
+
Aws::DynamoDB::Client.new
|
9
|
+
end
|
10
|
+
deprecate :call, 'EventTracer::Config.config.dynamo_db_client', 2021, 12
|
6
11
|
end
|
7
12
|
end
|
8
13
|
end
|
@@ -20,14 +20,19 @@ module EventTracer
|
|
20
20
|
# See https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/DynamoDB/Client.html#batch_write_item-instance_method
|
21
21
|
MAX_DYNAMO_DB_ITEM_PER_REQUEST = 25
|
22
22
|
|
23
|
+
def initialize(client = nil)
|
24
|
+
@config = EventTracer::Config.config
|
25
|
+
@client = client || @config.dynamo_db_client || Client.call
|
26
|
+
end
|
27
|
+
|
23
28
|
def perform(items)
|
24
29
|
wrap(items).each_slice(MAX_DYNAMO_DB_ITEM_PER_REQUEST) do |batch|
|
25
30
|
data = batch.map do |item|
|
26
31
|
{ put_request: { item: clean_empty_values(item) } }
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
request_items: {
|
34
|
+
client.batch_write_item(
|
35
|
+
request_items: { config.dynamo_db_table_name => data }
|
31
36
|
)
|
32
37
|
|
33
38
|
rescue Aws::DynamoDB::Errors::ServiceError => e
|
@@ -43,6 +48,8 @@ module EventTracer
|
|
43
48
|
|
44
49
|
private
|
45
50
|
|
51
|
+
attr_reader :client, :config
|
52
|
+
|
46
53
|
def wrap(items)
|
47
54
|
# NOTE: This allows us to handle either buffered or unbuffered payloads
|
48
55
|
if items.is_a?(Hash)
|
data/lib/event_tracer/version.rb
CHANGED
data/lib/event_tracer.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- melvrickgoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|