deimos-ruby 1.16.4 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3 -3
- data/.rubocop.yml +20 -14
- data/.rubocop_todo.yml +364 -0
- data/.ruby-version +2 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +0 -1
- data/README.md +6 -2
- data/Steepfile +8 -0
- data/deimos-ruby.gemspec +3 -2
- data/docs/CONFIGURATION.md +2 -1
- data/lib/deimos/config/configuration.rb +2 -0
- data/lib/deimos/metrics/mock.rb +1 -1
- data/lib/deimos/schema_backends/mock.rb +1 -1
- data/lib/deimos/utils/db_poller.rb +49 -5
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/schema_class_generator.rb +1 -1
- data/rbs_collection.lock.yaml +16 -16
- data/sig/defs.rbs +9 -1
- data/sig/fig_tree.rbs +1 -1
- data/spec/consumer_spec.rb +14 -14
- data/spec/generators/schema_class/my_schema_spec.rb +3 -3
- data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +1 -1
- data/spec/producer_spec.rb +1 -1
- data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +3 -3
- data/spec/utils/db_poller_spec.rb +89 -46
- metadata +35 -22
- data/.gemfiles/avro_turf-0.gemfile +0 -3
- data/.gemfiles/avro_turf-1.gemfile +0 -3
- data/.ruby-gemset +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4270b2fc345a60377ead079f053ea92281bd606df2d24da782c583bf25e3b9
|
4
|
+
data.tar.gz: 6c824200ea66395439dfbc00a0478a30f1410d10032915fb063f94e0d7efbeb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db33a95a08af5e4d5a6e42ea7d8d7193432647afe1c18186d8d4dbf58dca3fa7994cf06c67abda80c841a918746fe4059e72386c6ab2d98080bd1e9aa727e25e
|
7
|
+
data.tar.gz: 8d091dfb4478e66dc898949bc87304dc82a48fc29e1c89e2b1235ea199d338a59c62cc8b29667a03eb45e45db846187feaa28f8f490db3beb17c8e70ddfb7cf0
|
data/.github/workflows/ci.yml
CHANGED
@@ -25,18 +25,18 @@ jobs:
|
|
25
25
|
ruby-version: 2.7
|
26
26
|
bundler-cache: true
|
27
27
|
|
28
|
+
- name: Bundle install
|
29
|
+
run: bundle install --with development
|
30
|
+
|
28
31
|
- name: Rubocop
|
29
32
|
run: bundle exec rubocop --format progress
|
30
33
|
|
31
34
|
build:
|
32
35
|
runs-on: ubuntu-latest
|
33
|
-
env:
|
34
|
-
BUNDLE_GEMFILE: ${{ github.workspace }}/.gemfiles/${{ matrix.gemfile }}.gemfile
|
35
36
|
strategy:
|
36
37
|
fail-fast: false
|
37
38
|
matrix:
|
38
39
|
ruby: [ '2.6', '2.7', '3.0', '3.1' ]
|
39
|
-
gemfile: [ 'avro_turf-0', 'avro_turf-1' ]
|
40
40
|
|
41
41
|
steps:
|
42
42
|
- uses: actions/checkout@v2
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
require: rubocop-rspec
|
2
4
|
|
3
5
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.5
|
5
7
|
Exclude:
|
6
8
|
- lib/deimos/monkey_patches/*.rb
|
7
9
|
- vendor/**/*
|
@@ -39,8 +41,9 @@ Layout/EmptyLinesAroundBlockBody:
|
|
39
41
|
Layout/LineLength:
|
40
42
|
Max: 120
|
41
43
|
Severity: refactor
|
42
|
-
|
43
|
-
|
44
|
+
# TODO: uncomment the files below once rubocop is fixed
|
45
|
+
# Exclude:
|
46
|
+
# - 'spec/**/*'
|
44
47
|
|
45
48
|
# foo = if expression
|
46
49
|
# 'bar'
|
@@ -149,18 +152,20 @@ Style/CollectionMethods:
|
|
149
152
|
Style/DateTime:
|
150
153
|
AllowCoercion: true
|
151
154
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
- 'app/
|
156
|
-
- '
|
155
|
+
# TODO: uncomment the lines below once rubocop is fixed
|
156
|
+
#Style/Documentation:
|
157
|
+
# Exclude:
|
158
|
+
# - 'app/controllers/**/*'
|
159
|
+
# - 'app/helpers/**/*'
|
160
|
+
# - 'db/**/*'
|
157
161
|
|
158
162
|
# Force documentation for public methods and classes
|
159
163
|
Style/DocumentationMethod:
|
160
164
|
Enabled: true
|
161
|
-
|
162
|
-
|
163
|
-
- '
|
165
|
+
# TODO: uncomment the file below once rubocop is fixed
|
166
|
+
# Exclude:
|
167
|
+
# - 'app/controllers/**/*'
|
168
|
+
# - 'db/**/*'
|
164
169
|
|
165
170
|
# Allow else with just nil in it
|
166
171
|
Style/EmptyElse:
|
@@ -231,9 +236,10 @@ Style/MethodCallWithArgsParentheses:
|
|
231
236
|
- before_destroy
|
232
237
|
- after_destroy
|
233
238
|
- queue_as
|
234
|
-
|
235
|
-
|
236
|
-
- '
|
239
|
+
# TODO: uncomment the file below once rubocop is fixed
|
240
|
+
# Exclude:
|
241
|
+
# - 'bin/**/*'
|
242
|
+
# - 'Gemfile'
|
237
243
|
|
238
244
|
# Do not allow "end.something"
|
239
245
|
Style/MethodCalledOnDoEndBlock:
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,364 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
3
|
+
# on 2022-09-08 19:46:52 UTC using RuboCop version 0.90.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'deimos-ruby.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 4
|
17
|
+
# Cop supports --auto-correct.
|
18
|
+
Layout/EmptyLines:
|
19
|
+
Exclude:
|
20
|
+
- 'spec/schemas/my_namespace/generated.rb'
|
21
|
+
- 'spec/schemas/my_namespace/my_nested_schema.rb'
|
22
|
+
- 'spec/schemas/my_namespace/my_schema_with_circular_reference.rb'
|
23
|
+
- 'spec/schemas/my_namespace/my_schema_with_complex_type.rb'
|
24
|
+
|
25
|
+
# Offense count: 32
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
# Configuration parameters: EnforcedStyle.
|
28
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
29
|
+
Layout/EmptyLinesAroundClassBody:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# Offense count: 1
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
Layout/EmptyLinesAroundMethodBody:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/generators/deimos/schema_class_generator.rb'
|
37
|
+
|
38
|
+
# Offense count: 42
|
39
|
+
# Cop supports --auto-correct.
|
40
|
+
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
41
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
42
|
+
Layout/EndAlignment:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Offense count: 4
|
46
|
+
# Cop supports --auto-correct.
|
47
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
48
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
49
|
+
Layout/FirstHashElementIndentation:
|
50
|
+
Exclude:
|
51
|
+
- 'spec/producer_spec.rb'
|
52
|
+
|
53
|
+
# Offense count: 19
|
54
|
+
# Cop supports --auto-correct.
|
55
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
56
|
+
# SupportedHashRocketStyles: key, separator, table
|
57
|
+
# SupportedColonStyles: key, separator, table
|
58
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
59
|
+
Layout/HashAlignment:
|
60
|
+
Exclude:
|
61
|
+
- 'spec/consumer_spec.rb'
|
62
|
+
- 'spec/generators/schema_class/my_schema_with_circular_reference_spec.rb'
|
63
|
+
|
64
|
+
# Offense count: 21
|
65
|
+
# Cop supports --auto-correct.
|
66
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
67
|
+
Layout/IndentationWidth:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
# Offense count: 9
|
71
|
+
# Cop supports --auto-correct.
|
72
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
73
|
+
# SupportedStylesForExponentOperator: space, no_space
|
74
|
+
Layout/SpaceAroundOperators:
|
75
|
+
Exclude:
|
76
|
+
- 'spec/generators/schema_class/my_schema_with_circular_reference_spec.rb'
|
77
|
+
- 'spec/generators/schema_class_generator_spec.rb'
|
78
|
+
- 'spec/schemas/my_namespace/my_schema_with_complex_type.rb'
|
79
|
+
|
80
|
+
# Offense count: 1
|
81
|
+
# Cop supports --auto-correct.
|
82
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
83
|
+
# SupportedStyles: space, no_space
|
84
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
85
|
+
Layout/SpaceInsideBlockBraces:
|
86
|
+
Exclude:
|
87
|
+
- 'spec/generators/schema_class_generator_spec.rb'
|
88
|
+
|
89
|
+
# Offense count: 1
|
90
|
+
# Cop supports --auto-correct.
|
91
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
92
|
+
# SupportedStyles: space, no_space, compact
|
93
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
94
|
+
Layout/SpaceInsideHashLiteralBraces:
|
95
|
+
Exclude:
|
96
|
+
- 'spec/active_record_producer_spec.rb'
|
97
|
+
|
98
|
+
# Offense count: 1
|
99
|
+
# Cop supports --auto-correct.
|
100
|
+
# Configuration parameters: EnforcedStyle.
|
101
|
+
# SupportedStyles: space, no_space
|
102
|
+
Layout/SpaceInsideParens:
|
103
|
+
Exclude:
|
104
|
+
- 'lib/deimos.rb'
|
105
|
+
|
106
|
+
# Offense count: 23
|
107
|
+
# Cop supports --auto-correct.
|
108
|
+
# Configuration parameters: AllowInHeredoc.
|
109
|
+
Layout/TrailingWhitespace:
|
110
|
+
Exclude:
|
111
|
+
- 'spec/schemas/my_namespace/generated.rb'
|
112
|
+
- 'spec/schemas/my_namespace/my_nested_schema.rb'
|
113
|
+
- 'spec/schemas/my_namespace/my_schema_with_circular_reference.rb'
|
114
|
+
- 'spec/schemas/my_namespace/my_schema_with_complex_type.rb'
|
115
|
+
|
116
|
+
# Offense count: 5
|
117
|
+
Lint/MissingSuper:
|
118
|
+
Exclude:
|
119
|
+
- 'lib/deimos/active_record_consumer.rb'
|
120
|
+
- 'lib/deimos/metrics/datadog.rb'
|
121
|
+
- 'lib/deimos/schema_class/enum.rb'
|
122
|
+
- 'lib/deimos/tracing/datadog.rb'
|
123
|
+
- 'lib/deimos/tracing/mock.rb'
|
124
|
+
|
125
|
+
# Offense count: 1
|
126
|
+
# Cop supports --auto-correct.
|
127
|
+
Lint/RedundantCopDisableDirective:
|
128
|
+
Exclude:
|
129
|
+
- 'spec/spec_helper.rb'
|
130
|
+
|
131
|
+
# Offense count: 3
|
132
|
+
# Cop supports --auto-correct.
|
133
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
134
|
+
Lint/UnusedMethodArgument:
|
135
|
+
Exclude:
|
136
|
+
- 'lib/deimos/tracing/mock.rb'
|
137
|
+
- 'spec/schemas/my_namespace/my_schema_with_circular_reference.rb'
|
138
|
+
|
139
|
+
# Offense count: 1
|
140
|
+
Lint/UselessAssignment:
|
141
|
+
Exclude:
|
142
|
+
- 'spec/generators/schema_class_generator_spec.rb'
|
143
|
+
|
144
|
+
# Offense count: 19
|
145
|
+
# Configuration parameters: IgnoredMethods, Max.
|
146
|
+
Metrics/AbcSize:
|
147
|
+
Exclude:
|
148
|
+
- 'lib/deimos/active_record_consume/message_consumption.rb'
|
149
|
+
- 'lib/deimos/config/phobos_config.rb'
|
150
|
+
- 'lib/deimos/instrumentation.rb'
|
151
|
+
- 'lib/deimos/kafka_source.rb'
|
152
|
+
- 'lib/deimos/kafka_topic_info.rb'
|
153
|
+
- 'lib/deimos/producer.rb'
|
154
|
+
- 'lib/deimos/schema_backends/avro_schema_coercer.rb'
|
155
|
+
- 'lib/deimos/test_helpers.rb'
|
156
|
+
- 'lib/deimos/utils/db_poller.rb'
|
157
|
+
- 'lib/deimos/utils/db_producer.rb'
|
158
|
+
- 'lib/deimos/utils/inline_consumer.rb'
|
159
|
+
- 'lib/deimos/utils/schema_controller_mixin.rb'
|
160
|
+
- 'lib/generators/deimos/schema_class_generator.rb'
|
161
|
+
|
162
|
+
# Offense count: 1
|
163
|
+
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods.
|
164
|
+
Metrics/MethodLength:
|
165
|
+
Exclude:
|
166
|
+
- 'lib/deimos/config/phobos_config.rb'
|
167
|
+
|
168
|
+
# Offense count: 5
|
169
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
170
|
+
Metrics/ModuleLength:
|
171
|
+
Exclude:
|
172
|
+
- 'lib/deimos/test_helpers.rb'
|
173
|
+
- 'spec/active_record_batch_consumer_spec.rb'
|
174
|
+
- 'spec/batch_consumer_spec.rb'
|
175
|
+
- 'spec/kafka_source_spec.rb'
|
176
|
+
- 'spec/producer_spec.rb'
|
177
|
+
|
178
|
+
# Offense count: 6
|
179
|
+
# Configuration parameters: IgnoredMethods, Max.
|
180
|
+
Metrics/PerceivedComplexity:
|
181
|
+
Exclude:
|
182
|
+
- 'lib/deimos/config/phobos_config.rb'
|
183
|
+
- 'lib/deimos/consume/batch_consumption.rb'
|
184
|
+
- 'lib/deimos/kafka_source.rb'
|
185
|
+
- 'lib/deimos/schema_backends/avro_schema_coercer.rb'
|
186
|
+
- 'lib/deimos/test_helpers.rb'
|
187
|
+
|
188
|
+
# Offense count: 12
|
189
|
+
# Configuration parameters: Prefixes.
|
190
|
+
# Prefixes: when, with, without
|
191
|
+
RSpec/ContextWording:
|
192
|
+
Exclude:
|
193
|
+
- 'spec/generators/schema_class_generator_spec.rb'
|
194
|
+
|
195
|
+
# Offense count: 4
|
196
|
+
# Configuration parameters: Max.
|
197
|
+
RSpec/ExampleLength:
|
198
|
+
Exclude:
|
199
|
+
- 'spec/config/configuration_spec.rb'
|
200
|
+
- 'spec/utils/db_producer_spec.rb'
|
201
|
+
|
202
|
+
# Offense count: 6
|
203
|
+
# Configuration parameters: Max.
|
204
|
+
RSpec/MultipleExpectations:
|
205
|
+
Exclude:
|
206
|
+
- 'spec/active_record_consumer_spec.rb'
|
207
|
+
- 'spec/config/configuration_spec.rb'
|
208
|
+
- 'spec/kafka_topic_info_spec.rb'
|
209
|
+
- 'spec/utils/db_poller_spec.rb'
|
210
|
+
- 'spec/utils/db_producer_spec.rb'
|
211
|
+
|
212
|
+
# Offense count: 1
|
213
|
+
Style/Documentation:
|
214
|
+
Exclude:
|
215
|
+
- 'spec/**/*'
|
216
|
+
- 'test/**/*'
|
217
|
+
- 'regenerate_test_schema_classes.rb'
|
218
|
+
|
219
|
+
# Offense count: 1
|
220
|
+
# Configuration parameters: RequireForNonPublicMethods.
|
221
|
+
Style/DocumentationMethod:
|
222
|
+
Exclude:
|
223
|
+
- 'spec/**/*'
|
224
|
+
- 'test/**/*'
|
225
|
+
- 'regenerate_test_schema_classes.rb'
|
226
|
+
|
227
|
+
# Offense count: 1
|
228
|
+
# Cop supports --auto-correct.
|
229
|
+
# Configuration parameters: EnforcedStyle.
|
230
|
+
# SupportedStyles: compact, expanded
|
231
|
+
Style/EmptyMethod:
|
232
|
+
Exclude:
|
233
|
+
- 'regenerate_test_schema_classes.rb'
|
234
|
+
|
235
|
+
# Offense count: 2
|
236
|
+
# Cop supports --auto-correct.
|
237
|
+
Style/ExplicitBlockArgument:
|
238
|
+
Exclude:
|
239
|
+
- 'lib/deimos/metrics/datadog.rb'
|
240
|
+
- 'lib/deimos/utils/deadlock_retry.rb'
|
241
|
+
|
242
|
+
# Offense count: 2
|
243
|
+
# Cop supports --auto-correct.
|
244
|
+
# Configuration parameters: EnforcedStyle.
|
245
|
+
# SupportedStyles: always, always_true, never
|
246
|
+
Style/FrozenStringLiteralComment:
|
247
|
+
Exclude:
|
248
|
+
- 'regenerate_test_schema_classes.rb'
|
249
|
+
- 'spec/generators/schema_class/my_schema_spec.rb'
|
250
|
+
|
251
|
+
# Offense count: 10
|
252
|
+
# Cop supports --auto-correct.
|
253
|
+
Style/GlobalStdStream:
|
254
|
+
Exclude:
|
255
|
+
- 'lib/deimos/config/configuration.rb'
|
256
|
+
- 'lib/deimos/config/phobos_config.rb'
|
257
|
+
- 'lib/deimos/metrics/mock.rb'
|
258
|
+
- 'lib/deimos/test_helpers.rb'
|
259
|
+
- 'lib/deimos/tracing/mock.rb'
|
260
|
+
- 'lib/deimos/utils/db_producer.rb'
|
261
|
+
- 'lib/tasks/deimos.rake'
|
262
|
+
- 'spec/rake_spec.rb'
|
263
|
+
|
264
|
+
# Offense count: 1
|
265
|
+
# Cop supports --auto-correct.
|
266
|
+
Style/HashEachMethods:
|
267
|
+
Exclude:
|
268
|
+
- 'lib/generators/deimos/schema_class_generator.rb'
|
269
|
+
|
270
|
+
# Offense count: 31
|
271
|
+
# Cop supports --auto-correct.
|
272
|
+
# Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle.
|
273
|
+
# SupportedStyles: require_parentheses, omit_parentheses
|
274
|
+
Style/MethodCallWithArgsParentheses:
|
275
|
+
Exclude:
|
276
|
+
- 'lib/deimos/utils/db_poller.rb'
|
277
|
+
- 'lib/deimos/utils/inline_consumer.rb'
|
278
|
+
- 'spec/config/configuration_spec.rb'
|
279
|
+
- 'spec/deimos_spec.rb'
|
280
|
+
- 'spec/generators/schema_class_generator_spec.rb'
|
281
|
+
|
282
|
+
# Offense count: 1
|
283
|
+
Style/OptionalBooleanParameter:
|
284
|
+
Exclude:
|
285
|
+
- 'lib/deimos/test_helpers.rb'
|
286
|
+
|
287
|
+
# Offense count: 1
|
288
|
+
# Cop supports --auto-correct.
|
289
|
+
Style/RedundantAssignment:
|
290
|
+
Exclude:
|
291
|
+
- 'spec/schemas/my_namespace/my_schema_with_circular_reference.rb'
|
292
|
+
|
293
|
+
# Offense count: 2
|
294
|
+
# Cop supports --auto-correct.
|
295
|
+
Style/RedundantBegin:
|
296
|
+
Exclude:
|
297
|
+
- 'lib/deimos.rb'
|
298
|
+
- 'lib/deimos/utils/db_producer.rb'
|
299
|
+
|
300
|
+
# Offense count: 1
|
301
|
+
# Cop supports --auto-correct.
|
302
|
+
Style/SingleArgumentDig:
|
303
|
+
Exclude:
|
304
|
+
- 'lib/deimos/active_record_consume/batch_slicer.rb'
|
305
|
+
|
306
|
+
# Offense count: 1
|
307
|
+
# Cop supports --auto-correct.
|
308
|
+
# Configuration parameters: AllowIfMethodIsEmpty.
|
309
|
+
Style/SingleLineMethods:
|
310
|
+
Exclude:
|
311
|
+
- 'regenerate_test_schema_classes.rb'
|
312
|
+
|
313
|
+
# Offense count: 5
|
314
|
+
# Cop supports --auto-correct.
|
315
|
+
Style/StringConcatenation:
|
316
|
+
Exclude:
|
317
|
+
- 'spec/producer_spec.rb'
|
318
|
+
- 'spec/utils/schema_controller_mixin_spec.rb'
|
319
|
+
|
320
|
+
# Offense count: 10
|
321
|
+
# Cop supports --auto-correct.
|
322
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
323
|
+
# SupportedStyles: single_quotes, double_quotes
|
324
|
+
Style/StringLiterals:
|
325
|
+
Exclude:
|
326
|
+
- 'lib/generators/deimos/schema_class_generator.rb'
|
327
|
+
- 'lib/tasks/deimos.rake'
|
328
|
+
- 'regenerate_test_schema_classes.rb'
|
329
|
+
- 'spec/schemas/my_namespace/my_schema_with_complex_type.rb'
|
330
|
+
- 'spec/spec_helper.rb'
|
331
|
+
|
332
|
+
# Offense count: 1
|
333
|
+
# Cop supports --auto-correct.
|
334
|
+
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
|
335
|
+
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
|
336
|
+
Style/TernaryParentheses:
|
337
|
+
Exclude:
|
338
|
+
- 'lib/deimos/config/phobos_config.rb'
|
339
|
+
|
340
|
+
# Offense count: 21
|
341
|
+
# Cop supports --auto-correct.
|
342
|
+
Style/TrailingBodyOnModule:
|
343
|
+
Enabled: false
|
344
|
+
|
345
|
+
# Offense count: 1
|
346
|
+
# Cop supports --auto-correct.
|
347
|
+
# Configuration parameters: EnforcedStyleForMultiline.
|
348
|
+
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
349
|
+
Style/TrailingCommaInHashLiteral:
|
350
|
+
Exclude:
|
351
|
+
- 'spec/config/configuration_spec.rb'
|
352
|
+
|
353
|
+
# Offense count: 8
|
354
|
+
# Cop supports --auto-correct.
|
355
|
+
# Configuration parameters: AutoCorrect, Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
356
|
+
# URISchemes: http, https
|
357
|
+
Layout/LineLength:
|
358
|
+
Exclude:
|
359
|
+
- 'lib/deimos/producer.rb'
|
360
|
+
- 'lib/deimos/utils/db_poller.rb'
|
361
|
+
- 'lib/deimos/utils/db_producer.rb'
|
362
|
+
- 'spec/active_record_batch_consumer_spec.rb'
|
363
|
+
- 'spec/generators/schema_class/my_schema_with_circular_reference_spec.rb'
|
364
|
+
- 'spec/generators/schema_class/my_schema_with_complex_types_spec.rb'
|
data/.ruby-version
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
2.
|
1
|
+
2.7.0
|
2
|
+
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
# 1.17.0 - 2022-10-19
|
11
|
+
- Fix the linting step in the CI
|
12
|
+
- CHANGE: Add retries to DB poller and bypass "bad batches".
|
13
|
+
- Add tracing spans to DB poller production.
|
14
|
+
|
10
15
|
# 1.16.4 - 2022-09-09
|
11
16
|
|
12
17
|
- Now generates RBS types.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -800,6 +800,9 @@ class MyProducer < Deimos::ActiveRecordProducer
|
|
800
800
|
end
|
801
801
|
```
|
802
802
|
|
803
|
+
Note that the poller will retry infinitely if it encounters a Kafka-related error such
|
804
|
+
as a communication failure. For all other errors, it will retry once by default.
|
805
|
+
|
803
806
|
## Running consumers
|
804
807
|
|
805
808
|
Deimos includes a rake task. Once it's in your gemfile, just run
|
@@ -1200,13 +1203,14 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/flipp-
|
|
1200
1203
|
|
1201
1204
|
You can/should re-generate RBS types when methods or classes change by running the following:
|
1202
1205
|
|
1203
|
-
rbs collection install # if you haven't done it
|
1206
|
+
rbs collection install # if you haven't done it
|
1207
|
+
rbs collection update
|
1204
1208
|
bundle exec sord --hide-private --no-sord-comments sig/defs.rbs --tags 'override:Override'
|
1205
1209
|
|
1206
1210
|
### Linting
|
1207
1211
|
|
1208
1212
|
Deimos uses Rubocop to lint the code. Please run Rubocop on your code
|
1209
|
-
before submitting a PR.
|
1213
|
+
before submitting a PR. The GitHub CI will also run rubocop on your pull request.
|
1210
1214
|
|
1211
1215
|
---
|
1212
1216
|
<p align="center">
|
data/Steepfile
ADDED
data/deimos-ruby.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency('avro_turf', '>=
|
21
|
+
spec.add_runtime_dependency('avro_turf', '>= 1.4', '< 2')
|
22
|
+
spec.add_runtime_dependency('fig_tree', '~> 0.0.2')
|
22
23
|
spec.add_runtime_dependency('phobos', '>= 1.9', '< 3.0')
|
23
24
|
spec.add_runtime_dependency('ruby-kafka', '< 2')
|
24
25
|
spec.add_runtime_dependency('sigurd', '>= 0.1.0', '< 1.0')
|
25
|
-
spec.add_runtime_dependency('fig_tree', '~> 0.0.2')
|
26
26
|
|
27
27
|
spec.add_development_dependency('activerecord-import')
|
28
28
|
spec.add_development_dependency('avro', '~> 1.9')
|
@@ -43,4 +43,5 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency('rubocop', '0.89.0')
|
44
44
|
spec.add_development_dependency('rubocop-rspec', '1.42.0')
|
45
45
|
spec.add_development_dependency('sqlite3', '~> 1.3')
|
46
|
+
spec.add_development_dependency('steep', '~> 1.0')
|
46
47
|
end
|
data/docs/CONFIGURATION.md
CHANGED
@@ -15,7 +15,7 @@ Config name|Default|Description
|
|
15
15
|
logger|`Logger.new(STDOUT)`|The logger that Deimos will use.
|
16
16
|
phobos_logger|`Deimos.config.logger`|The logger passed to Phobos.
|
17
17
|
metrics|`Deimos::Metrics::Mock.new`|The metrics backend use for reporting.
|
18
|
-
tracer|`Deimos::
|
18
|
+
tracer|`Deimos::Tracing::Mock.new`|The tracer backend used for debugging.
|
19
19
|
|
20
20
|
## Defining Producers
|
21
21
|
|
@@ -119,6 +119,7 @@ timestamp_column|`:updated_at`|Name of the column to query. Remember to add an i
|
|
119
119
|
delay_time|2|Amount of time in seconds to wait before picking up records, to allow for transactions to finish.
|
120
120
|
full_table|false|If set to true, do a full table dump to Kafka each run. Good for very small tables.
|
121
121
|
start_from_beginning|true|If false, start from the current time instead of the beginning of time if this is the first time running the poller.
|
122
|
+
retries|1|The number of times to retry for a *non-Kafka* error.
|
122
123
|
|
123
124
|
## Kafka Configuration
|
124
125
|
|
@@ -461,6 +461,8 @@ module Deimos
|
|
461
461
|
# If false, start from the current time instead of the beginning of time
|
462
462
|
# if this is the first time running the poller.
|
463
463
|
setting :start_from_beginning, true
|
464
|
+
# The number of times to retry production when encountering a *non-Kafka* error.
|
465
|
+
setting :retries, 1
|
464
466
|
end
|
465
467
|
|
466
468
|
deprecate 'kafka_logger', 'kafka.logger'
|
data/lib/deimos/metrics/mock.rb
CHANGED
@@ -7,7 +7,7 @@ module Deimos
|
|
7
7
|
# A mock Metrics wrapper which just logs the metrics
|
8
8
|
class Mock < Provider
|
9
9
|
# @param logger [Logger,nil]
|
10
|
-
def initialize(logger=nil)
|
10
|
+
def initialize(logger=nil) # rubocop:disable Lint/MissingSuper
|
11
11
|
@logger = logger || Logger.new(STDOUT)
|
12
12
|
@logger.info('MockMetricsProvider initialized')
|
13
13
|
end
|
@@ -14,6 +14,9 @@ module Deimos
|
|
14
14
|
# @return [Integer]
|
15
15
|
attr_reader :id
|
16
16
|
|
17
|
+
# @return [Hash]
|
18
|
+
attr_reader :config
|
19
|
+
|
17
20
|
# Begin the DB Poller process.
|
18
21
|
# @return [void]
|
19
22
|
def self.start!
|
@@ -110,6 +113,7 @@ module Deimos
|
|
110
113
|
Deimos.config.logger.info("Polling #{@producer.topic} from #{time_from} to #{time_to}")
|
111
114
|
message_count = 0
|
112
115
|
batch_count = 0
|
116
|
+
error_count = 0
|
113
117
|
|
114
118
|
# poll_query gets all the relevant data from the database, as defined
|
115
119
|
# by the producer itself.
|
@@ -118,12 +122,15 @@ module Deimos
|
|
118
122
|
batch = fetch_results(time_from, time_to).to_a
|
119
123
|
break if batch.empty?
|
120
124
|
|
121
|
-
|
122
|
-
|
125
|
+
if process_batch_with_span(batch)
|
126
|
+
batch_count += 1
|
127
|
+
else
|
128
|
+
error_count += 1
|
129
|
+
end
|
123
130
|
message_count += batch.size
|
124
131
|
time_from = last_updated(batch.last)
|
125
132
|
end
|
126
|
-
Deimos.config.logger.info("Poll #{@producer.topic} complete at #{time_to} (#{message_count} messages, #{batch_count} batches}")
|
133
|
+
Deimos.config.logger.info("Poll #{@producer.topic} complete at #{time_to} (#{message_count} messages, #{batch_count} successful batches, #{error_count} batches errored}")
|
127
134
|
end
|
128
135
|
|
129
136
|
# @param time_from [ActiveSupport::TimeWithZone]
|
@@ -143,15 +150,52 @@ module Deimos
|
|
143
150
|
|
144
151
|
# @param batch [Array<ActiveRecord::Base>]
|
145
152
|
# @return [void]
|
146
|
-
def
|
153
|
+
def process_batch_with_span(batch)
|
154
|
+
retries = 0
|
155
|
+
begin
|
156
|
+
span = Deimos.config.tracer&.start(
|
157
|
+
'deimos-db-poller',
|
158
|
+
resource: @producer.class.name.gsub('::', '-')
|
159
|
+
)
|
160
|
+
process_batch(batch)
|
161
|
+
Deimos.config.tracer&.finish(span)
|
162
|
+
rescue Kafka::Error => e # keep trying till it fixes itself
|
163
|
+
Deimos.config.logger.error("Error publishing through DB Poller: #{e.message}")
|
164
|
+
sleep(0.5)
|
165
|
+
retry
|
166
|
+
rescue StandardError => e
|
167
|
+
Deimos.config.logger.error("Error publishing through DB poller: #{e.message}}")
|
168
|
+
if retries < @config.retries
|
169
|
+
retries += 1
|
170
|
+
sleep(0.5)
|
171
|
+
retry
|
172
|
+
else
|
173
|
+
Deimos.config.logger.error('Retries exceeded, moving on to next batch')
|
174
|
+
Deimos.config.tracer&.set_error(span, e)
|
175
|
+
self.touch_info(batch)
|
176
|
+
return false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
true
|
180
|
+
end
|
181
|
+
|
182
|
+
# @param batch [Array<ActiveRecord::Base>]
|
183
|
+
# @return [void]
|
184
|
+
def touch_info(batch)
|
147
185
|
record = batch.last
|
148
186
|
id_method = record.class.primary_key
|
149
187
|
last_id = record.public_send(id_method)
|
150
188
|
last_updated_at = last_updated(record)
|
151
|
-
@producer.send_events(batch)
|
152
189
|
@info.attributes = { last_sent: last_updated_at, last_sent_id: last_id }
|
153
190
|
@info.save!
|
154
191
|
end
|
192
|
+
|
193
|
+
# @param batch [Array<ActiveRecord::Base>]
|
194
|
+
# @return [void]
|
195
|
+
def process_batch(batch)
|
196
|
+
@producer.send_events(batch)
|
197
|
+
self.touch_info(batch)
|
198
|
+
end
|
155
199
|
end
|
156
200
|
end
|
157
201
|
end
|