dionysus-rb 0.4.0 → 0.5.0

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: '0934079a452c75d517f1954e9cc6650c4b6219273c329013b676f336ea0d9e13'
4
- data.tar.gz: bee752d4720e8f4249867ecf3506b725fa9ba9cd678ebadf9ac0ac893c635925
3
+ metadata.gz: 64406a4ca852cfc6d663586730005d9c562121571cb0b876de7584eb63b2c49f
4
+ data.tar.gz: c30a51ca9f590795e55021209f274d67a18aa197bd2ebb7be3ed471940ee7f6a
5
5
  SHA512:
6
- metadata.gz: e12c164f5909f35e9b0d4336fb31ebb3d79e064409243beaad6e40c32f5590ff296ee805601de312b111fcc5fbb10d86008064cb2c229de56d7eab8518e6c9f9
7
- data.tar.gz: 6a0fffb5d3b4d65eab34a0aaa16871002b8713addb45e07a1094706559fc978d5b37c885d6d2179c481bea436eddfe9805db0385a464ddb6a70b056ccf10e489
6
+ metadata.gz: bd48b03ee34b15dd0481733a9bdd726ef23c871d2a6a19249501ffa5ebb200559a2c301785a0e9449e79059eb98f3166da2c70049d087003dc2684c89ab0a013
7
+ data.tar.gz: 13f6d2e1068ea38a8c8954e594fe36382d8d6a061228c5f1f9c5de722651c495363be8569874757ce8f1fe41232495597676532d7e56da1a5a3fe25a4c0a32f1
data/.rubocop_todo.yml CHANGED
@@ -12,6 +12,7 @@ Layout/LineLength:
12
12
  - 'lib/dionysus.rb'
13
13
  - 'lib/dionysus/consumer/persistor.rb'
14
14
  - 'lib/dionysus/producer/genesis/streamer/standard_job.rb'
15
+ - 'lib/dionysus/consumer/batch_events_publisher.rb'
15
16
  - 'spec/dionysus/consumer/karafka_consumer_generator_spec.rb'
16
17
  - 'spec/dionysus/producer/outbox/publisher_spec.rb'
17
18
  - 'spec/dionysus/producer/genesis_spec.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0]
4
+ - Publish consumed messages batch as `dionysus.consume_batch` event.
5
+
3
6
  ## [0.4.0]
4
7
  - Allow `Dionysus::Producer::Genesis::StreamJob`/`Dionysus::Producer::Genesis::Streamer` to take more options and perform filtering by extra conditions. This is useful if you only need to stream some of the records.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dionysus-rb (0.4.0)
4
+ dionysus-rb (0.5.0)
5
5
  activerecord (>= 5)
6
6
  activesupport (>= 3.2)
7
7
  concurrent-ruby
data/README.md CHANGED
@@ -194,7 +194,7 @@ Dionysus::Producer.responders_for(Record).each do |responder|
194
194
  message = [].tap do |current_message|
195
195
  current_message << ["record_created", created_records.to_a, {}]
196
196
  if canceled_records.any?
197
- current_message << ["record_destroyed", canceled_records.map { |record| RecordPrometheusDTO.new(record) }, { serialize: false }]
197
+ current_message << ["record_destroyed", canceled_records.map { |record| RecordDionysusDTO.new(record) }, { serialize: false }]
198
198
  end
199
199
  end
200
200
 
@@ -1137,7 +1137,7 @@ Dionysus::Consumer.configure do |config|
1137
1137
  config.resolve_synced_data_hash_proc = ->(record) { record.synced_data_model.synced_data_hash } # optional, defaults to ->(record) { record.public_send(Dionysus::Consumer.configuration.synced_data_attribute).to_h }
1138
1138
  config.sidekiq_queue = :default # optional, defaults to `:dionysus`
1139
1139
  config.message_filter = FilterIgnoringLargeMessageToAvoidOutofMemoryErrors.new(error_handler: Sentry) # DEPRECATED - not required, defaults to Dionysus::Utils::DefaultMessageFilter, which doesn't ignore any messages. It can be useful when you want to ignore some messages, e.g. some very large ones that would cause OOM error. Check the implementation of `Dionysus::Utils::DefaultMessageFilter for more details to understand what kind of arguments are available to set the condition. `error_handler` needs to implement Sentry-like interface. Kept for backwards compatibility, please use `message_filters` instead.
1140
- config.message_filters = [FilterIgnoringLargeMessageToAvoidOutofMemoryErrors.new(error_handler: Sentry)] # not required, defaults to [Dionysus::Utils::DefaultMessageFilter], which doesn't ignore any messages. It can be useful when you want to ignore some messages, e.g. some very large ones that would cause OOM error. Check the implementation of `Dionysus::Utils::DefaultMessageFilter for more details to understand what kind of arguments are available to set the condition. `error_handler` needs to implement Sentry-like interface.
1140
+ config.message_filters = [FilterIgnoringLargeMessageToAvoidOutofMemoryErrors.new(error_handler: Sentry)] # not required, defaults to [Dionysus::Utils::DefaultMessageFilter], which doesn't ignore any messages. It can be useful when you want to ignore some messages, e.g. some very large ones that would cause OOM error. Check the implementation of `Dionysus::Utils::DefaultMessageFilter for more details to understand what kind of arguments are available to set the condition. `error_handler` needs to implement Sentry-like interface.
1141
1141
 
1142
1142
  # if you ever need to provide mapping:
1143
1143
 
@@ -1154,7 +1154,9 @@ end
1154
1154
 
1155
1155
  Check publisher for reference about instrumentation and event bus. The only difference is about the methods that are instrumented and events that are published.
1156
1156
 
1157
- For the event bus, you may expect the `dionysus.consume` event. It contains the following attributes:
1157
+ For the event bus, you may expect two events:
1158
+
1159
+ 1. `dionysus.consume` event. It contains the following attributes:
1158
1160
  - `topic_name`, e.g. "v3_inbox", "v3_rentals"
1159
1161
  - `model_name`, e.g. "Conversation", "Rental"
1160
1162
  - `event_name`, e.g. "rental_created", "converation_updated", "message_destroyed"
@@ -1168,6 +1170,8 @@ For the event bus, you may expect the `dionysus.consume` event. It contains the
1168
1170
  }
1169
1171
  ```
1170
1172
 
1173
+ 2. `dionysus.consume_batch` event. It's essentially an array of events available under `dionysus.consume` event representing an entire Karafka consumers messages' batch.
1174
+
1171
1175
  Event bus is the recommended way to do something upon consuming events if you want to avoid putting that logic into ActiveRecord callbacks.
1172
1176
 
1173
1177
 
@@ -11,8 +11,10 @@ class Dionysus::Consumer::BatchEventsPublisher
11
11
 
12
12
  def publish(processed_events)
13
13
  processed_events
14
- .map(&method(:to_event_data))
15
- .each(&method(:publish_via_event_bus))
14
+ .map { |dionysus_event| to_event_data(dionysus_event) }
15
+ .select(&:present?) # potentially necessary for some Kafka versions? couldn't reproduce this reliably, but the integration spec added a tombstone message for `publish_events_batch_via_event_bus` in the older version
16
+ .then { |mapped_events| publish_events_batch_via_event_bus(mapped_events) }
17
+ .then { |mapped_events| mapped_events.each { |event_data| publish_single_event_via_event_bus(event_data) } }
16
18
  end
17
19
 
18
20
  private
@@ -27,7 +29,12 @@ class Dionysus::Consumer::BatchEventsPublisher
27
29
  }
28
30
  end
29
31
 
30
- def publish_via_event_bus(event_data)
32
+ def publish_events_batch_via_event_bus(events_batch_data)
33
+ config.event_bus.publish("dionysus.consume_batch", events_batch_data)
34
+ events_batch_data
35
+ end
36
+
37
+ def publish_single_event_via_event_bus(event_data)
31
38
  config.event_bus.publish("dionysus.consume", event_data)
32
39
  end
33
40
  end
@@ -3,5 +3,5 @@
3
3
  module Dionysus
4
4
  module Version
5
5
  end
6
- VERSION = "0.4.0"
6
+ VERSION = "0.5.0"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dionysus-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-23 00:00:00.000000000 Z
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord