deimos-ruby 1.19.3 → 1.19.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/CHANGELOG.md.orig +517 -0
- data/docs/CONFIGURATION.md +8 -6
- data/lib/deimos/active_record_consume/batch_consumption.rb +16 -2
- data/lib/deimos/active_record_consumer.rb +6 -0
- data/lib/deimos/backends/base.rb +32 -10
- data/lib/deimos/config/configuration.rb +6 -0
- data/lib/deimos/test_helpers.rb +1 -1
- data/lib/deimos/version.rb +1 -1
- data/spec/active_record_consume/batch_consumption_spec.rb +103 -0
- data/spec/backends/base_spec.rb +24 -0
- data/spec/config/configuration_spec.rb +6 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6be8380428e48dd415fd6ec606832fab6204a280effc65e65e967ef72dca1c32
|
4
|
+
data.tar.gz: 1096e0da58a961c3875b5d8545a6c226ba60ebacd5c60639f09acce4dcb73374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7770d8bf7eb8c9b1db538891a025586411c24c076cfe49474e312ca859386366d24cf57007c0e1230fa98dd2aa17ca3b0fc1c0f9324003918a7df00e0738944f
|
7
|
+
data.tar.gz: '02019bdab7dd827f9373de64250c10119ab56dcf441369f3bec7c023e3c524f403fcdb35202c4e92cdfa0b66175ca17905c86ab407cc8f45fea49bad1d33c6b5'
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
# 1.19.5 - 2023-03-29
|
11
|
+
|
12
|
+
- Feature: add additional setting to Deimos.config - payload_log
|
13
|
+
|
14
|
+
# 1.19.4 - 2023-03-23
|
15
|
+
|
16
|
+
- Feature: Limit amount of transactions in a single database call with `max_db_batch_size`
|
17
|
+
|
10
18
|
# 1.19.3 - 2023-03-22
|
11
19
|
|
12
20
|
- Fix: Allow `have_sent` matcher to work with schema classes.
|
data/CHANGELOG.md.orig
ADDED
@@ -0,0 +1,517 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## UNRELEASED
|
9
|
+
|
10
|
+
<<<<<<< HEAD
|
11
|
+
- Feature: Limit amount of transactions in a single database call with `max_db_batch_size`
|
12
|
+
=======
|
13
|
+
# 1.19.3 - 2023-03-22
|
14
|
+
|
15
|
+
- Fix: Allow `have_sent` matcher to work with schema classes.
|
16
|
+
>>>>>>> have-sent-fix
|
17
|
+
|
18
|
+
# 1.19.2 - 2023-03-20
|
19
|
+
|
20
|
+
- Fix for saving associations where the primary key is not `id`.
|
21
|
+
|
22
|
+
# 1.19.1 - 2023-03-17
|
23
|
+
|
24
|
+
- Fix for `rails g deimos:bulk_import_id` generator.
|
25
|
+
|
26
|
+
# 1.19.0 - 2023-02-21
|
27
|
+
|
28
|
+
- Feature: When consuming data in batch mode, this adds ability to save data to multiple tables with `association_list`.
|
29
|
+
- Fix bug with the `disable_producers` method where producers may remain disabled after the block
|
30
|
+
is done processing if an error occurs inside it.
|
31
|
+
|
32
|
+
# 1.18.2 - 2022-11-14
|
33
|
+
|
34
|
+
- Fixes bug related to wait between runs when no records are fetched by updating poll_info
|
35
|
+
|
36
|
+
# 1.18.1 - 2022-11-01
|
37
|
+
|
38
|
+
- Fix the primary_key detection way in `state_based` mode
|
39
|
+
|
40
|
+
# 1.18.0 - 2022-11-01
|
41
|
+
|
42
|
+
### Features :star:
|
43
|
+
|
44
|
+
- Add the `state_based` mode for DB pollers.
|
45
|
+
|
46
|
+
### Fixes :wrench:
|
47
|
+
- Fix the mock schema backend's `encode_key` method so it doesn't crash when used in application code.
|
48
|
+
|
49
|
+
# 1.17.1 - 2022-10-20
|
50
|
+
|
51
|
+
- Fix the log message for publishing messages so it uses the topic of the actual message instead of
|
52
|
+
the default for the producer.
|
53
|
+
- Use public sord gem instead of private fork.
|
54
|
+
|
55
|
+
# 1.17.0 - 2022-10-19
|
56
|
+
- Fix the linting step in the CI
|
57
|
+
- CHANGE: Add retries to DB poller and bypass "bad batches".
|
58
|
+
- Add tracing spans to DB poller production.
|
59
|
+
|
60
|
+
# 1.16.4 - 2022-09-09
|
61
|
+
|
62
|
+
- Now generates RBS types.
|
63
|
+
- Use `allocate` instead of `new` in `tombstone` to avoid issues with required fields in `initialize`.
|
64
|
+
|
65
|
+
# 1.16.3 - 2022-09-08
|
66
|
+
|
67
|
+
- Add the `tombstone` method to schema classes.
|
68
|
+
|
69
|
+
# 1.16.2 - 2022-09-07
|
70
|
+
|
71
|
+
- Added support of post_process method in ActiveRecordProducer
|
72
|
+
|
73
|
+
# 1.16.1 - 2022-08-03
|
74
|
+
|
75
|
+
- Fix issues with `enum` schema classes (e.g. equality not working, `to_s` not working)
|
76
|
+
- Changed assumption in the base schema class that it was a record (e.g. defining `to_h` instead of `as_json`). Moved record functionality to the record base class.
|
77
|
+
- Added the `active_span` and `set_tag` methods to the tracing classes.
|
78
|
+
- Added span tags for fields in SchemaControllerMixin.
|
79
|
+
- Updated SchemaControllerMixin so it works with generated schema classes.
|
80
|
+
- Fixed bug with previous release where the filename and constant names for `generate_namespace_folders` did not always match.
|
81
|
+
|
82
|
+
# 1.15.0 - 2022-07-20
|
83
|
+
|
84
|
+
- Update to `sigurd` 0.1.0 - DB producer should now exit when receiving a `SIGTERM` instead of throwing a `SignalException`
|
85
|
+
|
86
|
+
# 1.14.6 - 2022-06-21
|
87
|
+
|
88
|
+
- Add `generate_namespace_folders` to configuration; this will automatically generate subfolders to the `schemas` folder so that you can have different schemas with the same name but different namespaces generate separate classes.
|
89
|
+
|
90
|
+
# 1.14.5 - 2022-06-21
|
91
|
+
|
92
|
+
- Fix crash with the tracer when error happens in decoding a message during batch consuming
|
93
|
+
- Generate schema classes for all schemas, even without a consumer/producer set
|
94
|
+
|
95
|
+
# 1.14.4 - 2022-06-18
|
96
|
+
|
97
|
+
- Fix import in ActiveRecordConsumer on mysql
|
98
|
+
|
99
|
+
# 1.14.3 - 2022-06-17
|
100
|
+
|
101
|
+
- Fix issue with ActiveRecordConsumer double-decoding keys in batch mode.
|
102
|
+
|
103
|
+
# 1.14.2 - 2022-05-26
|
104
|
+
|
105
|
+
- Fix crash with `test_consume_message` when passing in an instance of a schema class instead of a hash.
|
106
|
+
|
107
|
+
# 1.14.1 - 2022-05-25
|
108
|
+
|
109
|
+
- Fix: When using key schemas, ActiveRecordConsumers were not finding the record by default.
|
110
|
+
|
111
|
+
# 1.14.0 - 2022-05-16
|
112
|
+
|
113
|
+
- **Breaking Change**: Nest sub-schemas by default into their parent schemas when generating classes.
|
114
|
+
- Add the `nest_child_schemas` option to essentially bring back the previous behavior in terms of code use (the actual classes will be separated out into different files).
|
115
|
+
|
116
|
+
# 1.13.3 - 2022-05-10
|
117
|
+
|
118
|
+
- Some cleanup on the active_record generator
|
119
|
+
- Fix crash with `test_consume_message` when using schema classes
|
120
|
+
- Add `[]=` and `merge` methods on the base schema class
|
121
|
+
|
122
|
+
# 1.13.2 - 2022-04-07
|
123
|
+
|
124
|
+
- Fix an issue with generating schema classes for schemas containing an enum with default value
|
125
|
+
|
126
|
+
# 1.13.1 - 2022-04-06
|
127
|
+
|
128
|
+
- Fix circular reference schema generation
|
129
|
+
|
130
|
+
# 1.13.0 - 2022-03-30
|
131
|
+
|
132
|
+
- Pass the Deimos logger to `AvroTurf::Messaging` for consistent logging
|
133
|
+
- Fix an issue with nullable enums not being included in the auto-generated schema class
|
134
|
+
|
135
|
+
# 1.12.6 - 2022-03-14
|
136
|
+
|
137
|
+
- Fix NameError when using Datadog Metrics
|
138
|
+
- Fix unwanted STDOUT output when loading the main `Deimos` module
|
139
|
+
|
140
|
+
# 1.12.5 - 2022-03-09
|
141
|
+
|
142
|
+
- Allow use of new avro_turf versions where child schemas are not listed with the top level schemas
|
143
|
+
- Add support for SASL authentication with brokers
|
144
|
+
- Add support for Basic auth with Schema Registry
|
145
|
+
|
146
|
+
# 1.12.4 - 2022-01-13
|
147
|
+
|
148
|
+
- Fix bug where schema controller mixin was using the schema name to register and not the namespaced schema name
|
149
|
+
|
150
|
+
# 1.12.3 - 2021-12-13
|
151
|
+
|
152
|
+
- Fix bug with previous release
|
153
|
+
|
154
|
+
# 1.12.2 - 2021-12-10
|
155
|
+
|
156
|
+
### Features :star:
|
157
|
+
|
158
|
+
- Added `Deimos.encode` and `Deimos.decode` for non-topic-related encoding and decoding.
|
159
|
+
|
160
|
+
# 1.12.1 - 2021-11-02
|
161
|
+
|
162
|
+
- ### Fixes :wrench:
|
163
|
+
- Fixed issue where Schema Class Consumer/Producer are using `Deimos::` instead of `Schema::` for instances of classes.
|
164
|
+
|
165
|
+
# 1.12.0 - 2021-11-01
|
166
|
+
|
167
|
+
### Features :star:
|
168
|
+
|
169
|
+
- Generate Schema classes from Avro Schemas
|
170
|
+
- Use Schema Classes in your consumer and producer
|
171
|
+
|
172
|
+
## 1.11.0 - 2021-08-27
|
173
|
+
|
174
|
+
- ### Fixes :wrench:
|
175
|
+
- Fixed issue where ActiveRecord batch consumption could fail when decoding keys.
|
176
|
+
|
177
|
+
- ### Roadmap :car:
|
178
|
+
- TestHelper does not automatically reset Deimos config before each test. [#120](https://github.com/flipp-oss/deimos/pull/120).
|
179
|
+
**Please note that this is a breaking change**
|
180
|
+
|
181
|
+
|
182
|
+
## 1.10.2 - 2021-07-20
|
183
|
+
|
184
|
+
- ### Fixes :wrench:
|
185
|
+
|
186
|
+
- Fixed issue where producers would stay in an error state after e.g. authorization failures for one topic that wouldn't apply to other topics.
|
187
|
+
|
188
|
+
## 1.10.1 - 2021-06-21
|
189
|
+
|
190
|
+
- ### Fixes :wrench:
|
191
|
+
|
192
|
+
- Fixed crash when trying to decode a nil payload (e.g. during instrumentation of `send_produce_error`.)
|
193
|
+
|
194
|
+
## 1.10.0 - 2021-03-22
|
195
|
+
|
196
|
+
- ### Roadmap :car:
|
197
|
+
|
198
|
+
- Extracted the configuration piece into a separate gem, [fig_tree](https://www.github.com/flipp-oss/fig_tree).
|
199
|
+
- Added a `save_record` method to ActiveRecordConsumer in case calling code wants to work with the record before saving.
|
200
|
+
|
201
|
+
- ### Fixes :wrench:
|
202
|
+
|
203
|
+
- Fixed a regression where the default values for consumer / Phobos listener configs were not correct (they were all nil). This is technically a breaking change, but it puts the configs back the way they were at version 1.4 and matches the documentation.
|
204
|
+
|
205
|
+
## 1.9.2 - 2021-01-29
|
206
|
+
|
207
|
+
- ### Fixes :wrench:
|
208
|
+
|
209
|
+
- Fix for `uninitialized constant ActiveSupport::Autoload` in certain circumstances
|
210
|
+
- Removed unnecessary monkey patch which was crashing on newer versions of ruby-kafka
|
211
|
+
|
212
|
+
## 1.9.0 - 2021-01-28
|
213
|
+
|
214
|
+
- ### Roadmap :car:
|
215
|
+
|
216
|
+
- Bumped the version of ruby-kafka to latest
|
217
|
+
|
218
|
+
- ### Fixes :wrench:
|
219
|
+
|
220
|
+
- Prevents DB Poller from reconnecting to DB if there is an open transaction
|
221
|
+
- Replaces `before` by `prepend_before` for more consistent test setups.
|
222
|
+
- Adds validation in the `kafka_producers` method (fixes [#90](https://github.com/flipp-oss/deimos/issues/90))
|
223
|
+
|
224
|
+
## 1.8.7 - 2021-01-14
|
225
|
+
|
226
|
+
- ### Roadmap :car:
|
227
|
+
- Update Phobos version to allow version 1.9 or 2.x.
|
228
|
+
|
229
|
+
## 1.8.6 - 2021-01-14
|
230
|
+
|
231
|
+
- ### Fixes :wrench:
|
232
|
+
- Fix for configuration bug with Ruby 3.0 (** instead of passing hash)
|
233
|
+
|
234
|
+
## 1.8.5 - 2021-01-13
|
235
|
+
|
236
|
+
- ### Fixes :wrench:
|
237
|
+
- Fixes for Rails 6.1 (remove usage of `update_attributes!`)
|
238
|
+
|
239
|
+
## 1.8.4 - 2020-12-02
|
240
|
+
|
241
|
+
### Features :star:
|
242
|
+
- Add overridable "process_message?" method to ActiveRecordConsumer to allow for skipping of saving/updating records
|
243
|
+
|
244
|
+
### Fixes :wrench:
|
245
|
+
|
246
|
+
- Do not apply type coercion to `timestamp-millis` and `timestamp-micros` logical types (fixes [#97](https://github.com/flipp-oss/deimos/issues/97))
|
247
|
+
|
248
|
+
## 1.8.3 - 2020-11-18
|
249
|
+
|
250
|
+
### Fixes :wrench:
|
251
|
+
- Do not resend already sent messages when splitting up batches
|
252
|
+
(fixes [#24](https://github.com/flipp-oss/deimos/issues/24))
|
253
|
+
- KafkaSource crashing on bulk-imports if import hooks are disabled
|
254
|
+
(fixes [#73](https://github.com/flipp-oss/deimos/issues/73))
|
255
|
+
- #96 Use string-safe encoding for partition keys
|
256
|
+
- Retry on offset seek failures in inline consumer
|
257
|
+
(fixes [#5](Inline consumer should use retries when seeking))
|
258
|
+
|
259
|
+
## 1.8.2 - 2020-09-25
|
260
|
+
|
261
|
+
### Features :star:
|
262
|
+
- Add "disabled" config field to consumers to allow disabling
|
263
|
+
individual consumers without having to comment out their
|
264
|
+
entries and possibly affecting unit tests.
|
265
|
+
|
266
|
+
### Fixes :wrench:
|
267
|
+
- Prepend topic_prefix while encoding messages
|
268
|
+
(fixes [#37](https://github.com/flipp-oss/deimos/issues/37))
|
269
|
+
- Raise error if producing without a topic
|
270
|
+
(fixes [#50](https://github.com/flipp-oss/deimos/issues/50))
|
271
|
+
- Don't try to load producers/consumers when running rake tasks involving webpacker or assets
|
272
|
+
|
273
|
+
## 1.8.2-beta2 - 2020-09-15
|
274
|
+
|
275
|
+
### Features :star:
|
276
|
+
|
277
|
+
- Add details on using schema backend directly in README.
|
278
|
+
- Default to the provided schema if topic is not provided when
|
279
|
+
encoding to `AvroSchemaRegistry`.
|
280
|
+
- Add mapping syntax for the `schema` call in `SchemaControllerMixin`.
|
281
|
+
|
282
|
+
## 1.8.2-beta1 - 2020-09-09
|
283
|
+
|
284
|
+
### Features :star:
|
285
|
+
|
286
|
+
- Added the ability to specify the topic for `publish`
|
287
|
+
and `publish_list` in a producer
|
288
|
+
|
289
|
+
## 1.8.1-beta9 - 2020-08-27
|
290
|
+
|
291
|
+
### Fixes :wrench:
|
292
|
+
- Moved the TestHelpers hook to `before(:suite)` to allow for
|
293
|
+
overriding e.g. in integration tests.
|
294
|
+
|
295
|
+
## 1.8.1-beta7 - 2020-08-25
|
296
|
+
|
297
|
+
### Fixes :wrench:
|
298
|
+
- Fix for crash when sending pending metrics with DB producer.
|
299
|
+
- Fix for compacting messages if all the keys are already unique
|
300
|
+
(fixes [#75](https://github.com/flipp-oss/deimos/issues/75))
|
301
|
+
|
302
|
+
## 1.8.1-beta6 - 2020-08-13
|
303
|
+
|
304
|
+
### Fixes :wrench:
|
305
|
+
|
306
|
+
- Fix for consuming nil payloads with Ruby 2.3.
|
307
|
+
|
308
|
+
## 1.8.1-beta5 - 2020-08-13
|
309
|
+
|
310
|
+
### Fixes :wrench:
|
311
|
+
- Fix regression bug which introduces backwards incompatibility
|
312
|
+
with ActiveRecordProducer's `record_attributes` method.
|
313
|
+
|
314
|
+
## 1.8.1-beta4 - 2020-08-12
|
315
|
+
|
316
|
+
### Fixes :wrench:
|
317
|
+
- Fix regression bug where arrays were not being encoded
|
318
|
+
|
319
|
+
## 1.8.1-beta3 - 2020-08-05
|
320
|
+
|
321
|
+
### Fixes :wrench:
|
322
|
+
- Simplify decoding messages and handle producer not found
|
323
|
+
- Consolidate types in sub-records recursively
|
324
|
+
(fixes [#72](https://github.com/flipp-oss/deimos/issues/72))
|
325
|
+
|
326
|
+
## 1.8.1-beta2 - 2020-07-28
|
327
|
+
|
328
|
+
### Features :star:
|
329
|
+
- Add `SchemaControllerMixin` to encode and decode schema-encoded
|
330
|
+
payloads in Rails controllers.
|
331
|
+
|
332
|
+
## 1.8.1-beta1 - 2020-07-22
|
333
|
+
|
334
|
+
### Fixes :wrench:
|
335
|
+
- Retry deleting messages without resending the batch if the
|
336
|
+
delete fails (fixes [#34](https://github.com/flipp-oss/deimos/issues/34))
|
337
|
+
- Delete messages in batches rather than all at once to
|
338
|
+
cut down on the chance of a deadlock.
|
339
|
+
|
340
|
+
### Features :star:
|
341
|
+
- Add `last_processed_at` to `kafka_topic_info` to ensure
|
342
|
+
that wait metrics are accurate in cases where records
|
343
|
+
get created with an old `created_at` time (e.g. for
|
344
|
+
long-running transactions).
|
345
|
+
- Add generator for ActiveRecord models and migrations (fixes [#6](https://github.com/flipp-oss/deimos/issues/6))
|
346
|
+
|
347
|
+
## 1.8.0-beta2 - 2020-07-08
|
348
|
+
|
349
|
+
### Fixes :wrench:
|
350
|
+
- Fix crash with batch consumption due to not having ActiveSupport::Concern
|
351
|
+
|
352
|
+
### Features :star:
|
353
|
+
- Add `first_offset` to the metadata sent via the batch
|
354
|
+
|
355
|
+
## 1.8.0-beta1 - 2020-07-06
|
356
|
+
### Features :star:
|
357
|
+
- Added `ActiveRecordConsumer` batch mode
|
358
|
+
|
359
|
+
### Fixes :wrench:
|
360
|
+
- Fixes `send_produce_error` to decode `failed_messages` with built-in decoder.
|
361
|
+
- Lag calculation can be incorrect if no messages are being consumed.
|
362
|
+
- Fixed bug where printing messages on a MessageSizeTooLarge
|
363
|
+
error didn't work.
|
364
|
+
|
365
|
+
### Roadmap
|
366
|
+
- Moved SignalHandler and Executor to the `sigurd` gem.
|
367
|
+
|
368
|
+
## 1.7.0-beta1 - 2020-05-12
|
369
|
+
### Features :star:
|
370
|
+
- Added the DB Poller feature / process.
|
371
|
+
|
372
|
+
## 1.6.4 - 2020-05-11
|
373
|
+
- Fixed the payload logging fix for errored messages as well.
|
374
|
+
|
375
|
+
## 1.6.3 - 2020-05-04
|
376
|
+
### Fixes :wrench:
|
377
|
+
- Fixed the payload logging fix.
|
378
|
+
|
379
|
+
## 1.6.2 - 2020-05-04
|
380
|
+
### Fixes :wrench:
|
381
|
+
- When saving records via `ActiveRecordConsumer`, update `updated_at` to today's time
|
382
|
+
even if nothing else was saved.
|
383
|
+
- When logging payloads and metadata, decode them first.
|
384
|
+
- Fixes bug in `KafkaSource` that crashes when importing a mix of existing and new records with the `:on_duplicate_key_update` option.
|
385
|
+
|
386
|
+
## [1.6.1] - 2020-04-20
|
387
|
+
### Fixes :wrench:
|
388
|
+
- Re-consuming a message after crashing would try to re-decode message keys.
|
389
|
+
|
390
|
+
# [1.6.0] - 2020-03-05
|
391
|
+
### Roadmap :car:
|
392
|
+
- Removed `was_message_sent?` method from `TestHelpers`.
|
393
|
+
|
394
|
+
# [1.6.0-beta1] - 2020-02-05
|
395
|
+
### Roadmap :car:
|
396
|
+
- Updated dependency for Phobos to 1.9.0-beta3. This ensures compatibility with
|
397
|
+
Phobos 2.0.
|
398
|
+
### Fixes :wrench:
|
399
|
+
- Fixed RSpec warning when using `test_consume_invalid_message`.
|
400
|
+
|
401
|
+
# [1.5.0-beta2] - 2020-01-17
|
402
|
+
### Roadmap :car:
|
403
|
+
- Added schema backends, which should simplify Avro encoding and make it
|
404
|
+
more flexible for unit tests and local development.
|
405
|
+
### Features :star:
|
406
|
+
- Add `:test` producer backend which replaces the existing TestHelpers
|
407
|
+
functionality of writing messages to an in-memory hash.
|
408
|
+
|
409
|
+
# [1.4.0-beta7] - 2019-12-16
|
410
|
+
### Fixes :wrench:
|
411
|
+
- Clone loggers when assigning to multiple levels.
|
412
|
+
|
413
|
+
# [1.4.0-beta6] - 2019-12-16
|
414
|
+
### Features :star:
|
415
|
+
- Added default for max_bytes_per_partition.
|
416
|
+
|
417
|
+
# [1.4.0-beta4] - 2019-11-26
|
418
|
+
### Features :star:
|
419
|
+
- Added `define_settings` to define settings without invoking callbacks.
|
420
|
+
|
421
|
+
# [1.4.0-beta2] - 2019-11-22
|
422
|
+
### Fixes :wrench:
|
423
|
+
- Settings with default_proc were being called immediately
|
424
|
+
instead of being lazy-evaluated.
|
425
|
+
|
426
|
+
# [1.4.0-beta1] - 2019-11-22
|
427
|
+
### Roadmap :car:
|
428
|
+
- Complete revamp of configuration method.
|
429
|
+
|
430
|
+
# [1.3.0-beta5] - 2020-01-14
|
431
|
+
### Features :star:
|
432
|
+
- Added `db_producer.insert` and `db_producer.process` metrics.
|
433
|
+
|
434
|
+
# [1.3.0-beta4] - 2019-12-02
|
435
|
+
### Fixes :wrench:
|
436
|
+
- Fixed bug where by running `rake deimos:start` without
|
437
|
+
specifying a producer backend would crash.
|
438
|
+
|
439
|
+
# [1.3.0-beta3] - 2019-11-26
|
440
|
+
### Fixes :wrench:
|
441
|
+
- Fixed bug in TestHelpers where key_decoder was not stubbed out.
|
442
|
+
|
443
|
+
# [1.3.0-beta2] - 2019-11-22
|
444
|
+
### Fixes :wrench:
|
445
|
+
- Fixed bug where consumers would require a key config in all cases
|
446
|
+
even though it's optional if they don't use keys.
|
447
|
+
|
448
|
+
# [1.3.0-beta1] - 2019-11-21
|
449
|
+
### Features :star:
|
450
|
+
- Added `fetch_record` and `assign_key` methods to ActiveRecordConsumer.
|
451
|
+
|
452
|
+
# [1.2.0-beta1] - 2019-09-12
|
453
|
+
### Features :star:
|
454
|
+
- Added `fatal_error` to both global config and consumer classes.
|
455
|
+
- Changed `pending_db_messages_max_wait` metric to send per topic.
|
456
|
+
- Added config to compact messages in the DB producer.
|
457
|
+
- Added config to log messages in the DB producer.
|
458
|
+
- Added config to provide a separate logger to the DB producer.
|
459
|
+
|
460
|
+
# [1.1.0-beta2] - 2019-09-11
|
461
|
+
### Fixes :wrench:
|
462
|
+
- Fixed bug where ActiveRecordConsumer was not using `unscoped` to update
|
463
|
+
via primary key and causing duplicate record errors.
|
464
|
+
|
465
|
+
# [1.1.0-beta1] - 2019-09-10
|
466
|
+
### Features :star:
|
467
|
+
- Added BatchConsumer.
|
468
|
+
|
469
|
+
## [1.0.0] - 2019-09-03
|
470
|
+
### Roadmap :car:
|
471
|
+
- Official release of Deimos 1.0!
|
472
|
+
|
473
|
+
## [1.0.0-beta26] - 2019-08-29
|
474
|
+
- Recover from Kafka::MessageSizeTooLarge in the DB producer.
|
475
|
+
- Shut down sync producers correctly when persistent_connections is true.
|
476
|
+
- Notify when messages fail to produce in the DB producer.
|
477
|
+
- Delete messages on failure and rely on notification.
|
478
|
+
|
479
|
+
## [1.0.0-beta25] - 2019-08-28
|
480
|
+
- Fix bug where crashing would cause producers to stay disabled
|
481
|
+
|
482
|
+
## [1.0.0-beta24] - 2019-08-26
|
483
|
+
- Reconnect DB backend if database goes away.
|
484
|
+
- Sleep only 5 seconds between attempts instead of using exponential backoff.
|
485
|
+
- Fix for null payload being Avro-encoded.
|
486
|
+
|
487
|
+
## [1.0.0-beta23] - 2019-08-22
|
488
|
+
- Fix bug where nil payloads were not being saved to the DB.
|
489
|
+
- Fix DB producer rake task looking at THREADS env var instead of THREAD_COUNT.
|
490
|
+
- Debug messages in the DB producer if debug logs are turned on.
|
491
|
+
- Changed logger in specs to info.
|
492
|
+
|
493
|
+
## [1.0.0-beta22] - 2019-08-09
|
494
|
+
- Add `pending_db_messages_max_wait` metric for the DB producer.
|
495
|
+
- Fix mock metrics to allow optional option hashes.
|
496
|
+
|
497
|
+
## [1.0.0-beta21] - 2019-08-08
|
498
|
+
- Handle Phobos `persistent_connections` setting in handling buffer overflows
|
499
|
+
|
500
|
+
## [1.0.0-beta20] - 2019-08-07
|
501
|
+
- Catch buffer overflows when producing via the DB producer and split the
|
502
|
+
batch up.
|
503
|
+
|
504
|
+
## [1.0.0-beta19] - 2019-08-06
|
505
|
+
- Fix for DB producer crashing on error in Rails 3.
|
506
|
+
|
507
|
+
## [1.0.0-beta18] - 2019-08-02
|
508
|
+
- Fixed crash when sending metrics in a couple of places.
|
509
|
+
|
510
|
+
## [1.0.0-beta17] - 2019-07-31
|
511
|
+
- Added `rails deimos:db_producer` rake task.
|
512
|
+
- Fixed the DB producer so it runs inline instead of on a separate thread.
|
513
|
+
Calling code should run it on a thread manually if that is the desired
|
514
|
+
behavior.
|
515
|
+
|
516
|
+
## [1.0.0-beta15] - 2019-07-08
|
517
|
+
- Initial release.
|
data/docs/CONFIGURATION.md
CHANGED
@@ -10,12 +10,13 @@ Nested configuration is denoted in simple dot notation:
|
|
10
10
|
configurations.
|
11
11
|
|
12
12
|
## Base Configuration
|
13
|
-
Config name|Default|Description
|
14
|
-
|
15
|
-
logger
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
Config name| Default |Description
|
14
|
+
-----------|-----------------------------|-----------
|
15
|
+
logger| `Logger.new(STDOUT)` |The logger that Deimos will use.
|
16
|
+
payload_log| `:full` |Determines how much data is logged per payload.</br>`:full` - all keys and payloads are logged.</br>`:keys` - only keys are logged.</br>`:count` - only the total count of messages are logged.
|
17
|
+
phobos_logger| `Deimos.config.logger` |The logger passed to Phobos.
|
18
|
+
metrics| `Deimos::Metrics::Mock.new` |The metrics backend use for reporting.
|
19
|
+
tracer| `Deimos::Tracing::Mock.new` |The tracer backend used for debugging.
|
19
20
|
|
20
21
|
## Defining Producers
|
21
22
|
|
@@ -83,6 +84,7 @@ key_config|nil|Configuration hash for message keys. See [Kafka Message Keys](../
|
|
83
84
|
disabled|false|Set to true to skip starting an actual listener for this consumer on startup.
|
84
85
|
group_id|nil|ID of the consumer group.
|
85
86
|
use_schema_classes|nil|Set to true or false to enable or disable using the consumers schema classes. See [Generated Schema Classes](../README.md#generated-schema-classes)
|
87
|
+
max_db_batch_size|nil|Maximum limit for batching database calls to reduce the load on the db.
|
86
88
|
max_concurrency|1|Number of threads created for this listener. Each thread will behave as an independent consumer. They don't share any state.
|
87
89
|
start_from_beginning|true|Once the consumer group has checkpointed its progress in the topic's partitions, the consumers will always start from the checkpointed offsets, regardless of config. As such, this setting only applies when the consumer initially starts consuming from a topic
|
88
90
|
max_bytes_per_partition|512.kilobytes|Maximum amount of data fetched from a single partition at a time.
|
@@ -78,8 +78,22 @@ module Deimos
|
|
78
78
|
# deleted record (no payload)
|
79
79
|
removed, upserted = messages.partition(&:tombstone?)
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
max_db_batch_size = self.class.config[:max_db_batch_size]
|
82
|
+
if upserted.any?
|
83
|
+
if max_db_batch_size
|
84
|
+
upserted.each_slice(max_db_batch_size) { |group| upsert_records(group) }
|
85
|
+
else
|
86
|
+
upsert_records(upserted)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
return if removed.empty?
|
91
|
+
|
92
|
+
if max_db_batch_size
|
93
|
+
removed.each_slice(max_db_batch_size) { |group| remove_records(group) }
|
94
|
+
else
|
95
|
+
remove_records(removed)
|
96
|
+
end
|
83
97
|
end
|
84
98
|
|
85
99
|
# Upsert any non-deleted records
|
@@ -48,6 +48,12 @@ module Deimos
|
|
48
48
|
def compacted(val)
|
49
49
|
config[:compacted] = val
|
50
50
|
end
|
51
|
+
|
52
|
+
# @param limit [Integer] Maximum number of transactions in a single database call.
|
53
|
+
# @return [void]
|
54
|
+
def max_db_batch_size(limit)
|
55
|
+
config[:max_db_batch_size] = limit
|
56
|
+
end
|
51
57
|
end
|
52
58
|
|
53
59
|
# Setup
|
data/lib/deimos/backends/base.rb
CHANGED
@@ -9,16 +9,7 @@ module Deimos
|
|
9
9
|
# @param messages [Array<Deimos::Message>]
|
10
10
|
# @return [void]
|
11
11
|
def publish(producer_class:, messages:)
|
12
|
-
Deimos.config.logger.info(
|
13
|
-
message: 'Publishing messages',
|
14
|
-
topic: messages.first&.topic,
|
15
|
-
payloads: messages.map do |message|
|
16
|
-
{
|
17
|
-
payload: message.payload,
|
18
|
-
key: message.key
|
19
|
-
}
|
20
|
-
end
|
21
|
-
)
|
12
|
+
Deimos.config.logger.info(log_message(messages))
|
22
13
|
execute(producer_class: producer_class, messages: messages)
|
23
14
|
end
|
24
15
|
|
@@ -28,6 +19,37 @@ module Deimos
|
|
28
19
|
def execute(producer_class:, messages:)
|
29
20
|
raise NotImplementedError
|
30
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def log_message(messages)
|
26
|
+
log_message = {
|
27
|
+
message: 'Publishing messages',
|
28
|
+
topic: messages.first&.topic
|
29
|
+
}
|
30
|
+
|
31
|
+
case Deimos.config.payload_log
|
32
|
+
when :keys
|
33
|
+
log_message.merge!(
|
34
|
+
payload_keys: messages.map(&:key)
|
35
|
+
)
|
36
|
+
when :count
|
37
|
+
log_message.merge!(
|
38
|
+
payloads_count: messages.count
|
39
|
+
)
|
40
|
+
else
|
41
|
+
log_message.merge!(
|
42
|
+
payloads: messages.map do |message|
|
43
|
+
{
|
44
|
+
payload: message.payload,
|
45
|
+
key: message.key
|
46
|
+
}
|
47
|
+
end
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
log_message
|
52
|
+
end
|
31
53
|
end
|
32
54
|
end
|
33
55
|
end
|
@@ -95,6 +95,9 @@ module Deimos
|
|
95
95
|
# @return [Logger]
|
96
96
|
setting :logger, Logger.new(STDOUT)
|
97
97
|
|
98
|
+
# @return [Symbol]
|
99
|
+
setting :payload_log, :full
|
100
|
+
|
98
101
|
# @return [Logger]
|
99
102
|
setting :phobos_logger, default_proc: proc { Deimos.config.logger.clone }
|
100
103
|
|
@@ -424,6 +427,9 @@ module Deimos
|
|
424
427
|
# Configure the usage of generated schema classes for this consumer
|
425
428
|
# @return [Boolean]
|
426
429
|
setting :use_schema_classes
|
430
|
+
# Optional maximum limit for batching database calls to reduce the load on the db.
|
431
|
+
# @return [Integer]
|
432
|
+
setting :max_db_batch_size
|
427
433
|
|
428
434
|
# These are the phobos "listener" configs. See CONFIGURATION.md for more
|
429
435
|
# info.
|
data/lib/deimos/test_helpers.rb
CHANGED
@@ -143,7 +143,7 @@ module Deimos
|
|
143
143
|
Deimos::Backends::Test.sent_messages.any? do |m|
|
144
144
|
hash_matcher = RSpec::Matchers::BuiltIn::Match.new(message)
|
145
145
|
hash_matcher.send(:match,
|
146
|
-
message.to_h,
|
146
|
+
message&.respond_to?(:to_h) ? message.to_h : message,
|
147
147
|
m[:payload]&.with_indifferent_access) &&
|
148
148
|
topic == m[:topic] &&
|
149
149
|
(key.present? ? key == m[:key] : true) &&
|
data/lib/deimos/version.rb
CHANGED
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Deimos::ActiveRecordConsume::BatchConsumption do
|
4
|
+
let(:batch_consumer) do
|
5
|
+
Deimos::ActiveRecordConsumer.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#update_database' do
|
9
|
+
describe 'upsert_records' do
|
10
|
+
let(:records) do
|
11
|
+
[
|
12
|
+
Deimos::Message.new({ v: 1 }, nil, key: 1),
|
13
|
+
Deimos::Message.new({ v: 2 }, nil, key: 2),
|
14
|
+
Deimos::Message.new({ v: 3 }, nil, key: 3),
|
15
|
+
Deimos::Message.new({ v: 4 }, nil, key: 4),
|
16
|
+
Deimos::Message.new({ v: 5 }, nil, key: 5)
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be called 1 time when record size < max batch size' do
|
21
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size + 1
|
22
|
+
expect(batch_consumer).to receive(:upsert_records).once
|
23
|
+
|
24
|
+
batch_consumer.send(:update_database, records)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should be called 1 time when record size == max batch size' do
|
28
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size
|
29
|
+
expect(batch_consumer).to receive(:upsert_records).once
|
30
|
+
|
31
|
+
batch_consumer.send(:update_database, records)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should be called multiple times when record size > max batch size' do
|
35
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size - 1
|
36
|
+
expect(batch_consumer).to receive(:upsert_records).twice
|
37
|
+
|
38
|
+
batch_consumer.send(:update_database, records)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should be called records.size times when max batch size is 1' do
|
42
|
+
batch_consumer.class.config[:max_db_batch_size] = 1
|
43
|
+
expect(batch_consumer).to receive(:upsert_records).exactly(records.size)
|
44
|
+
|
45
|
+
batch_consumer.send(:update_database, records)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should be called 1 time when batch size is nil' do
|
49
|
+
batch_consumer.class.config[:max_db_batch_size] = nil
|
50
|
+
expect(batch_consumer).to receive(:upsert_records).once
|
51
|
+
|
52
|
+
batch_consumer.send(:update_database, records)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'remove_records' do
|
57
|
+
let(:records) do
|
58
|
+
[
|
59
|
+
Deimos::Message.new(nil, nil, key: 1),
|
60
|
+
Deimos::Message.new(nil, nil, key: 2),
|
61
|
+
Deimos::Message.new(nil, nil, key: 3),
|
62
|
+
Deimos::Message.new(nil, nil, key: 4),
|
63
|
+
Deimos::Message.new(nil, nil, key: 5)
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should be called 1 time when record size < max batch size' do
|
68
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size + 1
|
69
|
+
expect(batch_consumer).to receive(:remove_records).once
|
70
|
+
|
71
|
+
batch_consumer.send(:update_database, records)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should be called 1 time when record size == max batch size' do
|
75
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size
|
76
|
+
expect(batch_consumer).to receive(:remove_records).once
|
77
|
+
|
78
|
+
batch_consumer.send(:update_database, records)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should be called multiple times when record size > max batch size' do
|
82
|
+
batch_consumer.class.config[:max_db_batch_size] = records.size - 1
|
83
|
+
expect(batch_consumer).to receive(:remove_records).twice
|
84
|
+
|
85
|
+
batch_consumer.send(:update_database, records)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should be called record.size times when max batch size is 1' do
|
89
|
+
batch_consumer.class.config[:max_db_batch_size] = 1
|
90
|
+
expect(batch_consumer).to receive(:remove_records).exactly(records.size)
|
91
|
+
|
92
|
+
batch_consumer.send(:update_database, records)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should be called 1 time when batch size is nil' do
|
96
|
+
batch_consumer.class.config[:max_db_batch_size] = nil
|
97
|
+
expect(batch_consumer).to receive(:remove_records).once
|
98
|
+
|
99
|
+
batch_consumer.send(:update_database, records)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/spec/backends/base_spec.rb
CHANGED
@@ -7,4 +7,28 @@ RSpec.describe Deimos::Backends::Base do
|
|
7
7
|
with(messages: messages, producer_class: MyProducer)
|
8
8
|
described_class.publish(producer_class: MyProducer, messages: messages)
|
9
9
|
end
|
10
|
+
|
11
|
+
describe 'payload_log method' do
|
12
|
+
it 'should return whole payload (default behavior)' do
|
13
|
+
log_message = described_class.send(:log_message, messages)
|
14
|
+
expect(log_message[:payloads].count).to eq(3)
|
15
|
+
expect(log_message[:payloads].first[:payload]).to eq({ 'foo' => 1 })
|
16
|
+
expect(log_message[:payloads].first[:key]).to eq('foo1')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return only keys of messages' do
|
20
|
+
Deimos.config.payload_log = :keys
|
21
|
+
log_message = described_class.send(:log_message, messages)
|
22
|
+
expect(log_message[:payload_keys].count).to eq(3)
|
23
|
+
expect(log_message[:payload_keys]).to be_a(Array)
|
24
|
+
expect(log_message[:payload_keys].first).to eq('foo1')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return only messages count' do
|
28
|
+
Deimos.config.payload_log = :count
|
29
|
+
log_message = described_class.send(:log_message, messages)
|
30
|
+
expect(log_message[:payloads_count]).to be_a(Integer)
|
31
|
+
expect(log_message[:payloads_count]).to eq(3)
|
32
|
+
end
|
33
|
+
end
|
10
34
|
end
|
@@ -90,7 +90,8 @@ describe Deimos, 'configuration' do
|
|
90
90
|
offset_retention_time: nil,
|
91
91
|
heartbeat_interval: 10,
|
92
92
|
handler: 'ConsumerTest::MyConsumer',
|
93
|
-
use_schema_classes: nil
|
93
|
+
use_schema_classes: nil,
|
94
|
+
max_db_batch_size: nil
|
94
95
|
}, {
|
95
96
|
topic: 'my_batch_consume_topic',
|
96
97
|
group_id: 'my_batch_group_id',
|
@@ -107,7 +108,8 @@ describe Deimos, 'configuration' do
|
|
107
108
|
offset_retention_time: nil,
|
108
109
|
heartbeat_interval: 10,
|
109
110
|
handler: 'ConsumerTest::MyBatchConsumer',
|
110
|
-
use_schema_classes: nil
|
111
|
+
use_schema_classes: nil,
|
112
|
+
max_db_batch_size: nil
|
111
113
|
}
|
112
114
|
],
|
113
115
|
producer: {
|
@@ -258,7 +260,8 @@ describe Deimos, 'configuration' do
|
|
258
260
|
offset_retention_time: 13,
|
259
261
|
heartbeat_interval: 13,
|
260
262
|
handler: 'MyConfigConsumer',
|
261
|
-
use_schema_classes: false
|
263
|
+
use_schema_classes: false,
|
264
|
+
max_db_batch_size: nil
|
262
265
|
}
|
263
266
|
],
|
264
267
|
producer: {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deimos-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.19.
|
4
|
+
version: 1.19.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|
@@ -410,6 +410,7 @@ files:
|
|
410
410
|
- ".rubocop_todo.yml"
|
411
411
|
- ".ruby-version"
|
412
412
|
- CHANGELOG.md
|
413
|
+
- CHANGELOG.md.orig
|
413
414
|
- CODE_OF_CONDUCT.md
|
414
415
|
- Dockerfile
|
415
416
|
- Gemfile
|
@@ -510,6 +511,7 @@ files:
|
|
510
511
|
- sig/fig_tree.rbs
|
511
512
|
- spec/active_record_batch_consumer_mysql_spec.rb
|
512
513
|
- spec/active_record_batch_consumer_spec.rb
|
514
|
+
- spec/active_record_consume/batch_consumption_spec.rb
|
513
515
|
- spec/active_record_consume/batch_slicer_spec.rb
|
514
516
|
- spec/active_record_consume/schema_model_converter_spec.rb
|
515
517
|
- spec/active_record_consumer_spec.rb
|
@@ -635,6 +637,7 @@ summary: Kafka libraries for Ruby.
|
|
635
637
|
test_files:
|
636
638
|
- spec/active_record_batch_consumer_mysql_spec.rb
|
637
639
|
- spec/active_record_batch_consumer_spec.rb
|
640
|
+
- spec/active_record_consume/batch_consumption_spec.rb
|
638
641
|
- spec/active_record_consume/batch_slicer_spec.rb
|
639
642
|
- spec/active_record_consume/schema_model_converter_spec.rb
|
640
643
|
- spec/active_record_consumer_spec.rb
|