eventsimple 1.1.0 → 1.1.2

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: c89fd452fb688ea84659fb341c78b8c30ce14632a948750fab7ec831d34baf0e
4
- data.tar.gz: ef3abdd6bd8158e65e476a23170c9e9b42329974abd7de679f2ca27c2203972e
3
+ metadata.gz: 989aab149125d77a97510193a1905233eef5714a798a821e14fa7697247b5403
4
+ data.tar.gz: 7dc3276c03f6ab9617733ef292297ba2e5dc9b414c5d221621b2bed5a8635151
5
5
  SHA512:
6
- metadata.gz: 804e17de52e7f4f5c172b1e3a8735c1037966298aaf40952ffc36446ad37514890fabe4cf602164932723598c83d8060a6ab0f9a05d39d01b932b9fbcd0bd401
7
- data.tar.gz: 77589ed9dbb33bd4142282599f00a53790468ebdd1695d74bd19a1a7d515937988c31c70db84cbc2b91a76ce0e3b32aab910735cacbfc3f4e81ce055fc4023c7
6
+ metadata.gz: a378b62e0dc1e50540b85f002b06d5a8ff8b17d338b9b7a860d97f630538c919dde28bd1ff44c1d0ef62e29044e26f11089115e03bbd08545c60566fd893a9c5
7
+ data.tar.gz: 34cd12770a08ff80b4c6e7ee6e01e0c8e347415d7303ee646d4328a734ca2214180cd64e223e38fe7bae1bb6f39a702aa44ad2dc9e440677cd42e3ce1424618b
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.1.2 - 2023-06-22
10
+ ### Changed
11
+ - Fix exception noise generated by early global_id desrialization
12
+
13
+ ## 1.1.1 - 2023-06-19
14
+ ### Changed
15
+ - Remove active_job_parent_klass config introduced in 1.1.0. There isn't a usecase for it yet,
16
+ and it was causing loading issues.
17
+
9
18
  ## 1.1.0 - 2023-06-11
10
19
  ### Changed
11
20
  - Reactors now use ActiveJob instead of Sidekiq directly. This allows for more
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.1.0)
4
+ eventsimple (1.1.2)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  pg (~> 1.4)
@@ -159,7 +159,7 @@ GEM
159
159
  mini_mime (1.1.2)
160
160
  minitest (5.18.0)
161
161
  nenv (0.3.0)
162
- net-imap (0.3.4)
162
+ net-imap (0.3.6)
163
163
  date
164
164
  net-protocol
165
165
  net-pop (0.1.2)
@@ -284,7 +284,7 @@ GEM
284
284
  rubocop (>= 0.53.0)
285
285
  ruby-progressbar (1.13.0)
286
286
  shellany (0.0.1)
287
- sidekiq (7.1.1)
287
+ sidekiq (7.1.2)
288
288
  concurrent-ruby (< 2)
289
289
  connection_pool (>= 2.3.0)
290
290
  rack (>= 2.2.4)
data/README.md CHANGED
@@ -74,11 +74,6 @@ Setup an initializer in `config/initializers/eventsimple.rb`:
74
74
  # Defaults to `Eventsimple::Metadata`
75
75
  config.metadata_klass = 'Eventsimple::Metadata'
76
76
 
77
- # Optional: Reactors inherit from an ActiveJob base class.
78
- # Set the parent class for reactors.
79
- # Defaults to ActiveJob::Base.
80
- config.active_job_parent_klass = 'ApplicationJob'
81
-
82
77
  # Optional: When using an ActiveJob adapter that writes to a different data store like redis,
83
78
  # it is possible that the reactor is executed before the transaction persisting the event is committed. This can result in noisy errors when using processors like Sidekiq.
84
79
  # Enable this option to retry the reactor inline if the event is not found.
@@ -0,0 +1,20 @@
1
+ require 'active_job/arguments'
2
+
3
+ module ActiveJob
4
+ module Arguments
5
+ extend self
6
+
7
+ def deserialize_global_id(hash)
8
+ # For non database based processors like sidekiq, the reactor may trigger before the
9
+ # transaction is committed. Attempt to wait for the transaction to be commited before
10
+ # running the reactor. This is not a perfect solution, but it's better than nothing.
11
+ if Eventsimple.configuration.retry_reactor_on_record_not_found
12
+ Retriable.with_context(:reactor) do
13
+ ApplicationRecord.uncached { GlobalID::Locator.locate hash[GLOBALID_KEY] }
14
+ end
15
+ else
16
+ GlobalID::Locator.locate hash[GLOBALID_KEY]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,7 +4,6 @@ module Eventsimple
4
4
  class Configuration
5
5
  attr_reader :max_concurrency_retries
6
6
  attr_writer :metadata_klass
7
- attr_writer :active_job_parent_klass
8
7
  attr_accessor :retry_reactor_on_record_not_found
9
8
 
10
9
  attr_accessor :ui_visible_models
@@ -13,7 +12,6 @@ module Eventsimple
13
12
  @dispatchers = []
14
13
  @max_concurrency_retries = 2
15
14
  @metadata_klass = 'Eventsimple::Metadata'
16
- @active_job_parent_klass = 'ActiveJob::Base'
17
15
  @retry_reactor_on_record_not_found = false
18
16
 
19
17
  @ui_visible_models = [] # internal use only
@@ -34,7 +32,6 @@ module Eventsimple
34
32
  end
35
33
 
36
34
  # rubocop:disable Naming/MemoizedInstanceVariableName
37
-
38
35
  def dispatchers
39
36
  @dispatchers_klass_consts ||= @dispatchers.map(&:constantize)
40
37
  end
@@ -42,10 +39,6 @@ module Eventsimple
42
39
  def metadata_klass
43
40
  @metadata_klass_const ||= @metadata_klass.constantize
44
41
  end
45
-
46
- def active_job_parent_klass
47
- @active_job_parent_klass_const ||= @active_job_parent_klass.constantize
48
- end
49
42
  # rubocop:enable Naming/MemoizedInstanceVariableName
50
43
  end
51
44
  end
@@ -1,32 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- class Reactor < Eventsimple.configuration.active_job_parent_klass
4
+ class Reactor < ActiveJob::Base # rubocop:disable Rails/ApplicationJob
5
5
  queue_as :eventsimple
6
6
 
7
- def perform(event)
8
- call(event)
7
+ discard_on ActiveJob::DeserializationError do |job, error|
8
+ Rails.logger.warn("Event #{job.arguments.first} not found for reactor: #{self.class}")
9
9
  end
10
10
 
11
- around_perform do |job, block|
12
- event_global_id = job.arguments.first
13
- reactor_class = job.arguments.second
14
-
15
- # For non database based processors like sidekiq, the reactor may trigger before the
16
- # transaction is committed. Attempt to wait for the transaction to be commited before
17
- # running the reactor. This is not a perfect solution, but it's better than nothing.
18
- if Eventsimple.configuration.retry_reactor_on_record_not_found
19
- begin
20
- Retriable.with_context(:reactor) do
21
- ApplicationRecord.uncached { GlobalID::Locator.locate(event_global_id) }
22
- end
23
- rescue ActiveRecord::RecordNotFound
24
- Rails.logger.error("Event #{event_global_id} not found for reactor: #{reactor_class}")
25
- return
26
- end
27
- end
28
-
29
- block.call
11
+ def perform(event)
12
+ call(event)
30
13
  end
31
14
  end
32
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.2'
5
5
  end
data/lib/eventsimple.rb CHANGED
@@ -13,6 +13,7 @@ require 'sidekiq'
13
13
 
14
14
  require 'dry_types'
15
15
 
16
+ require 'eventsimple/active_job/arguments'
16
17
  require 'eventsimple/configuration'
17
18
  require 'eventsimple/message'
18
19
  require 'eventsimple/data_type'
@@ -20,6 +21,7 @@ require 'eventsimple/metadata_type'
20
21
  require 'eventsimple/metadata'
21
22
  require 'eventsimple/dispatcher'
22
23
  require 'eventsimple/event_dispatcher'
24
+ require 'eventsimple/reactor'
23
25
  require 'eventsimple/reactor_worker'
24
26
  require 'eventsimple/invalid_transition'
25
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-15 00:00:00.000000000 Z
11
+ date: 2023-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -253,6 +253,7 @@ files:
253
253
  - eventsimple.gemspec
254
254
  - lib/dry_types.rb
255
255
  - lib/eventsimple.rb
256
+ - lib/eventsimple/active_job/arguments.rb
256
257
  - lib/eventsimple/configuration.rb
257
258
  - lib/eventsimple/data_type.rb
258
259
  - lib/eventsimple/dispatcher.rb