eventsimple 1.4.1 → 1.4.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: 78e8b529bc0609ec85f79d7490381461a2e870f44bbbce92e2d5dbb1e800c15a
4
- data.tar.gz: 73975b9169be6c278091016c98f05e482b62e0c6fc0dbe26e1a7baddb77c3a9a
3
+ metadata.gz: 89459aafe1f0b6343f5893f9921d43e2b41a77bdd051160f8206837589941dc7
4
+ data.tar.gz: 9920a2bd4454bc8f97fbf9d9fc036ddc3801508321602a27cf1236de005a3633
5
5
  SHA512:
6
- metadata.gz: 8ef1062b9f798d47b344efec4bcf2e76a051698c516e151d5356c0d3e334a2e52722fc17e6d330e9dfbe5d79588dcaf204af48d6b2fb733c37385c99fe41646c
7
- data.tar.gz: f001fcdefb2ae74e9f4b800d0397c1f67c92585a919ccf3c7e79da3894ecaa985fe1465ca226d9dcdb005ce3bc11bfc1ba8990ac4c1be179c82301c60266e5cd
6
+ metadata.gz: fa543c41fa1318ab325ad2be11586ba642f07ba4210cb9163b309023da7c56cffb9220ffa92af85b57f43011e02a38a3f60e416fa5c96e6c6a3da8ef5f465541
7
+ data.tar.gz: c6a1e7bda23440825c00effa10ae939690f9b0963dd5269b048df08de4ea7de72785a6f26a168a0b2ddc7e1e3a038e8d20a35fccc55465130688058ee04b342c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.2.3
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.4.3 - 2024-05-06
10
+ ### Changed
11
+ - The order of execution for synchronous reactors is now guaranteed to be the order in which they were registered.
12
+ - The shared examples for reactors `'an event which (a)synchronously dispatches'` now accept 1 or multiple arguments. The synchronous version checks that reactors are given in the order in which they are registered.
13
+
14
+ ## 1.4.2 - 2024-04-30
15
+ ### Changed
16
+ - Raise error on missing consumer config
17
+
9
18
  ## 1.4.1 - 2024-04-28
10
19
  ### Fixed
11
20
  - Fix Sidebar scroll
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.4.1)
4
+ eventsimple (1.4.3)
5
5
  dry-struct (~> 1.6)
6
6
  dry-types (~> 1.7)
7
7
  pg (~> 1.4)
@@ -55,6 +55,7 @@ module Eventsimple
55
55
  end
56
56
 
57
57
  # Return a ReactorSet containing all Reactors matching an Event
58
+ # Reactors will be in the order in which they were registered
58
59
  def for(event)
59
60
  reactors = ReactorSet.new
60
61
 
@@ -77,16 +78,16 @@ module Eventsimple
77
78
  attr_reader :sync, :async
78
79
 
79
80
  def initialize
80
- @sync = Set.new
81
- @async = Set.new
81
+ @sync = []
82
+ @async = []
82
83
  end
83
84
 
84
85
  def add_sync(reactors)
85
- @sync += reactors
86
+ @sync |= reactors
86
87
  end
87
88
 
88
89
  def add_async(reactors)
89
- @async += reactors
90
+ @async |= reactors
90
91
  end
91
92
  end
92
93
  end
@@ -12,11 +12,11 @@ module Eventsimple
12
12
  class_attribute :_processor_klass
13
13
  class_attribute :_processor
14
14
  class_attribute :stop_consumer, default: false
15
- class_attribute :_identifier, default: name.to_s
15
+ class_attribute :_identifier
16
16
  end
17
17
  end
18
18
 
19
- def identifier(name = nil)
19
+ def identifier(name)
20
20
  self._identifier = name
21
21
  end
22
22
 
@@ -46,6 +46,12 @@ module Eventsimple
46
46
  end
47
47
 
48
48
  def run_consumer(group_number:)
49
+ raise 'Eventsimple: No event class defined' unless _event_klass
50
+ raise 'Eventsimple: No processor defined' unless _processor
51
+ raise 'Eventsimple: No identifier defined' unless _identifier
52
+
53
+ Rails.logger.info("Starting consumer for #{_identifier}, processing #{_event_klass} events with group number #{group_number}")
54
+
49
55
  cursor = Outbox::Cursor.fetch(_identifier, group_number: group_number)
50
56
 
51
57
  until stop_consumer
@@ -1,18 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.shared_examples 'an event which synchronously dispatches' do |dispatcher_klass|
3
+ RSpec.shared_examples 'an event which synchronously dispatches' do |*dispatcher_klasses|
4
4
  specify do
5
5
  reactors = Eventsimple::EventDispatcher.rules.for(described_class.new)
6
6
 
7
- expect(reactors.sync).to include(dispatcher_klass)
7
+ # Order is important here since the synchronous reactors are executed sequentially
8
+ expect(reactors.sync & dispatcher_klasses).to eq(dispatcher_klasses)
8
9
  end
9
10
  end
10
11
 
11
- RSpec.shared_examples 'an event which asynchronously dispatches' do |dispatcher_klass|
12
+ RSpec.shared_examples 'an event which asynchronously dispatches' do |*dispatcher_klasses|
12
13
  specify do
13
14
  reactors = Eventsimple::EventDispatcher.rules.for(described_class.new)
14
15
 
15
- expect(reactors.async).to include(dispatcher_klass)
16
+ # Order is _not_ important here since async reactors have no order guarantee
17
+ expect(reactors.async).to include(*dispatcher_klasses)
16
18
  end
17
19
  end
18
20
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.4.1'
4
+ VERSION = '1.4.3'
5
5
  end
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.4.1
4
+ version: 1.4.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: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  - !ruby/object:Gem::Version
299
299
  version: '0'
300
300
  requirements: []
301
- rubygems_version: 3.4.10
301
+ rubygems_version: 3.4.19
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: Event sourcing toolkit using Rails and ActiveJob