Skip to content

Commit

Permalink
fix concurrency initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
desheikh committed May 14, 2024
1 parent c0f684e commit d26d3f4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
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 d26d3f4

Please sign in to comment.