Skip to content

Commit

Permalink
Merge branch 'hotfix/240605/rename-from-export_batch-to-process_batch…
Browse files Browse the repository at this point in the history
…' into 'master'

[DEX-240605] hotfix: rename from export_batch to process_batch

See merge request nstmrt/rubygems/sbmt-kafka_consumer!52
  • Loading branch information
bibendi committed Jun 5, 2024
2 parents 69bf6d5 + 26c3983 commit a1f6274
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [2.3.1] - 2024-06-05

### Fixed

- Rename from `export_batch` to `process_batch`

## [2.3.0] - 2024-05-30

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ require_relative "config/environment"
some-extra-configuration
```

### `Export batch`
### `Process batch`

To process messages in batches, you need to add the `export_batch` method in the consumer
To process messages in batches, you need to add the `process_batch` method in the consumer

```ruby
# app/consumers/some_consumer.rb
class SomeConsumer < Sbmt::KafkaConsumer::BaseConsumer
def export_batch(messages)
def process_batch(messages)
# some code
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/sbmt/kafka_consumer/base_consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def self.name

def consume
::Rails.application.executor.wrap do
if export_batch?
if process_batch?
with_batch_instrumentation(messages) do
export_batch(messages)
process_batch(messages)
mark_as_consumed!(messages.last)
end
else
Expand All @@ -30,11 +30,11 @@ def consume
end
end

def export_batch?
if @export_batch_memoized.nil?
@export_batch_memoized = respond_to?(:export_batch)
def process_batch?
if @process_batch_memoized.nil?
@process_batch_memoized = respond_to?(:process_batch)
end
@export_batch_memoized
@process_batch_memoized
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/sbmt/kafka_consumer/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Sbmt
module KafkaConsumer
VERSION = "2.3.0"
VERSION = "2.3.1"
end
end
6 changes: 3 additions & 3 deletions spec/sbmt/kafka_consumer/base_consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def process_message(_message)
let(:consumer_class) do
Class.new(described_class.consumer_klass) do
attr_reader :consumed
def export_batch(messages)
Rails.logger.info "Export batch #{messages.count} messages"
def process_batch(messages)
Rails.logger.info "Process batch #{messages.count} messages"
@consumed = true
end

Expand All @@ -119,7 +119,7 @@ def consumed?
it "consumes" do
consume_with_sbmt_karafka
expect(consumer).to be_consumed
expect(Rails.logger).to have_received(:info).with(/Export batch/)
expect(Rails.logger).to have_received(:info).with(/Process batch/)
end
end
end

0 comments on commit a1f6274

Please sign in to comment.