eventsimple 1.1.1 → 1.1.3

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: 46f6a80be5a43cb84c321b67e9a27dde596b2eb3aa3d55ce8f635e395f42ce19
4
- data.tar.gz: c3abab5c2bd25bee61695d24cdb9104cd11d403bb2b360ad1417f71f3006cd54
3
+ metadata.gz: 80288a15a3b05c634212479375312858866bdc7371cc74633c3ca59e23d97b1f
4
+ data.tar.gz: d3a9129566b5080b8dd62bc25b1e44cd93e97d919c2e3e844a7519c31ebcfbff
5
5
  SHA512:
6
- metadata.gz: 3eb05c140311c7466f6cc27fe2a63e033f4464123449d9c9bc20b4b3ae9dd207b03bfe3acfd00cbf6c04bfa4c55456910fb2cee80056e04b5ec5aff70a4b73c1
7
- data.tar.gz: fe56e5c4b5fa1608bd05a01f2b05f2051c8d7491170dc0c06790279a134a5d2b19465feca5104420d7dc43dcf2816e982d7aafbaa0aa65bfeadcca0ad476948d
6
+ metadata.gz: 6d66922352e0cc3f3115ec7dd648a84b7d2c739faf25ed871b634a3165ea67c459677e2958657f0469ee23dfa44ddfbabf447cb270ce93521d818d063357a075
7
+ data.tar.gz: 32379b97f433cd15e6fb2e1cdb0eb85ec9a07ba09a2edefe303b785723d38d8b91788628055afa7ab1b3b6ee0d69c51b574afdd5f74875d2d96eb653635a518d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.1.3 - 2023-07-07
10
+ ### Changed
11
+ - Sidekiq is no longer a required dependency.
12
+
13
+ ## 1.1.2 - 2023-06-22
14
+ ### Changed
15
+ - Fix exception noise generated by early global_id desrialization
16
+
9
17
  ## 1.1.1 - 2023-06-19
10
18
  ### Changed
11
19
  - Remove active_job_parent_klass config introduced in 1.1.0. There isn't a usecase for it yet,
data/Gemfile.lock CHANGED
@@ -1,78 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.1.1)
4
+ eventsimple (1.1.3)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  pg (~> 1.4)
8
8
  rails (~> 7.0)
9
9
  retriable (~> 3.1)
10
- sidekiq (~> 7.0)
11
10
 
12
11
  GEM
13
12
  remote: https://rubygems.org/
14
13
  specs:
15
- actioncable (7.0.5)
16
- actionpack (= 7.0.5)
17
- activesupport (= 7.0.5)
14
+ actioncable (7.0.6)
15
+ actionpack (= 7.0.6)
16
+ activesupport (= 7.0.6)
18
17
  nio4r (~> 2.0)
19
18
  websocket-driver (>= 0.6.1)
20
- actionmailbox (7.0.5)
21
- actionpack (= 7.0.5)
22
- activejob (= 7.0.5)
23
- activerecord (= 7.0.5)
24
- activestorage (= 7.0.5)
25
- activesupport (= 7.0.5)
19
+ actionmailbox (7.0.6)
20
+ actionpack (= 7.0.6)
21
+ activejob (= 7.0.6)
22
+ activerecord (= 7.0.6)
23
+ activestorage (= 7.0.6)
24
+ activesupport (= 7.0.6)
26
25
  mail (>= 2.7.1)
27
26
  net-imap
28
27
  net-pop
29
28
  net-smtp
30
- actionmailer (7.0.5)
31
- actionpack (= 7.0.5)
32
- actionview (= 7.0.5)
33
- activejob (= 7.0.5)
34
- activesupport (= 7.0.5)
29
+ actionmailer (7.0.6)
30
+ actionpack (= 7.0.6)
31
+ actionview (= 7.0.6)
32
+ activejob (= 7.0.6)
33
+ activesupport (= 7.0.6)
35
34
  mail (~> 2.5, >= 2.5.4)
36
35
  net-imap
37
36
  net-pop
38
37
  net-smtp
39
38
  rails-dom-testing (~> 2.0)
40
- actionpack (7.0.5)
41
- actionview (= 7.0.5)
42
- activesupport (= 7.0.5)
39
+ actionpack (7.0.6)
40
+ actionview (= 7.0.6)
41
+ activesupport (= 7.0.6)
43
42
  rack (~> 2.0, >= 2.2.4)
44
43
  rack-test (>= 0.6.3)
45
44
  rails-dom-testing (~> 2.0)
46
45
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
47
- actiontext (7.0.5)
48
- actionpack (= 7.0.5)
49
- activerecord (= 7.0.5)
50
- activestorage (= 7.0.5)
51
- activesupport (= 7.0.5)
46
+ actiontext (7.0.6)
47
+ actionpack (= 7.0.6)
48
+ activerecord (= 7.0.6)
49
+ activestorage (= 7.0.6)
50
+ activesupport (= 7.0.6)
52
51
  globalid (>= 0.6.0)
53
52
  nokogiri (>= 1.8.5)
54
- actionview (7.0.5)
55
- activesupport (= 7.0.5)
53
+ actionview (7.0.6)
54
+ activesupport (= 7.0.6)
56
55
  builder (~> 3.1)
57
56
  erubi (~> 1.4)
58
57
  rails-dom-testing (~> 2.0)
59
58
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
60
- activejob (7.0.5)
61
- activesupport (= 7.0.5)
59
+ activejob (7.0.6)
60
+ activesupport (= 7.0.6)
62
61
  globalid (>= 0.3.6)
63
- activemodel (7.0.5)
64
- activesupport (= 7.0.5)
65
- activerecord (7.0.5)
66
- activemodel (= 7.0.5)
67
- activesupport (= 7.0.5)
68
- activestorage (7.0.5)
69
- actionpack (= 7.0.5)
70
- activejob (= 7.0.5)
71
- activerecord (= 7.0.5)
72
- activesupport (= 7.0.5)
62
+ activemodel (7.0.6)
63
+ activesupport (= 7.0.6)
64
+ activerecord (7.0.6)
65
+ activemodel (= 7.0.6)
66
+ activesupport (= 7.0.6)
67
+ activestorage (7.0.6)
68
+ actionpack (= 7.0.6)
69
+ activejob (= 7.0.6)
70
+ activerecord (= 7.0.6)
71
+ activesupport (= 7.0.6)
73
72
  marcel (~> 1.0)
74
73
  mini_mime (>= 1.1.0)
75
- activesupport (7.0.5)
74
+ activesupport (7.0.6)
76
75
  concurrent-ruby (~> 1.0, >= 1.0.2)
77
76
  i18n (>= 1.6, < 2)
78
77
  minitest (>= 5.1)
@@ -88,7 +87,6 @@ GEM
88
87
  thor (~> 1.0)
89
88
  coderay (1.1.3)
90
89
  concurrent-ruby (1.2.2)
91
- connection_pool (2.4.1)
92
90
  crass (1.0.6)
93
91
  date (3.3.3)
94
92
  diff-lcs (1.5.0)
@@ -141,7 +139,7 @@ GEM
141
139
  ice_nine (0.11.2)
142
140
  json (2.6.3)
143
141
  language_server-protocol (3.17.0.3)
144
- lint_roller (1.0.0)
142
+ lint_roller (1.1.0)
145
143
  listen (3.8.0)
146
144
  rb-fsevent (~> 0.10, >= 0.10.3)
147
145
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -157,7 +155,7 @@ GEM
157
155
  marcel (1.0.2)
158
156
  method_source (1.0.0)
159
157
  mini_mime (1.1.2)
160
- minitest (5.18.0)
158
+ minitest (5.18.1)
161
159
  nenv (0.3.0)
162
160
  net-imap (0.3.6)
163
161
  date
@@ -169,9 +167,9 @@ GEM
169
167
  net-smtp (0.3.3)
170
168
  net-protocol
171
169
  nio4r (2.5.9)
172
- nokogiri (1.15.2-arm64-darwin)
170
+ nokogiri (1.15.3-arm64-darwin)
173
171
  racc (~> 1.4)
174
- nokogiri (1.15.2-x86_64-linux)
172
+ nokogiri (1.15.3-x86_64-linux)
175
173
  racc (~> 1.4)
176
174
  notiffany (0.1.3)
177
175
  nenv (~> 0.1)
@@ -190,33 +188,34 @@ GEM
190
188
  public_suffix (5.0.1)
191
189
  puma (6.3.0)
192
190
  nio4r (~> 2.0)
193
- racc (1.7.0)
191
+ racc (1.7.1)
194
192
  rack (2.2.7)
195
193
  rack-test (2.1.0)
196
194
  rack (>= 1.3)
197
- rails (7.0.5)
198
- actioncable (= 7.0.5)
199
- actionmailbox (= 7.0.5)
200
- actionmailer (= 7.0.5)
201
- actionpack (= 7.0.5)
202
- actiontext (= 7.0.5)
203
- actionview (= 7.0.5)
204
- activejob (= 7.0.5)
205
- activemodel (= 7.0.5)
206
- activerecord (= 7.0.5)
207
- activestorage (= 7.0.5)
208
- activesupport (= 7.0.5)
195
+ rails (7.0.6)
196
+ actioncable (= 7.0.6)
197
+ actionmailbox (= 7.0.6)
198
+ actionmailer (= 7.0.6)
199
+ actionpack (= 7.0.6)
200
+ actiontext (= 7.0.6)
201
+ actionview (= 7.0.6)
202
+ activejob (= 7.0.6)
203
+ activemodel (= 7.0.6)
204
+ activerecord (= 7.0.6)
205
+ activestorage (= 7.0.6)
206
+ activesupport (= 7.0.6)
209
207
  bundler (>= 1.15.0)
210
- railties (= 7.0.5)
211
- rails-dom-testing (2.0.3)
212
- activesupport (>= 4.2.0)
208
+ railties (= 7.0.6)
209
+ rails-dom-testing (2.1.1)
210
+ activesupport (>= 5.0.0)
211
+ minitest
213
212
  nokogiri (>= 1.6)
214
213
  rails-html-sanitizer (1.6.0)
215
214
  loofah (~> 2.21)
216
215
  nokogiri (~> 1.14)
217
- railties (7.0.5)
218
- actionpack (= 7.0.5)
219
- activesupport (= 7.0.5)
216
+ railties (7.0.6)
217
+ actionpack (= 7.0.6)
218
+ activesupport (= 7.0.6)
220
219
  method_source
221
220
  rake (>= 12.2)
222
221
  thor (~> 1.0)
@@ -227,8 +226,6 @@ GEM
227
226
  rb-inotify (0.10.1)
228
227
  ffi (~> 1.0)
229
228
  rchardet (1.8.0)
230
- redis-client (0.14.1)
231
- connection_pool
232
229
  regexp_parser (2.8.1)
233
230
  retriable (3.1.2)
234
231
  rexml (3.2.5)
@@ -252,11 +249,11 @@ GEM
252
249
  rspec-expectations (~> 3.12)
253
250
  rspec-mocks (~> 3.12)
254
251
  rspec-support (~> 3.12)
255
- rspec-support (3.12.0)
256
- rubocop (1.52.0)
252
+ rspec-support (3.12.1)
253
+ rubocop (1.52.1)
257
254
  json (~> 2.3)
258
255
  parallel (~> 1.10)
259
- parser (>= 3.2.0.0)
256
+ parser (>= 3.2.2.3)
260
257
  rainbow (>= 2.2.2, < 4.0)
261
258
  regexp_parser (>= 1.8, < 3.0)
262
259
  rexml (>= 3.2.5, < 4.0)
@@ -284,11 +281,6 @@ GEM
284
281
  rubocop (>= 0.53.0)
285
282
  ruby-progressbar (1.13.0)
286
283
  shellany (0.0.1)
287
- sidekiq (7.1.2)
288
- concurrent-ruby (< 2)
289
- connection_pool (>= 2.3.0)
290
- rack (>= 2.2.4)
291
- redis-client (>= 0.14.0)
292
284
  standard (1.29.0)
293
285
  language_server-protocol (~> 3.17.0.2)
294
286
  lint_roller (~> 1.0)
@@ -297,14 +289,14 @@ GEM
297
289
  standard-performance (~> 1.1.0)
298
290
  standard-custom (1.0.1)
299
291
  lint_roller (~> 1.0)
300
- standard-performance (1.1.0)
301
- lint_roller (~> 1.0)
292
+ standard-performance (1.1.1)
293
+ lint_roller (~> 1.1)
302
294
  rubocop-performance (~> 1.18.0)
303
295
  standard-rails (0.1.0)
304
296
  lint_roller (~> 1.0)
305
297
  rubocop-rails (~> 2.19.0)
306
298
  thor (1.2.2)
307
- timeout (0.3.2)
299
+ timeout (0.4.0)
308
300
  treetop (1.6.12)
309
301
  polyglot (~> 0.3)
310
302
  tzinfo (2.0.6)
@@ -313,7 +305,7 @@ GEM
313
305
  websocket-driver (0.7.5)
314
306
  websocket-extensions (>= 0.1.0)
315
307
  websocket-extensions (0.1.5)
316
- ws-style (7.1.0)
308
+ ws-style (7.1.1)
317
309
  rubocop-rspec (>= 2.2.0)
318
310
  rubocop-vendor (>= 0.11)
319
311
  standard (>= 1.28.2)
data/README.md CHANGED
@@ -82,6 +82,19 @@ Setup an initializer in `config/initializers/eventsimple.rb`:
82
82
  end
83
83
  ```
84
84
 
85
+ If using `Sidekiq` as a backend to `ActiveJob` for async reactors, please add this setting to
86
+ `config/application.rb`:
87
+ ```ruby
88
+ config.active_job.queue_adapter = :sidekiq
89
+ ```
90
+ The jobs are pushed into a queue named `eventsimple`, so please add it to your
91
+ `sidekiq.yml` as follows:
92
+ ```yml
93
+ :queues:
94
+ - [default, 10]
95
+ - [eventsimple, 10]
96
+ ```
97
+
85
98
  Generate a migration and add `Eventsimple` to an existing ActiveRecord model.
86
99
 
87
100
  ```ruby
data/eventsimple.gemspec CHANGED
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'pg', '~> 1.4'
29
29
  spec.add_runtime_dependency 'rails', '~> 7.0'
30
30
  spec.add_runtime_dependency 'retriable', '~> 3.1'
31
- spec.add_runtime_dependency 'sidekiq', '~> 7.0'
32
31
 
33
32
  spec.add_development_dependency 'bundle-audit'
34
33
  spec.add_development_dependency 'fuubar'
@@ -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,29 +4,12 @@ module Eventsimple
4
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.1'
4
+ VERSION = '1.1.3'
5
5
  end
data/lib/eventsimple.rb CHANGED
@@ -9,10 +9,10 @@ require 'active_support'
9
9
  require 'dry-types'
10
10
  require 'dry-struct'
11
11
  require 'retriable'
12
- require 'sidekiq'
13
12
 
14
13
  require 'dry_types'
15
14
 
15
+ require 'eventsimple/active_job/arguments'
16
16
  require 'eventsimple/configuration'
17
17
  require 'eventsimple/message'
18
18
  require 'eventsimple/data_type'
@@ -21,7 +21,6 @@ require 'eventsimple/metadata'
21
21
  require 'eventsimple/dispatcher'
22
22
  require 'eventsimple/event_dispatcher'
23
23
  require 'eventsimple/reactor'
24
- require 'eventsimple/reactor_worker'
25
24
  require 'eventsimple/invalid_transition'
26
25
 
27
26
  require 'eventsimple/entity'
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.1
4
+ version: 1.1.3
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-19 00:00:00.000000000 Z
11
+ date: 2023-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.1'
83
- - !ruby/object:Gem::Dependency
84
- name: sidekiq
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '7.0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '7.0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundle-audit
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -253,6 +239,7 @@ files:
253
239
  - eventsimple.gemspec
254
240
  - lib/dry_types.rb
255
241
  - lib/eventsimple.rb
242
+ - lib/eventsimple/active_job/arguments.rb
256
243
  - lib/eventsimple/configuration.rb
257
244
  - lib/eventsimple/data_type.rb
258
245
  - lib/eventsimple/dispatcher.rb