deimos-ruby 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +33 -30
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -6
- data/deimos-ruby.gemspec +15 -11
- data/karafka.rb +7 -4
- data/lib/deimos/active_record_consume/batch_consumption.rb +7 -7
- data/lib/deimos/active_record_consume/batch_record.rb +2 -2
- data/lib/deimos/active_record_consume/message_consumption.rb +6 -5
- data/lib/deimos/active_record_consume/schema_model_converter.rb +2 -2
- data/lib/deimos/active_record_consumer.rb +1 -0
- data/lib/deimos/active_record_producer.rb +4 -2
- data/lib/deimos/backends/base.rb +1 -3
- data/lib/deimos/backends/outbox.rb +1 -1
- data/lib/deimos/config/configuration.rb +88 -75
- data/lib/deimos/consume/batch_consumption.rb +5 -5
- data/lib/deimos/consume/message_consumption.rb +3 -3
- data/lib/deimos/ext/consumer_route.rb +3 -3
- data/lib/deimos/ext/producer_metrics_listener.rb +2 -2
- data/lib/deimos/ext/producer_middleware.rb +19 -15
- data/lib/deimos/ext/producer_route.rb +3 -1
- data/lib/deimos/ext/routing_defaults.rb +9 -7
- data/lib/deimos/ext/schema_route.rb +22 -15
- data/lib/deimos/kafka_message.rb +1 -1
- data/lib/deimos/kafka_source.rb +36 -31
- data/lib/deimos/kafka_topic_info.rb +1 -1
- data/lib/deimos/logging.rb +20 -19
- data/lib/deimos/message.rb +1 -1
- data/lib/deimos/metrics/minimal_datadog_listener.rb +19 -6
- data/lib/deimos/metrics/provider.rb +4 -4
- data/lib/deimos/producer.rb +3 -1
- data/lib/deimos/railtie.rb +1 -1
- data/lib/deimos/schema_backends/avro_base.rb +1 -1
- data/lib/deimos/schema_backends/avro_schema_coercer.rb +46 -27
- data/lib/deimos/schema_backends/avro_schema_registry.rb +8 -8
- data/lib/deimos/schema_backends/base.rb +9 -9
- data/lib/deimos/schema_backends/plain.rb +1 -1
- data/lib/deimos/schema_backends/proto_base.rb +7 -5
- data/lib/deimos/schema_backends/proto_local.rb +0 -2
- data/lib/deimos/schema_backends/proto_schema_registry.rb +0 -2
- data/lib/deimos/schema_class/base.rb +1 -1
- data/lib/deimos/schema_class/record.rb +3 -3
- data/lib/deimos/test_helpers.rb +31 -26
- data/lib/deimos/tracing/provider.rb +5 -5
- data/lib/deimos/transcoder.rb +6 -2
- data/lib/deimos/utils/db_poller/base.rb +3 -3
- data/lib/deimos/utils/deadlock_retry.rb +2 -2
- data/lib/deimos/utils/outbox_producer.rb +14 -14
- data/lib/deimos/version.rb +1 -1
- data/lib/deimos.rb +4 -4
- data/lib/generators/deimos/active_record_generator.rb +2 -1
- data/lib/generators/deimos/db_poller_generator.rb +1 -0
- data/lib/generators/deimos/outbox_backend_generator.rb +1 -0
- data/lib/generators/deimos/schema_class_generator.rb +3 -2
- data/lib/generators/deimos/v2_generator.rb +184 -155
- data/spec/active_record_batch_consumer_association_spec.rb +6 -2
- data/spec/active_record_batch_consumer_spec.rb +83 -106
- data/spec/active_record_consume/batch_consumption_spec.rb +27 -28
- data/spec/active_record_consume/batch_slicer_spec.rb +4 -12
- data/spec/active_record_consume/mass_updater_spec.rb +42 -46
- data/spec/active_record_consume/schema_model_converter_spec.rb +1 -1
- data/spec/active_record_consumer_spec.rb +7 -5
- data/spec/active_record_producer_spec.rb +83 -73
- data/spec/backends/outbox_spec.rb +1 -1
- data/spec/batch_consumer_spec.rb +20 -20
- data/spec/consumer_spec.rb +23 -12
- data/spec/gen/sample/v1/sample_pb.rb +3 -3
- data/spec/generators/active_record_generator_spec.rb +4 -4
- data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +2 -1
- data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +9 -2
- data/spec/generators/schema_class_generator_spec.rb +5 -5
- data/spec/kafka_source_spec.rb +13 -6
- data/spec/kafka_topic_info_spec.rb +7 -7
- data/spec/karafka/karafka.rb +6 -5
- data/spec/karafka_config/karafka_spec.rb +22 -19
- data/spec/logging_spec.rb +2 -0
- data/spec/producer_spec.rb +25 -20
- data/spec/schema_backends/avro_base_shared.rb +8 -8
- data/spec/schema_backends/avro_local_spec.rb +5 -6
- data/spec/schema_backends/avro_schema_registry_spec.rb +5 -6
- data/spec/schema_backends/proto_schema_registry_spec.rb +9 -12
- data/spec/schemas/my_namespace/generated.rb +1 -2
- data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +5 -8
- data/spec/schemas/my_namespace/my_schema_with_union_type.rb +22 -23
- data/spec/spec_helper.rb +13 -17
- data/spec/utils/db_poller_spec.rb +5 -5
- data/spec/utils/deadlock_retry_spec.rb +1 -4
- data/spec/utils/outbox_producer_spec.rb +36 -24
- metadata +68 -161
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c65bec6ee47b3c7fc30871b7124d0dea51b7cfc831b07a4f36eb27c48636fc1
|
|
4
|
+
data.tar.gz: bb411d26783b61f8737c70ddb8045d99a0673324ddef9eaa61bfa5c3c3e8933c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cfbb246222b9bbf795f9614f3c5ca9e15f217a84bec6c9f0d3e454179295a8c16539e36827f34dd4af2474568d6ecc7e6296fae5197a92be28ab7c8a72903c4
|
|
7
|
+
data.tar.gz: 6fef3d36d1b7ad788eb40a985c24b50205c96bec6cabb13f6b6d29b37dcae2cabbe142ddce0622fa33fcfd7d087a1d1ae50756bd338754bf427c4d420ef8d1bc
|
data/.rubocop.yml
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
plugins:
|
|
4
|
+
- rubocop-rspec
|
|
4
5
|
|
|
5
6
|
AllCops:
|
|
6
7
|
TargetRubyVersion: 2.5
|
|
7
8
|
Exclude:
|
|
8
9
|
- lib/deimos/monkey_patches/*.rb
|
|
10
|
+
- spec/gen/**/*.rb
|
|
11
|
+
- lib/deimos/ext/routing_defaults.rb # provided by Maciej
|
|
9
12
|
- vendor/**/*
|
|
10
13
|
- Guardfile
|
|
11
14
|
NewCops: enable
|
|
15
|
+
SuggestExtensions: false
|
|
16
|
+
|
|
17
|
+
Gemspec/DevelopmentDependencies:
|
|
18
|
+
EnforcedStyle: gemspec
|
|
12
19
|
|
|
13
20
|
# class Plumbus
|
|
14
21
|
# private
|
|
@@ -41,9 +48,9 @@ Layout/EmptyLinesAroundBlockBody:
|
|
|
41
48
|
Layout/LineLength:
|
|
42
49
|
Max: 120
|
|
43
50
|
Severity: refactor
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
SplitStrings: true
|
|
52
|
+
Exclude:
|
|
53
|
+
- bin/console # this causes LineLength to crash for some reason on line 15
|
|
47
54
|
|
|
48
55
|
# foo = if expression
|
|
49
56
|
# 'bar'
|
|
@@ -73,6 +80,10 @@ Lint/AssignmentInCondition:
|
|
|
73
80
|
AllowSafeAssignment: false
|
|
74
81
|
Severity: convention
|
|
75
82
|
|
|
83
|
+
Lint/UnderscorePrefixedVariableName:
|
|
84
|
+
Exclude:
|
|
85
|
+
- spec/schemas/**/*.rb
|
|
86
|
+
|
|
76
87
|
Lint/UnusedBlockArgument:
|
|
77
88
|
AllowUnusedKeywordArguments: true
|
|
78
89
|
|
|
@@ -81,7 +92,10 @@ Lint/UnusedMethodArgument:
|
|
|
81
92
|
|
|
82
93
|
Metrics/AbcSize:
|
|
83
94
|
Severity: refactor
|
|
84
|
-
Max:
|
|
95
|
+
Max: 40
|
|
96
|
+
Exclude:
|
|
97
|
+
- lib/generators/deimos/v2_generator.rb
|
|
98
|
+
- lib/deimos/test_helpers.rb
|
|
85
99
|
|
|
86
100
|
Metrics/BlockLength:
|
|
87
101
|
Enabled: false
|
|
@@ -108,7 +122,10 @@ Metrics/ParameterLists:
|
|
|
108
122
|
|
|
109
123
|
Metrics/PerceivedComplexity:
|
|
110
124
|
Severity: refactor
|
|
111
|
-
Max:
|
|
125
|
+
Max: 15
|
|
126
|
+
Exclude:
|
|
127
|
+
- lib/generators/deimos/v2_generator.rb
|
|
128
|
+
- lib/deimos/test_helpers.rb
|
|
112
129
|
|
|
113
130
|
# Use alias_method instead of alias
|
|
114
131
|
Style/Alias:
|
|
@@ -152,20 +169,8 @@ Style/CollectionMethods:
|
|
|
152
169
|
Style/DateTime:
|
|
153
170
|
AllowCoercion: true
|
|
154
171
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# Exclude:
|
|
158
|
-
# - 'app/controllers/**/*'
|
|
159
|
-
# - 'app/helpers/**/*'
|
|
160
|
-
# - 'db/**/*'
|
|
161
|
-
|
|
162
|
-
# Force documentation for public methods and classes
|
|
163
|
-
Style/DocumentationMethod:
|
|
164
|
-
Enabled: true
|
|
165
|
-
# TODO: uncomment the file below once rubocop is fixed
|
|
166
|
-
# Exclude:
|
|
167
|
-
# - 'app/controllers/**/*'
|
|
168
|
-
# - 'db/**/*'
|
|
172
|
+
Style/Documentation:
|
|
173
|
+
Enabled: false
|
|
169
174
|
|
|
170
175
|
# Allow else with just nil in it
|
|
171
176
|
Style/EmptyElse:
|
|
@@ -202,7 +207,7 @@ Style/LineEndConcatenation:
|
|
|
202
207
|
# Require parentheses around all method arguments except for whitelist
|
|
203
208
|
Style/MethodCallWithArgsParentheses:
|
|
204
209
|
Enabled: true
|
|
205
|
-
|
|
210
|
+
AllowedMethods:
|
|
206
211
|
- puts
|
|
207
212
|
- render
|
|
208
213
|
- redirect_to
|
|
@@ -236,10 +241,6 @@ Style/MethodCallWithArgsParentheses:
|
|
|
236
241
|
- before_destroy
|
|
237
242
|
- after_destroy
|
|
238
243
|
- queue_as
|
|
239
|
-
# TODO: uncomment the file below once rubocop is fixed
|
|
240
|
-
# Exclude:
|
|
241
|
-
# - 'bin/**/*'
|
|
242
|
-
# - 'Gemfile'
|
|
243
244
|
|
|
244
245
|
# Do not allow "end.something"
|
|
245
246
|
Style/MethodCalledOnDoEndBlock:
|
|
@@ -292,10 +293,6 @@ RSpec/ExampleLength:
|
|
|
292
293
|
RSpec/ExampleWording:
|
|
293
294
|
Enabled: false
|
|
294
295
|
|
|
295
|
-
# Allow describing specs without only using classes and methods
|
|
296
|
-
RSpec/FilePath:
|
|
297
|
-
Enabled: false
|
|
298
|
-
|
|
299
296
|
# Use before(:each), not before or before(:example)
|
|
300
297
|
RSpec/HookArgument:
|
|
301
298
|
EnforcedStyle: each
|
|
@@ -318,9 +315,12 @@ RSpec/MessageSpies:
|
|
|
318
315
|
Enabled: false
|
|
319
316
|
|
|
320
317
|
RSpec/MultipleExpectations:
|
|
321
|
-
Max:
|
|
318
|
+
Max: 20
|
|
322
319
|
Severity: refactor
|
|
323
320
|
|
|
321
|
+
RSpec/MultipleMemoizedHelpers:
|
|
322
|
+
Max: 10
|
|
323
|
+
|
|
324
324
|
# Allow both and_return() and block returns (use these for multi-line)
|
|
325
325
|
RSpec/ReturnFromStub:
|
|
326
326
|
Enabled: false
|
|
@@ -334,6 +334,9 @@ RSpec/ExpectActual:
|
|
|
334
334
|
RSpec/BeforeAfterAll:
|
|
335
335
|
Enabled: false
|
|
336
336
|
|
|
337
|
+
RSpec/SpecFilePathFormat:
|
|
338
|
+
Enabled: false
|
|
339
|
+
|
|
337
340
|
Security/YAMLLoad:
|
|
338
341
|
Exclude:
|
|
339
342
|
- 'lib/deimos.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## UNRELEASED
|
|
9
9
|
|
|
10
|
+
# 2.2.1 - 2025-11-13
|
|
11
|
+
|
|
12
|
+
- Fix: The global `use_schema_classes` setting wasn't being respected.
|
|
13
|
+
- Fix: `fetch_record` was being passed a hash even if `use_schema_classes` was set to true.
|
|
14
|
+
- Fix crash on ERB 6.0 (legacy_trim_mode is removed)
|
|
15
|
+
|
|
10
16
|
# 2.2.0 - 2025-11-11
|
|
11
17
|
|
|
12
18
|
- Feature: Support Protobuf as a schema backend.
|
data/Gemfile
CHANGED
data/deimos-ruby.gemspec
CHANGED
|
@@ -15,37 +15,41 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
18
|
spec.require_paths = ['lib']
|
|
20
19
|
|
|
21
|
-
spec.
|
|
22
|
-
spec.
|
|
23
|
-
spec.
|
|
24
|
-
spec.
|
|
25
|
-
spec.
|
|
20
|
+
spec.add_dependency('avro_turf', '>= 1.4', '< 2')
|
|
21
|
+
spec.add_dependency('benchmark', '~> 0.5')
|
|
22
|
+
spec.add_dependency('fig_tree', '~> 0.2.0')
|
|
23
|
+
spec.add_dependency('karafka', '~> 2.0')
|
|
24
|
+
spec.add_dependency('sigurd', '>= 0.1.0', '< 1.0')
|
|
26
25
|
|
|
27
26
|
spec.add_development_dependency('activerecord-import')
|
|
28
|
-
spec.add_development_dependency('activerecord-trilogy-adapter')
|
|
29
27
|
spec.add_development_dependency('avro', '~> 1.9')
|
|
30
28
|
spec.add_development_dependency('database_cleaner', '~> 2.1')
|
|
31
29
|
spec.add_development_dependency('ddtrace', '>= 0.11')
|
|
32
30
|
spec.add_development_dependency('dogstatsd-ruby', '>= 4.2')
|
|
33
|
-
spec.add_development_dependency('proto_turf')
|
|
34
31
|
spec.add_development_dependency('guard', '~> 2')
|
|
35
32
|
spec.add_development_dependency('guard-rspec', '~> 4')
|
|
36
33
|
spec.add_development_dependency('guard-rubocop', '~> 1')
|
|
37
34
|
spec.add_development_dependency('karafka-testing', '~> 2.0')
|
|
38
|
-
spec.add_development_dependency('trilogy', '>= 0.1')
|
|
39
35
|
spec.add_development_dependency('pg', '~> 1.1')
|
|
36
|
+
spec.add_development_dependency('proto_turf')
|
|
40
37
|
spec.add_development_dependency('rails', '~> 8.0')
|
|
41
38
|
spec.add_development_dependency('rake', '~> 13')
|
|
42
39
|
spec.add_development_dependency('rspec', '~> 3')
|
|
43
40
|
spec.add_development_dependency('rspec_junit_formatter', '~>0.3')
|
|
44
41
|
spec.add_development_dependency('rspec-rails', '~> 8.0')
|
|
45
42
|
spec.add_development_dependency('rspec-snapshot', '~> 2.0')
|
|
46
|
-
spec.add_development_dependency('rubocop', '
|
|
47
|
-
spec.add_development_dependency('rubocop-rspec', '
|
|
43
|
+
spec.add_development_dependency('rubocop', '~> 1.0')
|
|
44
|
+
spec.add_development_dependency('rubocop-rspec', '3.8')
|
|
48
45
|
spec.add_development_dependency('sord', '>= 5.0')
|
|
49
46
|
spec.add_development_dependency('sqlite3', '~> 2.7')
|
|
50
47
|
spec.add_development_dependency('steep', '~> 1.0')
|
|
48
|
+
spec.add_development_dependency('trilogy', '>= 0.1')
|
|
49
|
+
|
|
50
|
+
# for older activerecord
|
|
51
|
+
spec.add_development_dependency('bigdecimal')
|
|
52
|
+
spec.add_development_dependency('mutex_m')
|
|
53
|
+
|
|
54
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
51
55
|
end
|
data/karafka.rb
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Used in regenerate_test_schema_classes.rb
|
|
2
4
|
|
|
3
5
|
class MyConsumer < Deimos::Consumer
|
|
4
|
-
def consume(payload, metadata)
|
|
6
|
+
def consume(payload, metadata)
|
|
7
|
+
end
|
|
5
8
|
end
|
|
6
9
|
|
|
7
|
-
require_relative
|
|
10
|
+
require_relative 'lib/generators/deimos/schema_class_generator'
|
|
8
11
|
|
|
9
12
|
Deimos.configure do |deimos_config|
|
|
10
13
|
deimos_config.schema.nest_child_schemas = true
|
|
11
|
-
deimos_config.schema.path =
|
|
14
|
+
deimos_config.schema.path = 'spec/schemas'
|
|
12
15
|
deimos_config.schema.backend = :avro_validation
|
|
13
16
|
deimos_config.schema.generated_class_path = './spec/schemas'
|
|
14
17
|
deimos_config.schema.use_full_namespace = true
|
|
@@ -21,7 +24,7 @@ end
|
|
|
21
24
|
class KarafkaApp < Karafka::App
|
|
22
25
|
setup do
|
|
23
26
|
config.kafka = {
|
|
24
|
-
|
|
27
|
+
'bootstrap.servers': '127.0.0.1:9092'
|
|
25
28
|
}
|
|
26
29
|
end
|
|
27
30
|
routes.draw do
|
|
@@ -30,7 +30,7 @@ module Deimos
|
|
|
30
30
|
tag = topic.name
|
|
31
31
|
Deimos.config.tracer.active_span.set_tag('topic', tag)
|
|
32
32
|
|
|
33
|
-
Karafka.monitor.instrument('deimos.ar_consumer.consume_batch', {topic: tag}) do
|
|
33
|
+
Karafka.monitor.instrument('deimos.ar_consumer.consume_batch', { topic: tag }) do
|
|
34
34
|
if @compacted && deimos_messages.map(&:key).compact.any?
|
|
35
35
|
update_database(compact_messages(deimos_messages))
|
|
36
36
|
else
|
|
@@ -154,9 +154,9 @@ module Deimos
|
|
|
154
154
|
invalid = filter_records(record_list)
|
|
155
155
|
if invalid.any?
|
|
156
156
|
Karafka.monitor.instrument('deimos.batch_consumption.invalid_records', {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
records: invalid,
|
|
158
|
+
consumer: self.class
|
|
159
|
+
})
|
|
160
160
|
end
|
|
161
161
|
return if record_list.empty?
|
|
162
162
|
|
|
@@ -171,9 +171,9 @@ module Deimos
|
|
|
171
171
|
save_associations_first: self.save_associations_first,
|
|
172
172
|
bulk_import_id_column: self.bulk_import_id_column)
|
|
173
173
|
Karafka.monitor.instrument('deimos.batch_consumption.valid_records', {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
records: updater.mass_update(record_list),
|
|
175
|
+
consumer: self.class
|
|
176
|
+
})
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
# @param record_list [BatchRecordList]
|
|
@@ -43,8 +43,8 @@ module Deimos
|
|
|
43
43
|
def validate_import_id!
|
|
44
44
|
return if @klass.column_names.include?(self.bulk_import_column.to_s)
|
|
45
45
|
|
|
46
|
-
raise "Create bulk_import_id on the #{@klass.table_name} table." \
|
|
47
|
-
|
|
46
|
+
raise "Create bulk_import_id on the #{@klass.table_name} table. " \
|
|
47
|
+
'Run rails g deimos:bulk_import_id {table} to create the migration.'
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# @return [Class < ActiveRecord::Base]
|
|
@@ -8,6 +8,7 @@ module Deimos
|
|
|
8
8
|
# as ActiveRecord instances.
|
|
9
9
|
module MessageConsumption
|
|
10
10
|
include Deimos::Consume::MessageConsumption
|
|
11
|
+
|
|
11
12
|
# Find the record specified by the given payload and key.
|
|
12
13
|
# Default is to use the primary key column and the value of the first
|
|
13
14
|
# field in the key.
|
|
@@ -33,16 +34,16 @@ module Deimos
|
|
|
33
34
|
def consume_message(message)
|
|
34
35
|
unless self.process_message?(message)
|
|
35
36
|
Deimos::Logging.log_debug(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
message: 'Skipping processing of message',
|
|
38
|
+
payload: message.payload.to_h,
|
|
39
|
+
metadata: Deimos::Logging.metadata_log_text(message.metadata)
|
|
40
|
+
)
|
|
40
41
|
return
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
klass = self.class.config[:record_class]
|
|
44
45
|
payload = message.payload
|
|
45
|
-
if payload.is_a?(Hash) || payload.nil?
|
|
46
|
+
if payload.is_a?(Hash) || payload.nil?
|
|
46
47
|
payload = payload.to_h.with_indifferent_access
|
|
47
48
|
end
|
|
48
49
|
record = fetch_record(klass, payload, message.key)
|
|
@@ -56,6 +56,7 @@ module Deimos
|
|
|
56
56
|
|
|
57
57
|
def encoder
|
|
58
58
|
raise "No schema or namespace configured for #{self.name}" if karafka_config.nil?
|
|
59
|
+
|
|
59
60
|
karafka_config.deserializers[:payload].backend
|
|
60
61
|
end
|
|
61
62
|
|
|
@@ -71,7 +72,8 @@ module Deimos
|
|
|
71
72
|
payload.delete_if do |k, _|
|
|
72
73
|
k.to_sym != :payload_key && !fields.map(&:name).include?(k)
|
|
73
74
|
end
|
|
74
|
-
return payload
|
|
75
|
+
return payload if self.karafka_config.use_schema_classes.nil? &&
|
|
76
|
+
!Deimos.config.schema.use_schema_classes
|
|
75
77
|
|
|
76
78
|
Utils::SchemaClass.instance(payload, encoder.schema, encoder.namespace)
|
|
77
79
|
end
|
|
@@ -93,7 +95,7 @@ module Deimos
|
|
|
93
95
|
# @param min_id [Numeric] the minimum ID (i.e. all IDs must be greater
|
|
94
96
|
# than this value).
|
|
95
97
|
# @return [ActiveRecord::Relation]
|
|
96
|
-
def poll_query(time_from:, time_to:, column_name: :updated_at
|
|
98
|
+
def poll_query(time_from:, time_to:, min_id:, column_name: :updated_at)
|
|
97
99
|
klass = @record_class
|
|
98
100
|
table = ActiveRecord::Base.connection.quote_table_name(klass.table_name)
|
|
99
101
|
column = ActiveRecord::Base.connection.quote_column_name(column_name)
|
data/lib/deimos/backends/base.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Deimos
|
|
|
12
12
|
topic = producer_class.topic
|
|
13
13
|
execute(producer_class: producer_class, messages: messages)
|
|
14
14
|
message = ::Deimos::Logging.messages_log_text(producer_class.karafka_config.payload_log, messages)
|
|
15
|
-
Deimos::Logging.log_info({message: "Publishing Messages for #{topic}:" }.merge(message))
|
|
15
|
+
Deimos::Logging.log_info({ message: "Publishing Messages for #{topic}:" }.merge(message))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# @param producer_class [Class<Deimos::Producer>]
|
|
@@ -22,8 +22,6 @@ module Deimos
|
|
|
22
22
|
raise MissingImplementationError
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
private
|
|
26
|
-
|
|
27
25
|
end
|
|
28
26
|
end
|
|
29
27
|
end
|
|
@@ -13,7 +13,7 @@ module Deimos
|
|
|
13
13
|
records = messages.map do |m|
|
|
14
14
|
Deimos::ProducerMiddleware.call(m)
|
|
15
15
|
message = Deimos::KafkaMessage.new(
|
|
16
|
-
message: m[:payload]
|
|
16
|
+
message: m[:payload]&.to_s&.b,
|
|
17
17
|
topic: m[:topic],
|
|
18
18
|
partition_key: partition_key_for(m)
|
|
19
19
|
)
|