eventsimple 1.5.7 → 1.7.0

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: 1ad06b055da4ac9aac198693559193edbc58df0dc35276c37a35399740c95f06
4
- data.tar.gz: 23153c0fc74d8336f76108013bcc2b9f48f9d46c4dfa1e96368e08fce7704e82
3
+ metadata.gz: 6c0e02b9b7b00100a888407cfd7dfb4422f468fb2ee7807d0a174996be66d12d
4
+ data.tar.gz: 89f100e610caeff2b34d2a0a67b934e701845548007bacbef0d814f221f7c7bc
5
5
  SHA512:
6
- metadata.gz: 46087d727d23121cc684c4f799624f2c1f44d47a7c040caa1f4a8d3935af09d09e075743d737b587482271d235fc1925a710922017641e9ac58d2b979e670d5a
7
- data.tar.gz: 7f1d1d568bbb9245b869ad7a23f48b236b46c0472867c987d7cc9ead26232483319ada8eea80400a323a236c939bec93bb2db46fef63a08a405bfa8367f3be9f
6
+ metadata.gz: a2cd191a5940f13eaa79cd75b2cf4285a52f34e35b5b463ac568ceebca6c2f2c804b99c329bb622c4dd8e368a6a7bfe671cd248f4a62493aa59a81de11b9f4cc
7
+ data.tar.gz: 80a78a2b932b5c3784432bf66a731f169ac70f161bc1330d63d70ad642cc005eea3f8fc640416121a7bb8f21f1de65cf68062686843ac39ff3dc0898c1200a49
data/.rubocop.yml CHANGED
@@ -1,18 +1,95 @@
1
- inherit_gem:
2
- ws-style:
3
- - default.yml
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
5
+ plugins:
6
+ - rubocop-performance
7
+ - rubocop-rails
8
+ - rubocop-rspec
9
+ - rubocop-rspec_rails
10
+ - rubocop-factory_bot
4
11
 
5
12
  AllCops:
13
+ NewCops: disable
6
14
  Exclude:
7
15
  - "spec/dummy/bin/**/*"
8
16
  - "spec/dummy/db/migrate/**/*"
9
17
  - "spec/dummy/db/schema.rb"
10
18
  - "spec/dummy/log/**/*"
11
19
  - "spec/dummy/tmp/**/*"
12
- TargetRubyVersion: 3.2
20
+
21
+ Layout/ArgumentAlignment:
22
+ Enabled: true
23
+ EnforcedStyle: with_fixed_indentation
24
+
25
+ Layout/DotPosition:
26
+ EnforcedStyle: trailing
27
+
28
+ Layout/LineLength:
29
+ Enabled: false
30
+
31
+ Metrics/AbcSize:
32
+ Enabled: false
33
+
34
+ Metrics/CyclomaticComplexity:
35
+ Enabled: false
36
+
37
+ Metrics/MethodLength:
38
+ Enabled: false
39
+
40
+ Metrics/ModuleLength:
41
+ Enabled: false
42
+
43
+ Metrics/PerceivedComplexity:
44
+ Enabled: false
13
45
 
14
46
  Rails/SkipsModelValidations:
15
47
  Enabled: false
16
48
 
17
- Vendor/StrictDryStruct:
49
+ RSpec/AnyInstance:
50
+ Enabled: false
51
+
52
+ RSpec/ExampleLength:
53
+ Enabled: false
54
+
55
+ RSpec/IndexedLet:
56
+ Enabled: false
57
+
58
+ RSpec/LetSetup:
18
59
  Enabled: false
60
+
61
+ RSpec/MessageSpies:
62
+ Enabled: false
63
+
64
+ RSpec/MultipleMemoizedHelpers:
65
+ Enabled: false
66
+
67
+ RSpec/MultipleExpectations:
68
+ Enabled: false
69
+
70
+ RSpec/NamedSubject:
71
+ Enabled: false
72
+
73
+ RSpec/NestedGroups:
74
+ Enabled: false
75
+
76
+ Style/BlockDelimiters:
77
+ Enabled: false
78
+
79
+ Style/Documentation:
80
+ Enabled: false
81
+
82
+ Style/IfUnlessModifier:
83
+ Enabled: false
84
+
85
+ Style/StringLiterals:
86
+ Enabled: false
87
+
88
+ Style/TrailingCommaInArguments:
89
+ EnforcedStyleForMultiline: comma
90
+
91
+ Style/TrailingCommaInArrayLiteral:
92
+ EnforcedStyleForMultiline: comma
93
+
94
+ Style/TrailingCommaInHashLiteral:
95
+ EnforcedStyleForMultiline: comma
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.3
1
+ 3.4.4
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.7.0 - 2025-06-27
10
+ ### Changed
11
+ - Verify optimistic locking column exists
12
+
13
+ ## 1.6.0 - 2025-06-27
14
+ ### Changed
15
+ - Remove ws-style as we no longer publish it to rubygems
16
+
9
17
  ## 1.5.7 - 2025-04-04
10
18
  ### Changed
11
19
  - Initializiation error on db:schema:load is fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.5.7)
4
+ eventsimple (1.7.0)
5
5
  concurrent-ruby (>= 1.2.3)
6
6
  dry-struct (~> 1.6)
7
7
  dry-types (~> 1.7)
@@ -87,9 +87,9 @@ GEM
87
87
  addressable (2.8.7)
88
88
  public_suffix (>= 2.0.2, < 7.0)
89
89
  ast (2.4.3)
90
- base64 (0.2.0)
91
- benchmark (0.4.0)
92
- bigdecimal (3.1.9)
90
+ base64 (0.3.0)
91
+ benchmark (0.4.1)
92
+ bigdecimal (3.2.2)
93
93
  builder (3.3.0)
94
94
  bundle-audit (0.1.0)
95
95
  bundler-audit
@@ -98,11 +98,11 @@ GEM
98
98
  thor (~> 1.0)
99
99
  coderay (1.1.3)
100
100
  concurrent-ruby (1.3.5)
101
- connection_pool (2.5.0)
101
+ connection_pool (2.5.3)
102
102
  crass (1.0.6)
103
103
  date (3.4.1)
104
- diff-lcs (1.6.1)
105
- drb (2.2.1)
104
+ diff-lcs (1.6.2)
105
+ drb (2.2.3)
106
106
  dry-core (1.1.0)
107
107
  concurrent-ruby (~> 1.0)
108
108
  logger
@@ -118,26 +118,27 @@ GEM
118
118
  dry-types (~> 1.8, >= 1.8.2)
119
119
  ice_nine (~> 0.11)
120
120
  zeitwerk (~> 2.6)
121
- dry-types (1.8.2)
121
+ dry-types (1.8.3)
122
122
  bigdecimal (~> 3.0)
123
123
  concurrent-ruby (~> 1.0)
124
124
  dry-core (~> 1.0)
125
125
  dry-inflector (~> 1.0)
126
126
  dry-logic (~> 1.4)
127
127
  zeitwerk (~> 2.6)
128
+ erb (5.0.1)
128
129
  erubi (1.13.1)
129
- factory_bot (6.5.1)
130
+ factory_bot (6.5.4)
130
131
  activesupport (>= 6.1.0)
131
- factory_bot_rails (6.4.4)
132
+ factory_bot_rails (6.5.0)
132
133
  factory_bot (~> 6.5)
133
- railties (>= 5.0.0)
134
- ffi (1.17.1-arm64-darwin)
135
- ffi (1.17.1-x86_64-linux-gnu)
134
+ railties (>= 6.1.0)
135
+ ffi (1.17.2-arm64-darwin)
136
+ ffi (1.17.2-x86_64-linux-gnu)
136
137
  formatador (1.1.0)
137
138
  fuubar (2.5.1)
138
139
  rspec-core (~> 3.0)
139
140
  ruby-progressbar (~> 1.4)
140
- git (3.0.0)
141
+ git (3.1.0)
141
142
  activesupport (>= 5.0)
142
143
  addressable (~> 2.8)
143
144
  process_executer (~> 1.3)
@@ -168,14 +169,14 @@ GEM
168
169
  pp (>= 0.6.0)
169
170
  rdoc (>= 4.0.0)
170
171
  reline (>= 0.4.2)
171
- json (2.10.2)
172
- language_server-protocol (3.17.0.4)
172
+ json (2.12.2)
173
+ language_server-protocol (3.17.0.5)
173
174
  lint_roller (1.1.0)
174
175
  listen (3.9.0)
175
176
  rb-fsevent (~> 0.10, >= 0.10.3)
176
177
  rb-inotify (~> 0.9, >= 0.9.10)
177
178
  logger (1.7.0)
178
- loofah (2.24.0)
179
+ loofah (2.24.1)
179
180
  crass (~> 1.0.2)
180
181
  nokogiri (>= 1.12.0)
181
182
  lumberjack (1.2.10)
@@ -189,7 +190,7 @@ GEM
189
190
  mini_mime (1.1.5)
190
191
  minitest (5.25.5)
191
192
  nenv (0.3.0)
192
- net-imap (0.5.6)
193
+ net-imap (0.5.9)
193
194
  date
194
195
  net-protocol
195
196
  net-pop (0.1.2)
@@ -199,18 +200,18 @@ GEM
199
200
  net-smtp (0.5.1)
200
201
  net-protocol
201
202
  nio4r (2.7.4)
202
- nokogiri (1.18.7-arm64-darwin)
203
+ nokogiri (1.18.8-arm64-darwin)
203
204
  racc (~> 1.4)
204
- nokogiri (1.18.7-x86_64-linux-gnu)
205
+ nokogiri (1.18.8-x86_64-linux-gnu)
205
206
  racc (~> 1.4)
206
207
  notiffany (0.1.3)
207
208
  nenv (~> 0.1)
208
209
  shellany (~> 0.0)
209
- ostruct (0.6.1)
210
- parallel (1.26.3)
210
+ ostruct (0.6.2)
211
+ parallel (1.27.0)
211
212
  parse_a_changelog (1.3.3)
212
213
  treetop (~> 1.6)
213
- parser (3.3.7.4)
214
+ parser (3.3.8.0)
214
215
  ast (~> 2.4.1)
215
216
  racc
216
217
  pg (1.5.9)
@@ -223,15 +224,15 @@ GEM
223
224
  pry (0.15.2)
224
225
  coderay (~> 1.1)
225
226
  method_source (~> 1.0)
226
- psych (5.2.3)
227
+ psych (5.2.6)
227
228
  date
228
229
  stringio
229
- public_suffix (6.0.1)
230
+ public_suffix (6.0.2)
230
231
  puma (6.6.0)
231
232
  nio4r (~> 2.0)
232
233
  racc (1.8.1)
233
- rack (3.1.12)
234
- rack-session (2.1.0)
234
+ rack (3.1.16)
235
+ rack-session (2.1.1)
235
236
  base64 (>= 0.1.0)
236
237
  rack (>= 3.0.0)
237
238
  rack-test (2.2.0)
@@ -252,7 +253,7 @@ GEM
252
253
  activesupport (= 8.0.2)
253
254
  bundler (>= 1.15.0)
254
255
  railties (= 8.0.2)
255
- rails-dom-testing (2.2.0)
256
+ rails-dom-testing (2.3.0)
256
257
  activesupport (>= 5.0.0)
257
258
  minitest
258
259
  nokogiri (>= 1.6)
@@ -268,39 +269,40 @@ GEM
268
269
  thor (~> 1.0, >= 1.2.2)
269
270
  zeitwerk (~> 2.6)
270
271
  rainbow (3.1.1)
271
- rake (13.2.1)
272
+ rake (13.3.0)
272
273
  rb-fsevent (0.11.2)
273
274
  rb-inotify (0.11.1)
274
275
  ffi (~> 1.0)
275
276
  rchardet (1.9.0)
276
- rdoc (6.13.1)
277
+ rdoc (6.14.1)
278
+ erb
277
279
  psych (>= 4.0.0)
278
280
  regexp_parser (2.10.0)
279
281
  reline (0.6.1)
280
282
  io-console (~> 0.5)
281
283
  retriable (3.1.2)
282
- rspec (3.13.0)
284
+ rspec (3.13.1)
283
285
  rspec-core (~> 3.13.0)
284
286
  rspec-expectations (~> 3.13.0)
285
287
  rspec-mocks (~> 3.13.0)
286
- rspec-core (3.13.3)
288
+ rspec-core (3.13.5)
287
289
  rspec-support (~> 3.13.0)
288
- rspec-expectations (3.13.3)
290
+ rspec-expectations (3.13.5)
289
291
  diff-lcs (>= 1.2.0, < 2.0)
290
292
  rspec-support (~> 3.13.0)
291
- rspec-mocks (3.13.2)
293
+ rspec-mocks (3.13.5)
292
294
  diff-lcs (>= 1.2.0, < 2.0)
293
295
  rspec-support (~> 3.13.0)
294
- rspec-rails (7.1.1)
295
- actionpack (>= 7.0)
296
- activesupport (>= 7.0)
297
- railties (>= 7.0)
296
+ rspec-rails (8.0.1)
297
+ actionpack (>= 7.2)
298
+ activesupport (>= 7.2)
299
+ railties (>= 7.2)
298
300
  rspec-core (~> 3.13)
299
301
  rspec-expectations (~> 3.13)
300
302
  rspec-mocks (~> 3.13)
301
303
  rspec-support (~> 3.13)
302
- rspec-support (3.13.2)
303
- rubocop (1.75.2)
304
+ rspec-support (3.13.4)
305
+ rubocop (1.77.0)
304
306
  json (~> 2.3)
305
307
  language_server-protocol (~> 3.17.0.2)
306
308
  lint_roller (~> 1.1.0)
@@ -308,49 +310,36 @@ GEM
308
310
  parser (>= 3.3.0.2)
309
311
  rainbow (>= 2.2.2, < 4.0)
310
312
  regexp_parser (>= 2.9.3, < 3.0)
311
- rubocop-ast (>= 1.44.0, < 2.0)
313
+ rubocop-ast (>= 1.45.1, < 2.0)
312
314
  ruby-progressbar (~> 1.7)
313
315
  unicode-display_width (>= 2.4.0, < 4.0)
314
- rubocop-ast (1.44.0)
316
+ rubocop-ast (1.45.1)
315
317
  parser (>= 3.3.7.2)
316
318
  prism (~> 1.4)
317
319
  rubocop-factory_bot (2.27.1)
318
320
  lint_roller (~> 1.1)
319
321
  rubocop (~> 1.72, >= 1.72.1)
320
- rubocop-performance (1.24.0)
322
+ rubocop-performance (1.25.0)
321
323
  lint_roller (~> 1.1)
322
- rubocop (>= 1.72.1, < 2.0)
324
+ rubocop (>= 1.75.0, < 2.0)
323
325
  rubocop-ast (>= 1.38.0, < 2.0)
324
- rubocop-rails (2.26.2)
326
+ rubocop-rails (2.32.0)
325
327
  activesupport (>= 4.2.0)
328
+ lint_roller (~> 1.1)
326
329
  rack (>= 1.1)
327
- rubocop (>= 1.52.0, < 2.0)
328
- rubocop-ast (>= 1.31.1, < 2.0)
329
- rubocop-rspec (3.5.0)
330
+ rubocop (>= 1.75.0, < 2.0)
331
+ rubocop-ast (>= 1.44.0, < 2.0)
332
+ rubocop-rspec (3.6.0)
330
333
  lint_roller (~> 1.1)
331
334
  rubocop (~> 1.72, >= 1.72.1)
332
- rubocop-vendor (0.14.2)
333
- lint_roller
334
- rubocop
335
+ rubocop-rspec_rails (2.31.0)
336
+ lint_roller (~> 1.1)
337
+ rubocop (~> 1.72, >= 1.72.1)
338
+ rubocop-rspec (~> 3.5)
335
339
  ruby-progressbar (1.13.0)
336
340
  securerandom (0.4.1)
337
341
  shellany (0.0.1)
338
- standard (1.35.0.1)
339
- language_server-protocol (~> 3.17.0.2)
340
- lint_roller (~> 1.0)
341
- rubocop (~> 1.62)
342
- standard-custom (~> 1.0.0)
343
- standard-performance (~> 1.3)
344
- standard-custom (1.0.2)
345
- lint_roller (~> 1.0)
346
- rubocop (~> 1.50)
347
- standard-performance (1.7.0)
348
- lint_roller (~> 1.1)
349
- rubocop-performance (~> 1.24.0)
350
- standard-rails (1.2.0)
351
- lint_roller (~> 1.0)
352
- rubocop-rails (~> 2.26.0)
353
- stringio (3.1.6)
342
+ stringio (3.1.7)
354
343
  thor (1.3.2)
355
344
  timeout (0.4.3)
356
345
  treetop (1.6.14)
@@ -362,25 +351,19 @@ GEM
362
351
  unicode-emoji (4.0.4)
363
352
  uri (1.0.3)
364
353
  useragent (0.16.11)
365
- websocket-driver (0.7.7)
354
+ websocket-driver (0.8.0)
366
355
  base64
367
356
  websocket-extensions (>= 0.1.0)
368
357
  websocket-extensions (0.1.5)
369
- with_advisory_lock (5.1.0)
358
+ with_advisory_lock (5.3.0)
370
359
  activerecord (>= 6.1)
371
360
  zeitwerk (>= 2.6)
372
- ws-style (7.7.2)
373
- rubocop-factory_bot (>= 2.26.0)
374
- rubocop-rspec (>= 3.0.0)
375
- rubocop-vendor (>= 0.14.2)
376
- standard (>= 1.30.1)
377
- standard-custom (>= 1.0.2)
378
- standard-rails (>= 0.1.0)
379
- zeitwerk (2.7.2)
361
+ zeitwerk (2.7.3)
380
362
 
381
363
  PLATFORMS
382
364
  arm64-darwin-22
383
365
  arm64-darwin-23
366
+ arm64-darwin-24
384
367
  x86_64-linux
385
368
 
386
369
  DEPENDENCIES
@@ -394,7 +377,12 @@ DEPENDENCIES
394
377
  pry
395
378
  puma
396
379
  rspec-rails
397
- ws-style
380
+ rubocop
381
+ rubocop-factory_bot
382
+ rubocop-performance
383
+ rubocop-rails
384
+ rubocop-rspec
385
+ rubocop-rspec_rails
398
386
 
399
387
  BUNDLED WITH
400
- 2.3.26
388
+ 2.6.9
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A sample Guardfile
2
4
  # More info at https://github.com/guard/guard#readme
3
5
 
data/README.md CHANGED
@@ -281,9 +281,6 @@ For many use cases, async reactors are sufficient to handle workflows like makin
281
281
 
282
282
  The current implementation leverages a single advisory lock to guarantee write order. This will impact write throughput on the model. On a db.rg6.large Aurora instance for example, write throughput to the table is ~300 events per second.
283
283
 
284
- For an explaination of why an advisory lock is required:
285
- https://github.com/pawelpacana/account-basics
286
-
287
284
  ### Setup an ordered outbox
288
285
 
289
286
  Generate migration to setup the outbox cursor table. This table is used to track cursor positions.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class ApplicationController < ActionController::Base
3
5
  helper_method :event_class_names
@@ -1,16 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class EntitiesController < ApplicationController
3
- # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
4
5
  def show
5
6
  @model_name = params[:model_name]
6
7
  @model_class = event_classes.find { |d| d.name == @model_name }
7
8
  @aggregate_id = params[:id]
8
9
  @event_id = params[:e] || -1
9
- @tab_id = (params[:t] == 'event') ? 'event' : 'entity'
10
+ @tab_id = params[:t] == 'event' ? 'event' : 'entity'
10
11
 
11
12
  filter_columns = @model_class._filter_attributes
12
13
  params_filters = params.permit(filters: {})[:filters] || {}
13
- @filters = filter_columns.to_h { |column| [column, params_filters[column]] }
14
+ @filters = filter_columns.index_with { |column| params_filters[column] }
14
15
 
15
16
  primary_key = @model_class.event_class._aggregate_id
16
17
  @entity = @model_class.find_by!(primary_key => @aggregate_id)
@@ -28,7 +29,6 @@ module Eventsimple
28
29
  @error_message = e.message
29
30
  render html: '', layout: true
30
31
  end
31
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
32
32
 
33
33
  private
34
34
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class HomeController < ApplicationController
3
5
  def index; end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class ModelsController < ApplicationController
3
5
  def show
@@ -17,7 +19,7 @@ module Eventsimple
17
19
  filter_columns = model_class._filter_attributes
18
20
 
19
21
  params_filters = params.permit(filters: {})[:filters] || {}
20
- @filters = filter_columns.to_h { |column| [column, params_filters[column]] }
22
+ @filters = filter_columns.index_with { |column| params_filters[column] }
21
23
 
22
24
  return model_event_class unless @filters.any?
23
25
 
@@ -25,6 +27,7 @@ module Eventsimple
25
27
  model_event_class = model_event_class.joins(aggregate_class_symbol)
26
28
  @filters.each do |key, value|
27
29
  next if value.blank?
30
+
28
31
  key = model_event_class._aggregate_id if key == :aggregate_id
29
32
  model_event_class = model_event_class.where({ aggregate_class_symbol => { key => value } })
30
33
  end
data/catalog-info.yaml CHANGED
@@ -9,3 +9,4 @@ metadata:
9
9
  spec:
10
10
  type: library
11
11
  lifecycle: production
12
+ owner: engineering
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Eventsimple::Engine.routes.draw do
2
4
  root to: 'home#index'
3
5
 
data/eventsimple.gemspec CHANGED
@@ -23,13 +23,13 @@ Gem::Specification.new do |spec|
23
23
  end
24
24
  spec.require_paths = ['lib']
25
25
 
26
+ spec.add_runtime_dependency 'concurrent-ruby', '>= 1.2.3'
26
27
  spec.add_runtime_dependency 'dry-struct', '~> 1.6'
27
28
  spec.add_runtime_dependency 'dry-types', '~> 1.7'
28
29
  spec.add_runtime_dependency 'pg', '~> 1.4'
29
30
  spec.add_runtime_dependency 'rails', '>= 7.0', '< 9.0'
30
31
  spec.add_runtime_dependency 'retriable', '~> 3.1'
31
32
  spec.add_runtime_dependency 'with_advisory_lock', '>= 5.1'
32
- spec.add_runtime_dependency 'concurrent-ruby', '>= 1.2.3'
33
33
 
34
34
  spec.add_development_dependency 'bundle-audit'
35
35
  spec.add_development_dependency 'fuubar'
@@ -39,5 +39,10 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency 'pry'
40
40
  spec.add_development_dependency 'puma'
41
41
  spec.add_development_dependency 'rspec-rails'
42
- spec.add_development_dependency 'ws-style'
42
+ spec.add_development_dependency 'rubocop'
43
+ spec.add_development_dependency 'rubocop-factory_bot'
44
+ spec.add_development_dependency 'rubocop-performance'
45
+ spec.add_development_dependency 'rubocop-rails'
46
+ spec.add_development_dependency 'rubocop-rspec'
47
+ spec.add_development_dependency 'rubocop-rspec_rails'
43
48
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_job/arguments'
2
4
 
3
5
  module ActiveJob
4
6
  module Arguments
5
- extend self
7
+ extend self # rubocop:disable Style/ModuleFunction
6
8
 
7
9
  def deserialize_global_id(hash)
8
10
  gid = GlobalID.parse(hash[GLOBALID_KEY])
@@ -3,11 +3,8 @@
3
3
  module Eventsimple
4
4
  class Configuration
5
5
  attr_reader :max_concurrency_retries
6
- attr_writer :metadata_klass
7
- attr_writer :parent_record_klass
8
- attr_accessor :retry_reactor_on_record_not_found
9
-
10
- attr_accessor :ui_visible_models
6
+ attr_writer :metadata_klass, :parent_record_klass
7
+ attr_accessor :retry_reactor_on_record_not_found, :ui_visible_models
11
8
 
12
9
  def initialize
13
10
  @dispatchers = []
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class Dispatcher
3
5
  def self.on(*events, sync: [], async: [])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails'
2
4
 
3
5
  module Eventsimple
@@ -1,9 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  module Entity
3
5
  DEFAULT_IGNORE_PROPS = %w[id lock_version].freeze
4
6
 
5
7
  def event_driven_by(event_klass, aggregate_id:, filter_attributes: [])
6
8
  begin
9
+ if table_exists? && !column_names.include?(locking_column)
10
+ raise ArgumentError, "A #{locking_column} column is required to enable optimistic locking"
11
+ end
12
+
7
13
  if defined?(event_klass._aggregate_id) && event_klass.table_exists? && table_exists?
8
14
  raise ArgumentError, "aggregate_id mismatch event:#{event_klass._aggregate_id} entity:#{aggregate_id}" if aggregate_id != event_klass._aggregate_id
9
15
 
@@ -13,6 +19,7 @@ module Eventsimple
13
19
  raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
14
20
  end
15
21
  rescue ActiveRecord::NoDatabaseError
22
+ # skip checks if the database is not yet created
16
23
  end
17
24
 
18
25
  has_many :events, class_name: event_klass.name.to_s,
@@ -53,10 +60,10 @@ module Eventsimple
53
60
  was_readonly = @readonly
54
61
  @readonly = false
55
62
 
56
- if block
57
- yield self
58
- @readonly = true if was_readonly
59
- end
63
+ return unless block
64
+
65
+ yield self
66
+ @readonly = was_readonly
60
67
  end
61
68
 
62
69
  def reproject(at: nil)
@@ -1,21 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  module Event
3
5
  require 'globalid'
4
6
  include GlobalID::Identification
5
7
 
6
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
7
8
  def drives_events_for(aggregate_klass, aggregate_id:, events_namespace: nil)
8
9
  begin
9
10
  if defined?(aggregate_klass._aggregate_id) && aggregate_klass.table_exists? && table_exists?
10
11
  raise ArgumentError, "aggregate_id mismatch event:#{aggregate_id} entity:#{aggregate_klass._aggregate_id}" if aggregate_id != aggregate_klass._aggregate_id
11
12
 
12
- aggregate_column_type_in_event = aggregate_klass.column_for_attribute(aggregate_klass._aggregate_id).type unless aggregate_klass.attribute_names.blank?
13
- aggregate_column_type_in_entity = column_for_attribute(:aggregate_id).type unless aggregate_klass.attribute_names.blank?
13
+ aggregate_column_type_in_event = aggregate_klass.column_for_attribute(aggregate_klass._aggregate_id).type if aggregate_klass.attribute_names.present?
14
+ aggregate_column_type_in_entity = column_for_attribute(:aggregate_id).type if aggregate_klass.attribute_names.present?
14
15
 
15
16
  raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
16
17
 
17
18
  end
18
19
  rescue ActiveRecord::NoDatabaseError
20
+ # skip checks if the database is not yet created
19
21
  end
20
22
 
21
23
  class_attribute :_events_namespace
@@ -57,7 +59,6 @@ module Eventsimple
57
59
  include InstanceMethods
58
60
  extend ClassMethods
59
61
  end
60
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
61
62
 
62
63
  module InstanceMethods
63
64
  def skip_dispatcher
@@ -135,7 +136,7 @@ module Eventsimple
135
136
  # Events for an entity are expected to be namespaced under _events_namespace.
136
137
  def find_sti_class(type_name)
137
138
  if _events_namespace.blank?
138
- super(type_name)
139
+ super
139
140
  else
140
141
  super("#{_events_namespace}::#{type_name}")
141
142
  end
@@ -180,7 +181,7 @@ module Eventsimple
180
181
  end
181
182
  end
182
183
 
183
- def with_retries(args, &) # rubocop:disable Metrics/AbcSize
184
+ def with_retries(args, &)
184
185
  entity = args[0][_aggregate_klass.model_name.element.to_sym]
185
186
 
186
187
  # Only implement retries when the event is not already inside a transaction.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Eventsimple
2
4
  class InvalidTransition < StandardError
3
5
  attr_reader :klass
@@ -33,10 +33,10 @@ module Eventsimple
33
33
  def processor(processor_klass, concurrency: 5)
34
34
  self._concurrency = concurrency
35
35
  self._processor_klass = processor_klass
36
- self._processor_pool = _concurrency.times.map { processor_klass.new }
36
+ self._processor_pool = Array.new(_concurrency) { processor_klass.new }
37
37
  end
38
38
 
39
- def start # rubocop:disable Metrics/AbcSize
39
+ def start
40
40
  Signal.trap('INT') do
41
41
  self.stop_consumer = true
42
42
  $stdout.puts('INT received, stopping consumer')
@@ -4,7 +4,7 @@ module Eventsimple
4
4
  class Reactor < ActiveJob::Base # rubocop:disable Rails/ApplicationJob
5
5
  queue_as :eventsimple
6
6
 
7
- discard_on ActiveJob::DeserializationError do |job, error|
7
+ discard_on ActiveJob::DeserializationError do |job, _error|
8
8
  Rails.logger.warn("Event #{job.arguments.first} not found for reactor: #{self.class}")
9
9
  end
10
10
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.5.7'
4
+ VERSION = '1.7.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: concurrent-ruby
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.2.3
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.2.3
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: dry-struct
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -101,21 +114,21 @@ dependencies:
101
114
  - !ruby/object:Gem::Version
102
115
  version: '5.1'
103
116
  - !ruby/object:Gem::Dependency
104
- name: concurrent-ruby
117
+ name: bundle-audit
105
118
  requirement: !ruby/object:Gem::Requirement
106
119
  requirements:
107
120
  - - ">="
108
121
  - !ruby/object:Gem::Version
109
- version: 1.2.3
110
- type: :runtime
122
+ version: '0'
123
+ type: :development
111
124
  prerelease: false
112
125
  version_requirements: !ruby/object:Gem::Requirement
113
126
  requirements:
114
127
  - - ">="
115
128
  - !ruby/object:Gem::Version
116
- version: 1.2.3
129
+ version: '0'
117
130
  - !ruby/object:Gem::Dependency
118
- name: bundle-audit
131
+ name: fuubar
119
132
  requirement: !ruby/object:Gem::Requirement
120
133
  requirements:
121
134
  - - ">="
@@ -129,7 +142,7 @@ dependencies:
129
142
  - !ruby/object:Gem::Version
130
143
  version: '0'
131
144
  - !ruby/object:Gem::Dependency
132
- name: fuubar
145
+ name: git
133
146
  requirement: !ruby/object:Gem::Requirement
134
147
  requirements:
135
148
  - - ">="
@@ -143,7 +156,7 @@ dependencies:
143
156
  - !ruby/object:Gem::Version
144
157
  version: '0'
145
158
  - !ruby/object:Gem::Dependency
146
- name: git
159
+ name: guard-rspec
147
160
  requirement: !ruby/object:Gem::Requirement
148
161
  requirements:
149
162
  - - ">="
@@ -157,7 +170,7 @@ dependencies:
157
170
  - !ruby/object:Gem::Version
158
171
  version: '0'
159
172
  - !ruby/object:Gem::Dependency
160
- name: guard-rspec
173
+ name: parse_a_changelog
161
174
  requirement: !ruby/object:Gem::Requirement
162
175
  requirements:
163
176
  - - ">="
@@ -171,7 +184,7 @@ dependencies:
171
184
  - !ruby/object:Gem::Version
172
185
  version: '0'
173
186
  - !ruby/object:Gem::Dependency
174
- name: parse_a_changelog
187
+ name: pry
175
188
  requirement: !ruby/object:Gem::Requirement
176
189
  requirements:
177
190
  - - ">="
@@ -185,7 +198,7 @@ dependencies:
185
198
  - !ruby/object:Gem::Version
186
199
  version: '0'
187
200
  - !ruby/object:Gem::Dependency
188
- name: pry
201
+ name: puma
189
202
  requirement: !ruby/object:Gem::Requirement
190
203
  requirements:
191
204
  - - ">="
@@ -199,7 +212,7 @@ dependencies:
199
212
  - !ruby/object:Gem::Version
200
213
  version: '0'
201
214
  - !ruby/object:Gem::Dependency
202
- name: puma
215
+ name: rspec-rails
203
216
  requirement: !ruby/object:Gem::Requirement
204
217
  requirements:
205
218
  - - ">="
@@ -213,7 +226,63 @@ dependencies:
213
226
  - !ruby/object:Gem::Version
214
227
  version: '0'
215
228
  - !ruby/object:Gem::Dependency
216
- name: rspec-rails
229
+ name: rubocop
230
+ requirement: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - ">="
233
+ - !ruby/object:Gem::Version
234
+ version: '0'
235
+ type: :development
236
+ prerelease: false
237
+ version_requirements: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ - !ruby/object:Gem::Dependency
243
+ name: rubocop-factory_bot
244
+ requirement: !ruby/object:Gem::Requirement
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ version: '0'
249
+ type: :development
250
+ prerelease: false
251
+ version_requirements: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ - !ruby/object:Gem::Dependency
257
+ name: rubocop-performance
258
+ requirement: !ruby/object:Gem::Requirement
259
+ requirements:
260
+ - - ">="
261
+ - !ruby/object:Gem::Version
262
+ version: '0'
263
+ type: :development
264
+ prerelease: false
265
+ version_requirements: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ - !ruby/object:Gem::Dependency
271
+ name: rubocop-rails
272
+ requirement: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: '0'
277
+ type: :development
278
+ prerelease: false
279
+ version_requirements: !ruby/object:Gem::Requirement
280
+ requirements:
281
+ - - ">="
282
+ - !ruby/object:Gem::Version
283
+ version: '0'
284
+ - !ruby/object:Gem::Dependency
285
+ name: rubocop-rspec
217
286
  requirement: !ruby/object:Gem::Requirement
218
287
  requirements:
219
288
  - - ">="
@@ -227,7 +296,7 @@ dependencies:
227
296
  - !ruby/object:Gem::Version
228
297
  version: '0'
229
298
  - !ruby/object:Gem::Dependency
230
- name: ws-style
299
+ name: rubocop-rspec_rails
231
300
  requirement: !ruby/object:Gem::Requirement
232
301
  requirements:
233
302
  - - ">="
@@ -303,7 +372,6 @@ licenses:
303
372
  - MIT
304
373
  metadata:
305
374
  changelog_uri: https://github.com/wealthsimple/eventsimple/blob/main/CHANGELOG.md
306
- post_install_message:
307
375
  rdoc_options: []
308
376
  require_paths:
309
377
  - lib
@@ -318,8 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
386
  - !ruby/object:Gem::Version
319
387
  version: '0'
320
388
  requirements: []
321
- rubygems_version: 3.4.19
322
- signing_key:
389
+ rubygems_version: 3.6.7
323
390
  specification_version: 4
324
391
  summary: Event sourcing toolkit using Rails and ActiveJob
325
392
  test_files: []