tpt-rails 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 300608f90255d2884190ff472e70781927269af457bf549d57443edc396186ca
4
- data.tar.gz: 5dd5a558b911dd7dae7486f0984ddeac4fa8c05d5d3407e5ef269d64fe7a3e4c
3
+ metadata.gz: '0395183e764d77487d191133045533748b1120aa919bd2904d19e923c58b5c1d'
4
+ data.tar.gz: f8591848d97fb4324aed4318183198db27ccfcff116ad43f806cd2322aadcb57
5
5
  SHA512:
6
- metadata.gz: 849e1766a9d4a6668516bb1d52d313e375bd823d2723668fb9917c218e79444e71400803cfecdea4f4ec7f8521832fea4c962d36af814b93fe1d4735e228d3c0
7
- data.tar.gz: 7865a91a0e8b6553647ee022d84617aad7ef590c5e9fce5f64ea30eeeb25f7dd60ea0f71ea28702cad0f0eed20f02cd588467c657edb4610bd679437e2a63784
6
+ metadata.gz: 3093e622d8895edf09b3d2ee025c1356e89bdd6d7ea95dd623e5f870e8d2adab915bc4f279c548f24d0636ee902825c163b1ea61f7ce21ef5a66c970dc0c55f8
7
+ data.tar.gz: 11459ad795f7603c051f7c509ff475bdfd21bd52ce37b26ad4792da3a833fdea0a4294f614965cd28a0716f51ed79039b5fe39ebde21458e2901595e6f0ca1e7
data/README.md CHANGED
@@ -68,7 +68,13 @@ See the documentation in [lib/tpt/rails.rb](lib/tpt/rails.rb).
68
68
 
69
69
  `Tpt::Rails::EventBridgePublisher` is the class used to emit events to EventBridge (in batches). To use:
70
70
 
71
- 1. In an initializer, pass in the `Datadog::Statsd` object you're using to the class method ::set_metrics.
71
+ 1. Add EventBridge to your gemfile:
72
+
73
+ ```ruby
74
+ gem "aws-sdk-eventbridge", "~> 1.3.0"
75
+ ```
76
+
77
+ 2. In an initializer, pass in the `Datadog::Statsd` object you're using to the class method ::set_metrics.
72
78
  (Failure to do so will result in an error.) When testing, you can pass in a local Statsd, eg:
73
79
 
74
80
  ```ruby
@@ -77,13 +83,13 @@ See the documentation in [lib/tpt/rails.rb](lib/tpt/rails.rb).
77
83
  )
78
84
  ```
79
85
 
80
- 2. By default (#new with no arguments) EventBridgePublisher will try to use the following environment
86
+ 3. By default (#new with no arguments) EventBridgePublisher will try to use the following environment
81
87
  variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `TPT_EVENT_SOURCE`, `TPT_SHARED_EVENT_BUS_NAME`.
82
88
 
83
89
  Additional configuration can be set as part of the constructor;
84
90
  [see event_bridge_publisher.rb implementation](https://github.com/TeachersPayTeachers/tpt-rails/blob/ad768d3bac0c8bd28e60a48a89aed36f01c4e17b/app/models/tpt/rails/event_bridge_publisher.rb) for more details.
85
91
 
86
- 3. Create events by instantiating or inheriting from `Tpt::Rails::ApplicationEvent`. Event types are derived from the text before
92
+ 4. Create events by instantiating or inheriting from `Tpt::Rails::ApplicationEvent`. Event types are derived from the text before
87
93
  "Event", so ResourceEvent has the event_type "Resource". Pass in an event or an array of events to EventBridgePublisher#publish
88
94
  and they will be published immediately. Large arrays will be batched (default 10 per batch).
89
95
 
@@ -12,7 +12,7 @@ module Tpt::Rails
12
12
  end
13
13
 
14
14
  def ==(other)
15
- data == other.data
15
+ @data == other.data
16
16
  end
17
17
 
18
18
  def attributes
@@ -1,5 +1,7 @@
1
1
  module Tpt::Rails
2
2
  class EventBridgePublisher
3
+ attr_accessor :batch_size
4
+
3
5
  def initialize(
4
6
  event_bus_name: default_event_bus_name,
5
7
  event_source: default_event_source,
@@ -26,7 +28,9 @@ module Tpt::Rails
26
28
  events
27
29
  end
28
30
 
29
- protected
31
+ private
32
+ attr_reader :client, :event_bus_name, :event_source
33
+
30
34
  def publish_batch(events)
31
35
  metrics.time('tpt.event_bridge.publish_batch') do
32
36
  wrapped_events = wrap_events(events)
@@ -77,14 +81,10 @@ module Tpt::Rails
77
81
  res.data.entries
78
82
  end
79
83
 
80
- private
81
-
82
- attr_reader :client, :event_bus_name, :event_source
83
-
84
84
  def make_client(options)
85
85
  all_options = {
86
- access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
87
- secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
86
+ access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID', nil),
87
+ secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', nil),
88
88
  region: ENV.fetch('AWS_REGION', 'us-east-1'),
89
89
  http_open_timeout: 1, # default is 15
90
90
  http_read_timeout: 1, # default is 60
@@ -1,6 +1,6 @@
1
1
  module Tpt
2
2
  module Rails
3
3
  # Do not change this manually. Our tooling will do it automatically.
4
- VERSION = '1.6.0'
4
+ VERSION = '1.6.1'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tpt-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TpT