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 +4 -4
- data/.rubocop_todo.yml +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -3
- data/lib/dionysus/consumer/batch_events_publisher.rb +10 -3
- data/lib/dionysus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64406a4ca852cfc6d663586730005d9c562121571cb0b876de7584eb63b2c49f
|
4
|
+
data.tar.gz: c30a51ca9f590795e55021209f274d67a18aa197bd2ebb7be3ed471940ee7f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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|
|
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
|
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(
|
15
|
-
.
|
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
|
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
|
data/lib/dionysus/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|