dionysus-rb 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/dionysus/consumer/config.rb +10 -1
- data/lib/dionysus/consumer/params_batch_processor.rb +8 -4
- data/lib/dionysus/producer/genesis/stream_job.rb +3 -2
- data/lib/dionysus/producer/genesis/streamer.rb +19 -2
- data/lib/dionysus/producer/genesis.rb +1 -1
- 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: '0934079a452c75d517f1954e9cc6650c4b6219273c329013b676f336ea0d9e13'
|
4
|
+
data.tar.gz: bee752d4720e8f4249867ecf3506b725fa9ba9cd678ebadf9ac0ac893c635925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e12c164f5909f35e9b0d4336fb31ebb3d79e064409243beaad6e40c32f5590ff296ee805601de312b111fcc5fbb10d86008064cb2c229de56d7eab8518e6c9f9
|
7
|
+
data.tar.gz: 6a0fffb5d3b4d65eab34a0aaa16871002b8713addb45e07a1094706559fc978d5b37c885d6d2179c481bea436eddfe9805db0385a464ddb6a70b056ccf10e489
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.0]
|
4
|
+
- 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
|
+
|
6
|
+
## [0.3.0]
|
7
|
+
- Allow to provide multiple message filters. `message_filter` stays for backwards compatibility and depends on `message_filters`.
|
8
|
+
|
3
9
|
## [0.2.0]
|
4
10
|
- Fix creation of outbox records when updating a record that was soft-deleted
|
5
11
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1136,7 +1136,8 @@ Dionysus::Consumer.configure do |config|
|
|
1136
1136
|
config.synced_data_attribute = :synced_data # required, default: :synced_data
|
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
|
-
config.message_filter = 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.
|
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
1141
|
|
1141
1142
|
# if you ever need to provide mapping:
|
1142
1143
|
|
@@ -6,7 +6,7 @@ class Dionysus::Consumer::Config
|
|
6
6
|
:instrumenter, :event_bus, :soft_delete_strategy, :soft_deleted_at_timestamp_attribute,
|
7
7
|
:synced_created_at_timestamp_attribute, :synced_updated_at_timestamp_attribute, :synced_id_attribute,
|
8
8
|
:synced_data_attribute, :consumer_base_class, :retry_provider, :resolve_synced_data_hash_proc, :sidekiq_queue,
|
9
|
-
:
|
9
|
+
:message_filters
|
10
10
|
|
11
11
|
def self.default_sidekiq_queue
|
12
12
|
:dionysus
|
@@ -94,4 +94,13 @@ class Dionysus::Consumer::Config
|
|
94
94
|
@message_filter || Dionysus::Utils::DefaultMessageFilter.new(error_handler:
|
95
95
|
Dionysus::Utils::NullErrorHandler)
|
96
96
|
end
|
97
|
+
|
98
|
+
def message_filter=(val)
|
99
|
+
@message_filter = val
|
100
|
+
self.message_filters = [val]
|
101
|
+
end
|
102
|
+
|
103
|
+
def message_filters
|
104
|
+
@message_filters || Array.wrap(message_filter)
|
105
|
+
end
|
97
106
|
end
|
@@ -27,8 +27,9 @@ class Dionysus::Consumer::ParamsBatchProcessor
|
|
27
27
|
transformed_data = Dionysus::Consumer::Deserializer.new(data).deserialize
|
28
28
|
end
|
29
29
|
|
30
|
-
if
|
31
|
-
notify_about_ignored_message(topic: topic, message: message,
|
30
|
+
if (applicable_message_filter = find_applicable_message_filter(topic, message, transformed_data))
|
31
|
+
applicable_message_filter.notify_about_ignored_message(topic: topic, message: message,
|
32
|
+
transformed_data: transformed_data)
|
32
33
|
next
|
33
34
|
end
|
34
35
|
|
@@ -50,8 +51,11 @@ class Dionysus::Consumer::ParamsBatchProcessor
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
|
-
delegate :
|
54
|
-
|
54
|
+
delegate :message_filters, to: :config
|
55
|
+
|
56
|
+
def find_applicable_message_filter(topic, message, transformed_data)
|
57
|
+
message_filters.find { |f| f.ignore_message?(topic: topic, message: message, transformed_data: transformed_data) }
|
58
|
+
end
|
55
59
|
|
56
60
|
def instrument(label, options = {}, &block)
|
57
61
|
config.instrumenter.instrument(label, options, &block)
|
@@ -5,9 +5,10 @@ class Dionysus::Producer::Genesis::StreamJob
|
|
5
5
|
|
6
6
|
sidekiq_options queue: Dionysus::Producer::Config.default_sidekiq_queue
|
7
7
|
|
8
|
-
def perform(topic, model_klass, from, to, number_of_days, streamer_job)
|
8
|
+
def perform(topic, model_klass, from, to, number_of_days, streamer_job, options = {})
|
9
|
+
final_options = options.symbolize_keys.reverse_merge(number_of_days: number_of_days)
|
9
10
|
Dionysus::Producer::Genesis::Streamer
|
10
11
|
.new(job_class: streamer_job.constantize)
|
11
|
-
.stream(topic, model_klass.constantize, from, to,
|
12
|
+
.stream(topic, model_klass.constantize, from, to, final_options)
|
12
13
|
end
|
13
14
|
end
|
@@ -26,14 +26,31 @@ class Dionysus::Producer::Genesis::Streamer
|
|
26
26
|
delegate :soft_delete_column, to: :config
|
27
27
|
|
28
28
|
def fetch_resources(resource_class, from, to, options_hash)
|
29
|
-
|
30
|
-
|
29
|
+
resource_class
|
30
|
+
.then { |records| apply_time_range(records, from, to) }
|
31
|
+
.then { |records| apply_visibility(records, options_hash) }
|
32
|
+
.then { |records| apply_query_conditions(records, options_hash) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def apply_time_range(records, from, to)
|
36
|
+
records = records.where("updated_at BETWEEN ? AND ?", from, to) if from.present? && to.present?
|
37
|
+
records
|
38
|
+
end
|
39
|
+
|
40
|
+
def apply_visibility(records, options_hash)
|
31
41
|
if visible_only?(options_hash) && records.column_names.include?(soft_delete_column.to_s)
|
32
42
|
records = records.where(soft_delete_column => nil)
|
33
43
|
end
|
34
44
|
records
|
35
45
|
end
|
36
46
|
|
47
|
+
def apply_query_conditions(records, options_hash)
|
48
|
+
if (query_conditions = options_hash.fetch(:query_conditions, {})).any?
|
49
|
+
query_conditions.each { |attr, val| records = records.where(attr => val) }
|
50
|
+
end
|
51
|
+
records
|
52
|
+
end
|
53
|
+
|
37
54
|
def visible_only?(options_hash)
|
38
55
|
options_hash.fetch(:visible_only, false)
|
39
56
|
end
|
@@ -32,7 +32,7 @@ class Dionysus::Producer::Genesis
|
|
32
32
|
def enqueue_stream_model_for_topic(topic, model, from, to, number_of_days, streamer_job)
|
33
33
|
Dionysus::Producer::Genesis::StreamJob
|
34
34
|
.set(queue: sidekiq_queue)
|
35
|
-
.perform_async(topic.to_s, model.to_s, from.as_json, to.as_json, number_of_days.to_i, streamer_job.to_s)
|
35
|
+
.perform_async(topic.to_s, model.to_s, from.as_json, to.as_json, number_of_days.to_i, streamer_job.to_s, {})
|
36
36
|
end
|
37
37
|
|
38
38
|
def publish_genesis_performed(model:, topic:, number_of_days:)
|
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.4.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-
|
11
|
+
date: 2024-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|