deimos-ruby 1.24.3 → 2.0.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +0 -17
- data/.tool-versions +1 -0
- data/CHANGELOG.md +1 -1
- data/README.md +287 -498
- data/deimos-ruby.gemspec +4 -4
- data/docs/CONFIGURATION.md +133 -227
- data/docs/UPGRADING.md +237 -0
- data/lib/deimos/active_record_consume/batch_consumption.rb +28 -29
- data/lib/deimos/active_record_consume/message_consumption.rb +15 -21
- data/lib/deimos/active_record_consumer.rb +36 -26
- data/lib/deimos/active_record_producer.rb +28 -9
- data/lib/deimos/backends/base.rb +4 -35
- data/lib/deimos/backends/kafka.rb +6 -22
- data/lib/deimos/backends/kafka_async.rb +6 -22
- data/lib/deimos/backends/{db.rb → outbox.rb} +13 -9
- data/lib/deimos/config/configuration.rb +116 -385
- data/lib/deimos/consume/batch_consumption.rb +24 -124
- data/lib/deimos/consume/message_consumption.rb +36 -63
- data/lib/deimos/consumer.rb +16 -75
- data/lib/deimos/ext/consumer_route.rb +35 -0
- data/lib/deimos/ext/producer_middleware.rb +94 -0
- data/lib/deimos/ext/producer_route.rb +22 -0
- data/lib/deimos/ext/redraw.rb +29 -0
- data/lib/deimos/ext/routing_defaults.rb +72 -0
- data/lib/deimos/ext/schema_route.rb +70 -0
- data/lib/deimos/kafka_message.rb +2 -2
- data/lib/deimos/kafka_source.rb +2 -7
- data/lib/deimos/kafka_topic_info.rb +1 -1
- data/lib/deimos/logging.rb +71 -0
- data/lib/deimos/message.rb +2 -11
- data/lib/deimos/metrics/datadog.rb +40 -1
- data/lib/deimos/metrics/provider.rb +4 -4
- data/lib/deimos/producer.rb +39 -116
- data/lib/deimos/railtie.rb +6 -0
- data/lib/deimos/schema_backends/avro_base.rb +21 -21
- data/lib/deimos/schema_backends/avro_schema_registry.rb +1 -2
- data/lib/deimos/schema_backends/avro_validation.rb +2 -2
- data/lib/deimos/schema_backends/base.rb +19 -12
- data/lib/deimos/schema_backends/mock.rb +6 -1
- data/lib/deimos/schema_backends/plain.rb +47 -0
- data/lib/deimos/schema_class/base.rb +2 -2
- data/lib/deimos/schema_class/enum.rb +1 -1
- data/lib/deimos/schema_class/record.rb +2 -2
- data/lib/deimos/test_helpers.rb +95 -320
- data/lib/deimos/tracing/provider.rb +6 -6
- data/lib/deimos/transcoder.rb +88 -0
- data/lib/deimos/utils/db_poller/base.rb +16 -14
- data/lib/deimos/utils/db_poller/state_based.rb +3 -3
- data/lib/deimos/utils/db_poller/time_based.rb +4 -4
- data/lib/deimos/utils/db_poller.rb +1 -1
- data/lib/deimos/utils/deadlock_retry.rb +1 -1
- data/lib/deimos/utils/{db_producer.rb → outbox_producer.rb} +16 -47
- data/lib/deimos/utils/schema_class.rb +0 -7
- data/lib/deimos/version.rb +1 -1
- data/lib/deimos.rb +79 -26
- data/lib/generators/deimos/{db_backend_generator.rb → outbox_backend_generator.rb} +4 -4
- data/lib/generators/deimos/schema_class_generator.rb +0 -1
- data/lib/generators/deimos/v2/templates/karafka.rb.tt +149 -0
- data/lib/generators/deimos/v2_generator.rb +193 -0
- data/lib/tasks/deimos.rake +5 -7
- data/spec/active_record_batch_consumer_association_spec.rb +22 -13
- data/spec/active_record_batch_consumer_spec.rb +84 -65
- data/spec/active_record_consume/batch_consumption_spec.rb +10 -10
- data/spec/active_record_consume/batch_slicer_spec.rb +12 -12
- data/spec/active_record_consumer_spec.rb +29 -13
- data/spec/active_record_producer_spec.rb +36 -26
- data/spec/backends/base_spec.rb +0 -23
- data/spec/backends/kafka_async_spec.rb +1 -3
- data/spec/backends/kafka_spec.rb +1 -3
- data/spec/backends/{db_spec.rb → outbox_spec.rb} +14 -20
- data/spec/batch_consumer_spec.rb +66 -116
- data/spec/consumer_spec.rb +53 -147
- data/spec/deimos_spec.rb +10 -126
- data/spec/kafka_source_spec.rb +19 -52
- data/spec/karafka/karafka.rb +69 -0
- data/spec/karafka_config/karafka_spec.rb +97 -0
- data/spec/logging_spec.rb +25 -0
- data/spec/message_spec.rb +9 -9
- data/spec/producer_spec.rb +112 -254
- data/spec/rake_spec.rb +1 -3
- data/spec/schema_backends/avro_validation_spec.rb +1 -1
- data/spec/schemas/com/my-namespace/MySchemaWithTitle.avsc +22 -0
- data/spec/snapshots/consumers-no-nest.snap +49 -0
- data/spec/snapshots/consumers.snap +49 -0
- data/spec/snapshots/consumers_and_producers-no-nest.snap +49 -0
- data/spec/snapshots/consumers_and_producers.snap +49 -0
- data/spec/snapshots/consumers_circular-no-nest.snap +49 -0
- data/spec/snapshots/consumers_circular.snap +49 -0
- data/spec/snapshots/consumers_complex_types-no-nest.snap +49 -0
- data/spec/snapshots/consumers_complex_types.snap +49 -0
- data/spec/snapshots/consumers_nested-no-nest.snap +49 -0
- data/spec/snapshots/consumers_nested.snap +49 -0
- data/spec/snapshots/namespace_folders.snap +49 -0
- data/spec/snapshots/namespace_map.snap +49 -0
- data/spec/snapshots/producers_with_key-no-nest.snap +49 -0
- data/spec/snapshots/producers_with_key.snap +49 -0
- data/spec/spec_helper.rb +61 -29
- data/spec/utils/db_poller_spec.rb +49 -39
- data/spec/utils/{db_producer_spec.rb → outbox_producer_spec.rb} +17 -184
- metadata +58 -67
- data/lib/deimos/batch_consumer.rb +0 -7
- data/lib/deimos/config/phobos_config.rb +0 -164
- data/lib/deimos/instrumentation.rb +0 -95
- data/lib/deimos/monkey_patches/phobos_cli.rb +0 -35
- data/lib/deimos/utils/inline_consumer.rb +0 -158
- data/lib/deimos/utils/lag_reporter.rb +0 -186
- data/lib/deimos/utils/schema_controller_mixin.rb +0 -129
- data/spec/config/configuration_spec.rb +0 -329
- data/spec/kafka_listener_spec.rb +0 -55
- data/spec/phobos.bad_db.yml +0 -73
- data/spec/phobos.yml +0 -77
- data/spec/utils/inline_consumer_spec.rb +0 -31
- data/spec/utils/lag_reporter_spec.rb +0 -76
- data/spec/utils/platform_schema_validation_spec.rb +0 -0
- data/spec/utils/schema_controller_mixin_spec.rb +0 -84
- /data/lib/generators/deimos/{db_backend → outbox_backend}/templates/migration +0 -0
- /data/lib/generators/deimos/{db_backend → outbox_backend}/templates/rails3_migration +0 -0
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:
|
4
|
+
version: 2.0.0.pre.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|
@@ -31,53 +31,33 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: karafka
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: '2.0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: phobos
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.9'
|
54
|
-
- - "<"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '3.0'
|
57
|
-
type: :runtime
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '1.9'
|
64
|
-
- - "<"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '3.0'
|
46
|
+
version: '2.0'
|
67
47
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
48
|
+
name: fig_tree
|
69
49
|
requirement: !ruby/object:Gem::Requirement
|
70
50
|
requirements:
|
71
|
-
- - "
|
51
|
+
- - "~>"
|
72
52
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
53
|
+
version: 0.2.0
|
74
54
|
type: :runtime
|
75
55
|
prerelease: false
|
76
56
|
version_requirements: !ruby/object:Gem::Requirement
|
77
57
|
requirements:
|
78
|
-
- - "
|
58
|
+
- - "~>"
|
79
59
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
60
|
+
version: 0.2.0
|
81
61
|
- !ruby/object:Gem::Dependency
|
82
62
|
name: sigurd
|
83
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,19 +205,33 @@ dependencies:
|
|
225
205
|
- !ruby/object:Gem::Version
|
226
206
|
version: '1'
|
227
207
|
- !ruby/object:Gem::Dependency
|
228
|
-
name:
|
208
|
+
name: karafka-testing
|
229
209
|
requirement: !ruby/object:Gem::Requirement
|
230
210
|
requirements:
|
231
211
|
- - "~>"
|
232
212
|
- !ruby/object:Gem::Version
|
233
|
-
version: '0
|
213
|
+
version: '2.0'
|
234
214
|
type: :development
|
235
215
|
prerelease: false
|
236
216
|
version_requirements: !ruby/object:Gem::Requirement
|
237
217
|
requirements:
|
238
218
|
- - "~>"
|
239
219
|
- !ruby/object:Gem::Version
|
240
|
-
version: '0
|
220
|
+
version: '2.0'
|
221
|
+
- !ruby/object:Gem::Dependency
|
222
|
+
name: trilogy
|
223
|
+
requirement: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ">="
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0.1'
|
228
|
+
type: :development
|
229
|
+
prerelease: false
|
230
|
+
version_requirements: !ruby/object:Gem::Requirement
|
231
|
+
requirements:
|
232
|
+
- - ">="
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0.1'
|
241
235
|
- !ruby/object:Gem::Dependency
|
242
236
|
name: pg
|
243
237
|
requirement: !ruby/object:Gem::Requirement
|
@@ -422,6 +416,7 @@ files:
|
|
422
416
|
- ".rubocop.yml"
|
423
417
|
- ".rubocop_todo.yml"
|
424
418
|
- ".ruby-version"
|
419
|
+
- ".tool-versions"
|
425
420
|
- CHANGELOG.md
|
426
421
|
- CODE_OF_CONDUCT.md
|
427
422
|
- Dockerfile
|
@@ -452,26 +447,29 @@ files:
|
|
452
447
|
- lib/deimos/active_record_consumer.rb
|
453
448
|
- lib/deimos/active_record_producer.rb
|
454
449
|
- lib/deimos/backends/base.rb
|
455
|
-
- lib/deimos/backends/db.rb
|
456
450
|
- lib/deimos/backends/kafka.rb
|
457
451
|
- lib/deimos/backends/kafka_async.rb
|
452
|
+
- lib/deimos/backends/outbox.rb
|
458
453
|
- lib/deimos/backends/test.rb
|
459
|
-
- lib/deimos/batch_consumer.rb
|
460
454
|
- lib/deimos/config/configuration.rb
|
461
|
-
- lib/deimos/config/phobos_config.rb
|
462
455
|
- lib/deimos/consume/batch_consumption.rb
|
463
456
|
- lib/deimos/consume/message_consumption.rb
|
464
457
|
- lib/deimos/consumer.rb
|
465
458
|
- lib/deimos/exceptions.rb
|
466
|
-
- lib/deimos/
|
459
|
+
- lib/deimos/ext/consumer_route.rb
|
460
|
+
- lib/deimos/ext/producer_middleware.rb
|
461
|
+
- lib/deimos/ext/producer_route.rb
|
462
|
+
- lib/deimos/ext/redraw.rb
|
463
|
+
- lib/deimos/ext/routing_defaults.rb
|
464
|
+
- lib/deimos/ext/schema_route.rb
|
467
465
|
- lib/deimos/kafka_message.rb
|
468
466
|
- lib/deimos/kafka_source.rb
|
469
467
|
- lib/deimos/kafka_topic_info.rb
|
468
|
+
- lib/deimos/logging.rb
|
470
469
|
- lib/deimos/message.rb
|
471
470
|
- lib/deimos/metrics/datadog.rb
|
472
471
|
- lib/deimos/metrics/mock.rb
|
473
472
|
- lib/deimos/metrics/provider.rb
|
474
|
-
- lib/deimos/monkey_patches/phobos_cli.rb
|
475
473
|
- lib/deimos/poll_info.rb
|
476
474
|
- lib/deimos/producer.rb
|
477
475
|
- lib/deimos/railtie.rb
|
@@ -482,6 +480,7 @@ files:
|
|
482
480
|
- lib/deimos/schema_backends/avro_validation.rb
|
483
481
|
- lib/deimos/schema_backends/base.rb
|
484
482
|
- lib/deimos/schema_backends/mock.rb
|
483
|
+
- lib/deimos/schema_backends/plain.rb
|
485
484
|
- lib/deimos/schema_class/base.rb
|
486
485
|
- lib/deimos/schema_class/enum.rb
|
487
486
|
- lib/deimos/schema_class/record.rb
|
@@ -490,32 +489,32 @@ files:
|
|
490
489
|
- lib/deimos/tracing/datadog.rb
|
491
490
|
- lib/deimos/tracing/mock.rb
|
492
491
|
- lib/deimos/tracing/provider.rb
|
492
|
+
- lib/deimos/transcoder.rb
|
493
493
|
- lib/deimos/utils/db_poller.rb
|
494
494
|
- lib/deimos/utils/db_poller/base.rb
|
495
495
|
- lib/deimos/utils/db_poller/state_based.rb
|
496
496
|
- lib/deimos/utils/db_poller/time_based.rb
|
497
|
-
- lib/deimos/utils/db_producer.rb
|
498
497
|
- lib/deimos/utils/deadlock_retry.rb
|
499
|
-
- lib/deimos/utils/
|
500
|
-
- lib/deimos/utils/lag_reporter.rb
|
498
|
+
- lib/deimos/utils/outbox_producer.rb
|
501
499
|
- lib/deimos/utils/schema_class.rb
|
502
|
-
- lib/deimos/utils/schema_controller_mixin.rb
|
503
500
|
- lib/deimos/version.rb
|
504
501
|
- lib/generators/deimos/active_record/templates/migration.rb.tt
|
505
502
|
- lib/generators/deimos/active_record/templates/model.rb.tt
|
506
503
|
- lib/generators/deimos/active_record_generator.rb
|
507
504
|
- lib/generators/deimos/bulk_import_id/templates/migration.rb.tt
|
508
505
|
- lib/generators/deimos/bulk_import_id_generator.rb
|
509
|
-
- lib/generators/deimos/db_backend/templates/migration
|
510
|
-
- lib/generators/deimos/db_backend/templates/rails3_migration
|
511
|
-
- lib/generators/deimos/db_backend_generator.rb
|
512
506
|
- lib/generators/deimos/db_poller/templates/migration
|
513
507
|
- lib/generators/deimos/db_poller/templates/rails3_migration
|
514
508
|
- lib/generators/deimos/db_poller_generator.rb
|
509
|
+
- lib/generators/deimos/outbox_backend/templates/migration
|
510
|
+
- lib/generators/deimos/outbox_backend/templates/rails3_migration
|
511
|
+
- lib/generators/deimos/outbox_backend_generator.rb
|
515
512
|
- lib/generators/deimos/schema_class/templates/schema_class.rb.tt
|
516
513
|
- lib/generators/deimos/schema_class/templates/schema_enum.rb.tt
|
517
514
|
- lib/generators/deimos/schema_class/templates/schema_record.rb.tt
|
518
515
|
- lib/generators/deimos/schema_class_generator.rb
|
516
|
+
- lib/generators/deimos/v2/templates/karafka.rb.tt
|
517
|
+
- lib/generators/deimos/v2_generator.rb
|
519
518
|
- lib/tasks/deimos.rake
|
520
519
|
- rbs_collection.lock.yaml
|
521
520
|
- rbs_collection.yaml
|
@@ -532,11 +531,10 @@ files:
|
|
532
531
|
- spec/active_record_consumer_spec.rb
|
533
532
|
- spec/active_record_producer_spec.rb
|
534
533
|
- spec/backends/base_spec.rb
|
535
|
-
- spec/backends/db_spec.rb
|
536
534
|
- spec/backends/kafka_async_spec.rb
|
537
535
|
- spec/backends/kafka_spec.rb
|
536
|
+
- spec/backends/outbox_spec.rb
|
538
537
|
- spec/batch_consumer_spec.rb
|
539
|
-
- spec/config/configuration_spec.rb
|
540
538
|
- spec/consumer_spec.rb
|
541
539
|
- spec/deimos_spec.rb
|
542
540
|
- spec/generators/active_record_generator_spec.rb
|
@@ -546,12 +544,12 @@ files:
|
|
546
544
|
- spec/generators/schema_class_generator_spec.rb
|
547
545
|
- spec/handlers/my_batch_consumer.rb
|
548
546
|
- spec/handlers/my_consumer.rb
|
549
|
-
- spec/kafka_listener_spec.rb
|
550
547
|
- spec/kafka_source_spec.rb
|
551
548
|
- spec/kafka_topic_info_spec.rb
|
549
|
+
- spec/karafka/karafka.rb
|
550
|
+
- spec/karafka_config/karafka_spec.rb
|
551
|
+
- spec/logging_spec.rb
|
552
552
|
- spec/message_spec.rb
|
553
|
-
- spec/phobos.bad_db.yml
|
554
|
-
- spec/phobos.yml
|
555
553
|
- spec/producer_spec.rb
|
556
554
|
- spec/rake_spec.rb
|
557
555
|
- spec/schema_backends/avro_base_shared.rb
|
@@ -569,6 +567,7 @@ files:
|
|
569
567
|
- spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
|
570
568
|
- spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
|
571
569
|
- spec/schemas/com/my-namespace/MySchemaWithId.avsc
|
570
|
+
- spec/schemas/com/my-namespace/MySchemaWithTitle.avsc
|
572
571
|
- spec/schemas/com/my-namespace/MySchemaWithUniqueId.avsc
|
573
572
|
- spec/schemas/com/my-namespace/MySchema_key.avsc
|
574
573
|
- spec/schemas/com/my-namespace/Wibble.avsc
|
@@ -620,12 +619,8 @@ files:
|
|
620
619
|
- spec/snapshots/producers_with_key.snap
|
621
620
|
- spec/spec_helper.rb
|
622
621
|
- spec/utils/db_poller_spec.rb
|
623
|
-
- spec/utils/db_producer_spec.rb
|
624
622
|
- spec/utils/deadlock_retry_spec.rb
|
625
|
-
- spec/utils/
|
626
|
-
- spec/utils/lag_reporter_spec.rb
|
627
|
-
- spec/utils/platform_schema_validation_spec.rb
|
628
|
-
- spec/utils/schema_controller_mixin_spec.rb
|
623
|
+
- spec/utils/outbox_producer_spec.rb
|
629
624
|
- support/deimos-solo.png
|
630
625
|
- support/deimos-with-name-next.png
|
631
626
|
- support/deimos-with-name.png
|
@@ -645,9 +640,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
645
640
|
version: '0'
|
646
641
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
647
642
|
requirements:
|
648
|
-
- - "
|
643
|
+
- - ">"
|
649
644
|
- !ruby/object:Gem::Version
|
650
|
-
version:
|
645
|
+
version: 1.3.1
|
651
646
|
requirements: []
|
652
647
|
rubygems_version: 3.4.10
|
653
648
|
signing_key:
|
@@ -663,11 +658,10 @@ test_files:
|
|
663
658
|
- spec/active_record_consumer_spec.rb
|
664
659
|
- spec/active_record_producer_spec.rb
|
665
660
|
- spec/backends/base_spec.rb
|
666
|
-
- spec/backends/db_spec.rb
|
667
661
|
- spec/backends/kafka_async_spec.rb
|
668
662
|
- spec/backends/kafka_spec.rb
|
663
|
+
- spec/backends/outbox_spec.rb
|
669
664
|
- spec/batch_consumer_spec.rb
|
670
|
-
- spec/config/configuration_spec.rb
|
671
665
|
- spec/consumer_spec.rb
|
672
666
|
- spec/deimos_spec.rb
|
673
667
|
- spec/generators/active_record_generator_spec.rb
|
@@ -677,12 +671,12 @@ test_files:
|
|
677
671
|
- spec/generators/schema_class_generator_spec.rb
|
678
672
|
- spec/handlers/my_batch_consumer.rb
|
679
673
|
- spec/handlers/my_consumer.rb
|
680
|
-
- spec/kafka_listener_spec.rb
|
681
674
|
- spec/kafka_source_spec.rb
|
682
675
|
- spec/kafka_topic_info_spec.rb
|
676
|
+
- spec/karafka/karafka.rb
|
677
|
+
- spec/karafka_config/karafka_spec.rb
|
678
|
+
- spec/logging_spec.rb
|
683
679
|
- spec/message_spec.rb
|
684
|
-
- spec/phobos.bad_db.yml
|
685
|
-
- spec/phobos.yml
|
686
680
|
- spec/producer_spec.rb
|
687
681
|
- spec/rake_spec.rb
|
688
682
|
- spec/schema_backends/avro_base_shared.rb
|
@@ -700,6 +694,7 @@ test_files:
|
|
700
694
|
- spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
|
701
695
|
- spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
|
702
696
|
- spec/schemas/com/my-namespace/MySchemaWithId.avsc
|
697
|
+
- spec/schemas/com/my-namespace/MySchemaWithTitle.avsc
|
703
698
|
- spec/schemas/com/my-namespace/MySchemaWithUniqueId.avsc
|
704
699
|
- spec/schemas/com/my-namespace/MySchema_key.avsc
|
705
700
|
- spec/schemas/com/my-namespace/Wibble.avsc
|
@@ -751,9 +746,5 @@ test_files:
|
|
751
746
|
- spec/snapshots/producers_with_key.snap
|
752
747
|
- spec/spec_helper.rb
|
753
748
|
- spec/utils/db_poller_spec.rb
|
754
|
-
- spec/utils/db_producer_spec.rb
|
755
749
|
- spec/utils/deadlock_retry_spec.rb
|
756
|
-
- spec/utils/
|
757
|
-
- spec/utils/lag_reporter_spec.rb
|
758
|
-
- spec/utils/platform_schema_validation_spec.rb
|
759
|
-
- spec/utils/schema_controller_mixin_spec.rb
|
750
|
+
- spec/utils/outbox_producer_spec.rb
|
@@ -1,164 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/array'
|
4
|
-
|
5
|
-
module Deimos
|
6
|
-
# Module to handle phobos.yml as well as outputting the configuration to save
|
7
|
-
# to Phobos itself.
|
8
|
-
module PhobosConfig
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
# @return [Hash]
|
12
|
-
def to_h
|
13
|
-
(FIELDS + [:handler]).map { |f|
|
14
|
-
val = self.send(f)
|
15
|
-
if f == :backoff && val
|
16
|
-
[:backoff, _backoff(val)]
|
17
|
-
elsif val.present?
|
18
|
-
[f, val]
|
19
|
-
end
|
20
|
-
}.to_h
|
21
|
-
end
|
22
|
-
|
23
|
-
# @return [void]
|
24
|
-
def reset!
|
25
|
-
super
|
26
|
-
Phobos.configure(self.phobos_config)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Create a hash representing the config that Phobos expects.
|
30
|
-
# @return [Hash]
|
31
|
-
def phobos_config
|
32
|
-
p_config = {
|
33
|
-
logger: Logger.new(STDOUT),
|
34
|
-
custom_logger: self.phobos_logger,
|
35
|
-
custom_kafka_logger: self.kafka.logger,
|
36
|
-
kafka: {
|
37
|
-
client_id: self.kafka.client_id,
|
38
|
-
connect_timeout: self.kafka.connect_timeout,
|
39
|
-
socket_timeout: self.kafka.socket_timeout,
|
40
|
-
ssl_verify_hostname: self.kafka.ssl.verify_hostname,
|
41
|
-
ssl_ca_certs_from_system: self.kafka.ssl.ca_certs_from_system,
|
42
|
-
seed_brokers: Array.wrap(self.kafka.seed_brokers)
|
43
|
-
},
|
44
|
-
producer: {
|
45
|
-
ack_timeout: self.producers.ack_timeout,
|
46
|
-
required_acks: self.producers.required_acks,
|
47
|
-
max_retries: self.producers.max_retries,
|
48
|
-
retry_backoff: self.producers.retry_backoff,
|
49
|
-
max_buffer_size: self.producers.max_buffer_size,
|
50
|
-
max_buffer_bytesize: self.producers.max_buffer_bytesize,
|
51
|
-
compression_codec: self.producers.compression_codec,
|
52
|
-
compression_threshold: self.producers.compression_threshold,
|
53
|
-
max_queue_size: self.producers.max_queue_size,
|
54
|
-
delivery_threshold: self.producers.delivery_threshold,
|
55
|
-
delivery_interval: self.producers.delivery_interval,
|
56
|
-
persistent_connections: self.producers.persistent_connections
|
57
|
-
},
|
58
|
-
consumer: {
|
59
|
-
session_timeout: self.consumers.session_timeout,
|
60
|
-
offset_commit_interval: self.consumers.offset_commit_interval,
|
61
|
-
offset_commit_threshold: self.consumers.offset_commit_threshold,
|
62
|
-
heartbeat_interval: self.consumers.heartbeat_interval
|
63
|
-
},
|
64
|
-
backoff: _backoff(self.consumers.backoff.to_a)
|
65
|
-
}
|
66
|
-
|
67
|
-
p_config[:listeners] = self.consumer_objects.map do |consumer|
|
68
|
-
next nil if consumer.disabled
|
69
|
-
|
70
|
-
hash = consumer.to_h.reject do |k, _|
|
71
|
-
%i(class_name schema namespace key_config backoff disabled replace_associations
|
72
|
-
bulk_import_id_column).include?(k)
|
73
|
-
end
|
74
|
-
hash = hash.map { |k, v| [k, v.is_a?(Symbol) ? v.to_s : v] }.to_h
|
75
|
-
hash[:handler] = consumer.class_name
|
76
|
-
if consumer.backoff
|
77
|
-
hash[:backoff] = _backoff(consumer.backoff.to_a)
|
78
|
-
end
|
79
|
-
hash
|
80
|
-
end
|
81
|
-
p_config[:listeners].compact!
|
82
|
-
|
83
|
-
if self.kafka.ssl.enabled
|
84
|
-
%w(ca_cert client_cert client_cert_key).each do |key|
|
85
|
-
next if self.kafka.ssl.send(key).blank?
|
86
|
-
|
87
|
-
p_config[:kafka]["ssl_#{key}".to_sym] = ssl_var_contents(self.kafka.ssl.send(key))
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
if self.kafka.sasl.enabled
|
92
|
-
p_config[:kafka][:sasl_over_ssl] = self.kafka.sasl.enforce_ssl
|
93
|
-
%w(
|
94
|
-
gssapi_principal
|
95
|
-
gssapi_keytab
|
96
|
-
plain_authzid
|
97
|
-
plain_username
|
98
|
-
plain_password
|
99
|
-
scram_username
|
100
|
-
scram_password
|
101
|
-
scram_mechanism
|
102
|
-
oauth_token_provider
|
103
|
-
).each do |key|
|
104
|
-
value = self.kafka.sasl.send(key)
|
105
|
-
next if value.blank?
|
106
|
-
|
107
|
-
p_config[:kafka]["sasl_#{key}".to_sym] = value
|
108
|
-
end
|
109
|
-
end
|
110
|
-
p_config
|
111
|
-
end
|
112
|
-
|
113
|
-
# @param key [String]
|
114
|
-
# @return [String]
|
115
|
-
def ssl_var_contents(key)
|
116
|
-
File.exist?(key) ? File.read(key) : key
|
117
|
-
end
|
118
|
-
|
119
|
-
# Legacy method to parse Phobos config file
|
120
|
-
# @!visibility private
|
121
|
-
def phobos_config_file=(file)
|
122
|
-
pconfig = YAML.load(ERB.new(File.read(File.expand_path(file))).result). # rubocop:disable Security/YAMLLoad
|
123
|
-
with_indifferent_access
|
124
|
-
self.logger&.warn('phobos.yml is deprecated - use direct configuration instead.')
|
125
|
-
pconfig[:kafka].each do |k, v|
|
126
|
-
if k.starts_with?('ssl')
|
127
|
-
k = k.sub('ssl_', '')
|
128
|
-
self.kafka.ssl.send("#{k}=", v)
|
129
|
-
elsif k.starts_with?('sasl')
|
130
|
-
k = (k == 'sasl_over_ssl') ? 'enforce_ssl' : k.sub('sasl_', '')
|
131
|
-
self.kafka.sasl.send("#{k}=", v)
|
132
|
-
else
|
133
|
-
self.kafka.send("#{k}=", v)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
pconfig[:producer].each do |k, v|
|
137
|
-
self.producers.send("#{k}=", v)
|
138
|
-
end
|
139
|
-
pconfig[:consumer].each do |k, v|
|
140
|
-
self.consumers.send("#{k}=", v)
|
141
|
-
end
|
142
|
-
self.consumers.backoff = pconfig[:backoff][:min_ms]..pconfig[:backoff][:max_ms]
|
143
|
-
pconfig[:listeners].each do |listener_hash|
|
144
|
-
self.consumer do
|
145
|
-
listener_hash.each do |k, v|
|
146
|
-
k = 'class_name' if k == 'handler'
|
147
|
-
send(k, v)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
private
|
154
|
-
|
155
|
-
# @param values [Array<Integer>]
|
156
|
-
# @return [Hash<Integer>]
|
157
|
-
def _backoff(values)
|
158
|
-
{
|
159
|
-
min_ms: values[0],
|
160
|
-
max_ms: values[-1]
|
161
|
-
}
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/notifications'
|
4
|
-
require 'active_support/concern'
|
5
|
-
|
6
|
-
# :nodoc:
|
7
|
-
module Deimos
|
8
|
-
# Copied from Phobos instrumentation.
|
9
|
-
module Instrumentation
|
10
|
-
extend ActiveSupport::Concern
|
11
|
-
|
12
|
-
# @return [String]
|
13
|
-
NAMESPACE = 'Deimos'
|
14
|
-
|
15
|
-
# :nodoc:
|
16
|
-
module ClassMethods
|
17
|
-
# @param event [String]
|
18
|
-
# @return [void]
|
19
|
-
def subscribe(event)
|
20
|
-
ActiveSupport::Notifications.subscribe("#{NAMESPACE}.#{event}") do |*args|
|
21
|
-
yield(ActiveSupport::Notifications::Event.new(*args)) if block_given?
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param subscriber [ActiveSupport::Subscriber]
|
26
|
-
# @return [void]
|
27
|
-
def unsubscribe(subscriber)
|
28
|
-
ActiveSupport::Notifications.unsubscribe(subscriber)
|
29
|
-
end
|
30
|
-
|
31
|
-
# @param event [String]
|
32
|
-
# @param extra [Hash]
|
33
|
-
# @return [void]
|
34
|
-
def instrument(event, extra={})
|
35
|
-
ActiveSupport::Notifications.instrument("#{NAMESPACE}.#{event}", extra) do |extra2|
|
36
|
-
yield(extra2) if block_given?
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
include Instrumentation
|
43
|
-
|
44
|
-
# This module listens to events published by RubyKafka.
|
45
|
-
module KafkaListener
|
46
|
-
# @param exception [Exception]
|
47
|
-
def self.handle_exception_with_messages(exception)
|
48
|
-
messages = exception.failed_messages
|
49
|
-
messages.group_by(&:topic).each do |topic, batch|
|
50
|
-
producer = Deimos::Producer.descendants.find { |c| c.topic == topic }
|
51
|
-
next if batch.empty? || !producer
|
52
|
-
|
53
|
-
decoder = Deimos.schema_backend(schema: producer.config[:schema],
|
54
|
-
namespace: producer.config[:namespace])
|
55
|
-
payloads = batch.map { |m| decoder.decode(m.value) }
|
56
|
-
|
57
|
-
Deimos.config.metrics&.increment(
|
58
|
-
'publish_error',
|
59
|
-
tags: %W(topic:#{topic}),
|
60
|
-
by: payloads.size
|
61
|
-
)
|
62
|
-
Deimos.instrument(
|
63
|
-
'produce_error',
|
64
|
-
producer: producer,
|
65
|
-
topic: topic,
|
66
|
-
exception_object: exception,
|
67
|
-
payloads: payloads
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# Listens for any exceptions that happen during publishing and re-publishes
|
73
|
-
# as a Deimos event.
|
74
|
-
# @param event [ActiveSupport::Notifications::Event]
|
75
|
-
# @return [void]
|
76
|
-
def self.send_produce_error(event)
|
77
|
-
exception = event.payload[:exception_object]
|
78
|
-
return unless exception
|
79
|
-
|
80
|
-
if exception.respond_to?(:failed_messages)
|
81
|
-
handle_exception_with_messages(exception)
|
82
|
-
else
|
83
|
-
Deimos.config.metrics&.increment(
|
84
|
-
'publish_error',
|
85
|
-
by: event.payload[:message_count] || 1
|
86
|
-
)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
ActiveSupport::Notifications.subscribe('deliver_messages.producer.kafka') do |*args|
|
92
|
-
event = ActiveSupport::Notifications::Event.new(*args)
|
93
|
-
KafkaListener.send_produce_error(event)
|
94
|
-
end
|
95
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'phobos/cli/start'
|
4
|
-
|
5
|
-
#@!visibility private
|
6
|
-
module Phobos
|
7
|
-
# :nodoc:
|
8
|
-
module CLI
|
9
|
-
# :nodoc:
|
10
|
-
class Start
|
11
|
-
# :nodoc:
|
12
|
-
def validate_listeners!
|
13
|
-
Phobos.config.listeners.each do |listener|
|
14
|
-
handler = listener.handler
|
15
|
-
begin
|
16
|
-
handler.constantize
|
17
|
-
rescue NameError
|
18
|
-
error_exit("Handler '#{handler}' not defined")
|
19
|
-
end
|
20
|
-
|
21
|
-
delivery = listener.delivery
|
22
|
-
if delivery.nil?
|
23
|
-
Phobos::CLI.logger.warn do
|
24
|
-
Hash(message: "Delivery option should be specified, defaulting to 'batch'"\
|
25
|
-
' - specify this option to silence this message')
|
26
|
-
end
|
27
|
-
elsif !Listener::DELIVERY_OPTS.include?(delivery)
|
28
|
-
error_exit("Invalid delivery option '#{delivery}'. Please specify one of: "\
|
29
|
-
"#{Listener::DELIVERY_OPTS.join(', ')}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|