Skip to content

Commit

Permalink
fix concurrency initialization (#67)
Browse files Browse the repository at this point in the history
Fix bug where concurrency was not initialized correctly.
  • Loading branch information
desheikh authored May 22, 2024
1 parent c0f684e commit 3858b52
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 1.5.1 - 2024-05-13
### Changed
- Fix bug where outbox concurrency was not being configured correctly.

## 1.5.0 - 2024-05-07
### Changed
- The outbox consumer processes event batches concurrently
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
eventsimple (1.5.0)
eventsimple (1.5.1)
concurrent-ruby (>= 1.2.3)
dry-struct (~> 1.6)
dry-types (~> 1.7)
Expand Down Expand Up @@ -184,7 +184,7 @@ GEM
minitest (5.22.2)
mutex_m (0.2.0)
nenv (0.3.0)
net-imap (0.4.10)
net-imap (0.4.11)
date
net-protocol
net-pop (0.1.2)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ module UserComponent

identitfier 'UserComponent::Consumer'
consumes_event UserEvent
processor EventProcessor
concurrency 5 # default is 5
processor EventProcessor, concurrency: 5
end
end
```
Expand Down
7 changes: 2 additions & 5 deletions lib/eventsimple/outbox/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ def consumes_event(event_klass)
self._event_klass = event_klass
end

def processor(processor_klass)
def processor(processor_klass, concurrency: 5)
self._concurrency = concurrency
self._processor_klass = processor_klass
self._processor_pool = _concurrency.times.map { processor_klass.new }
end

def concurrency(concurrency)
self._concurrency = concurrency
end

def start # rubocop:disable Metrics/AbcSize
Signal.trap('INT') do
self.stop_consumer = true
Expand Down
2 changes: 1 addition & 1 deletion lib/eventsimple/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Eventsimple
VERSION = '1.5.0'
VERSION = '1.5.1'
end
1 change: 1 addition & 0 deletions spec/dummy/spec/components/user_component/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

run_consumer

expect(described_class._processor_pool.size).to eq(5)
expect(described_class._processor_pool[0]).to have_received(:call).once
expect(described_class._processor_pool[1]).to have_received(:call).once
expect(described_class._processor_pool[2]).to have_received(:call).once
Expand Down

0 comments on commit 3858b52

Please sign in to comment.