deimos-ruby 1.11.2 → 1.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -2
  3. data/Gemfile.lock +8 -8
  4. data/README.md +103 -0
  5. data/deimos-ruby.gemspec +1 -1
  6. data/docs/CONFIGURATION.md +4 -0
  7. data/lib/deimos/active_record_consume/batch_consumption.rb +7 -9
  8. data/lib/deimos/active_record_consume/message_consumption.rb +4 -3
  9. data/lib/deimos/active_record_consumer.rb +2 -2
  10. data/lib/deimos/active_record_producer.rb +3 -0
  11. data/lib/deimos/config/configuration.rb +29 -0
  12. data/lib/deimos/consume/batch_consumption.rb +2 -2
  13. data/lib/deimos/consume/message_consumption.rb +2 -2
  14. data/lib/deimos/consumer.rb +10 -0
  15. data/lib/deimos/producer.rb +4 -3
  16. data/lib/deimos/schema_backends/avro_base.rb +64 -1
  17. data/lib/deimos/schema_backends/avro_schema_registry.rb +1 -1
  18. data/lib/deimos/schema_backends/base.rb +18 -2
  19. data/lib/deimos/schema_class/base.rb +62 -0
  20. data/lib/deimos/schema_class/enum.rb +24 -0
  21. data/lib/deimos/schema_class/record.rb +66 -0
  22. data/lib/deimos/shared_config.rb +5 -0
  23. data/lib/deimos/test_helpers.rb +43 -7
  24. data/lib/deimos/utils/schema_class.rb +29 -0
  25. data/lib/deimos/version.rb +1 -1
  26. data/lib/deimos.rb +21 -0
  27. data/lib/generators/deimos/schema_class/templates/schema_class.rb.tt +15 -0
  28. data/lib/generators/deimos/schema_class/templates/schema_enum.rb.tt +21 -0
  29. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +65 -0
  30. data/lib/generators/deimos/schema_class_generator.rb +247 -0
  31. data/lib/tasks/deimos.rake +8 -0
  32. data/spec/active_record_batch_consumer_spec.rb +120 -110
  33. data/spec/active_record_consumer_spec.rb +97 -88
  34. data/spec/active_record_producer_spec.rb +38 -27
  35. data/spec/batch_consumer_spec.rb +37 -28
  36. data/spec/config/configuration_spec.rb +10 -3
  37. data/spec/consumer_spec.rb +95 -84
  38. data/spec/generators/active_record_generator_spec.rb +1 -0
  39. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +206 -0
  40. data/spec/generators/schema_class_generator_spec.rb +186 -0
  41. data/spec/producer_spec.rb +110 -0
  42. data/spec/schema_classes/generated.rb +156 -0
  43. data/spec/schema_classes/my_nested_schema.rb +114 -0
  44. data/spec/schema_classes/my_schema.rb +53 -0
  45. data/spec/schema_classes/my_schema_key.rb +35 -0
  46. data/spec/schema_classes/my_schema_with_complex_types.rb +172 -0
  47. data/spec/schemas/com/my-namespace/Generated.avsc +6 -0
  48. data/spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc +95 -0
  49. data/spec/spec_helper.rb +6 -1
  50. metadata +28 -4
@@ -0,0 +1,95 @@
1
+ {
2
+ "namespace": "com.my-namespace",
3
+ "name": "MySchemaWithComplexTypes",
4
+ "type": "record",
5
+ "doc": "Test schema",
6
+ "fields": [
7
+ {
8
+ "name": "test_id",
9
+ "type": "string",
10
+ "doc": "test string"
11
+ },
12
+ {
13
+ "name": "test_float",
14
+ "type": "float",
15
+ "doc": "test float"
16
+ },
17
+ {
18
+ "name": "test_string_array",
19
+ "type": {
20
+ "type": "array",
21
+ "items": "string"
22
+ },
23
+ "default": ["test"]
24
+ },
25
+ {
26
+ "name": "test_int_array",
27
+ "type": {
28
+ "type": "array",
29
+ "items": "int"
30
+ },
31
+ "default": [123]
32
+ },
33
+ {
34
+ "name": "test_optional_int",
35
+ "type": [ "int", "null" ],
36
+ "default": 123
37
+ },
38
+ {
39
+ "name": "some_integer_map",
40
+ "doc": "some record map",
41
+ "type": {
42
+ "type": "map",
43
+ "values": "int"
44
+ },
45
+ "default": {"abc": 123}
46
+ },
47
+ {
48
+ "name": "some_record",
49
+ "type": {
50
+ "type": "record",
51
+ "name": "ARecord",
52
+ "fields": [
53
+ {
54
+ "name": "a_record_field",
55
+ "type": "string"
56
+ }
57
+ ]
58
+ },
59
+ "default": {"a_record_field": "Test String"}
60
+ },
61
+ {
62
+ "name": "some_optional_record",
63
+ "doc": "some optional record",
64
+ "type": [ "null", "ARecord" ],
65
+ "default": null
66
+ },
67
+ {
68
+ "name": "some_record_array",
69
+ "doc": "some record array",
70
+ "type": {
71
+ "type": "array",
72
+ "items": "ARecord"
73
+ }
74
+ },
75
+ {
76
+ "name": "some_record_map",
77
+ "doc": "some record map",
78
+ "type": {
79
+ "type": "map",
80
+ "values": "ARecord"
81
+ }
82
+ },
83
+ {
84
+ "name": "some_enum_array",
85
+ "type": {
86
+ "type": "array",
87
+ "items": {
88
+ "type": "enum",
89
+ "name": "AnEnum",
90
+ "symbols": ["sym1", "sym2"]
91
+ }
92
+ }
93
+ }
94
+ ]
95
+ }
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,10 @@ require 'activerecord-import'
13
13
  require 'handlers/my_batch_consumer'
14
14
  require 'handlers/my_consumer'
15
15
  require 'rspec/rails'
16
+ Dir['./spec/schema_classes/**/*.rb'].sort.each { |f| require f }
17
+
18
+ # Constants used for consumer specs
19
+ SCHEMA_CLASS_SETTINGS = { off: false, on: true }.freeze
16
20
 
17
21
  class DeimosApp < Rails::Application
18
22
  end
@@ -100,7 +104,7 @@ module DbConfigs
100
104
  DB_OPTIONS.each do |options|
101
105
  describe subject, :integration, db_config: options do
102
106
 
103
- include_context 'with DB'
107
+ include_context('with DB')
104
108
  describe options[:adapter] do # rubocop:disable RSpec/EmptyExampleGroup
105
109
  self.instance_eval(&block)
106
110
  end
@@ -192,6 +196,7 @@ RSpec.configure do |config|
192
196
  deimos_config.logger = Logger.new('/dev/null')
193
197
  deimos_config.logger.level = Logger::INFO
194
198
  deimos_config.schema.backend = :avro_validation
199
+ deimos_config.schema.generated_class_path = 'spec/schema_classes'
195
200
  end
196
201
  end
197
202
 
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.11.2
4
+ version: 1.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf
@@ -302,14 +302,14 @@ dependencies:
302
302
  requirements:
303
303
  - - '='
304
304
  - !ruby/object:Gem::Version
305
- version: 0.88.0
305
+ version: 0.89.0
306
306
  type: :development
307
307
  prerelease: false
308
308
  version_requirements: !ruby/object:Gem::Requirement
309
309
  requirements:
310
310
  - - '='
311
311
  - !ruby/object:Gem::Version
312
- version: 0.88.0
312
+ version: 0.89.0
313
313
  - !ruby/object:Gem::Dependency
314
314
  name: rubocop-rspec
315
315
  requirement: !ruby/object:Gem::Requirement
@@ -409,6 +409,9 @@ files:
409
409
  - lib/deimos/schema_backends/avro_validation.rb
410
410
  - lib/deimos/schema_backends/base.rb
411
411
  - lib/deimos/schema_backends/mock.rb
412
+ - lib/deimos/schema_class/base.rb
413
+ - lib/deimos/schema_class/enum.rb
414
+ - lib/deimos/schema_class/record.rb
412
415
  - lib/deimos/shared_config.rb
413
416
  - lib/deimos/test_helpers.rb
414
417
  - lib/deimos/tracing/datadog.rb
@@ -419,6 +422,7 @@ files:
419
422
  - lib/deimos/utils/deadlock_retry.rb
420
423
  - lib/deimos/utils/inline_consumer.rb
421
424
  - lib/deimos/utils/lag_reporter.rb
425
+ - lib/deimos/utils/schema_class.rb
422
426
  - lib/deimos/utils/schema_controller_mixin.rb
423
427
  - lib/deimos/version.rb
424
428
  - lib/generators/deimos/active_record/templates/migration.rb.tt
@@ -430,6 +434,10 @@ files:
430
434
  - lib/generators/deimos/db_poller/templates/migration
431
435
  - lib/generators/deimos/db_poller/templates/rails3_migration
432
436
  - lib/generators/deimos/db_poller_generator.rb
437
+ - lib/generators/deimos/schema_class/templates/schema_class.rb.tt
438
+ - lib/generators/deimos/schema_class/templates/schema_enum.rb.tt
439
+ - lib/generators/deimos/schema_class/templates/schema_record.rb.tt
440
+ - lib/generators/deimos/schema_class_generator.rb
433
441
  - lib/tasks/deimos.rake
434
442
  - spec/active_record_batch_consumer_spec.rb
435
443
  - spec/active_record_consume/batch_slicer_spec.rb
@@ -445,6 +453,8 @@ files:
445
453
  - spec/consumer_spec.rb
446
454
  - spec/deimos_spec.rb
447
455
  - spec/generators/active_record_generator_spec.rb
456
+ - spec/generators/schema_class/my_schema_with_complex_types_spec.rb
457
+ - spec/generators/schema_class_generator_spec.rb
448
458
  - spec/handlers/my_batch_consumer.rb
449
459
  - spec/handlers/my_consumer.rb
450
460
  - spec/kafka_listener_spec.rb
@@ -460,12 +470,18 @@ files:
460
470
  - spec/schema_backends/avro_schema_registry_spec.rb
461
471
  - spec/schema_backends/avro_validation_spec.rb
462
472
  - spec/schema_backends/base_spec.rb
473
+ - spec/schema_classes/generated.rb
474
+ - spec/schema_classes/my_nested_schema.rb
475
+ - spec/schema_classes/my_schema.rb
476
+ - spec/schema_classes/my_schema_key.rb
477
+ - spec/schema_classes/my_schema_with_complex_types.rb
463
478
  - spec/schemas/com/my-namespace/Generated.avsc
464
479
  - spec/schemas/com/my-namespace/MyNestedSchema.avsc
465
480
  - spec/schemas/com/my-namespace/MySchema-key.avsc
466
481
  - spec/schemas/com/my-namespace/MySchema.avsc
467
482
  - spec/schemas/com/my-namespace/MySchemaCompound-key.avsc
468
483
  - spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
484
+ - spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
469
485
  - spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
470
486
  - spec/schemas/com/my-namespace/MySchemaWithId.avsc
471
487
  - spec/schemas/com/my-namespace/MySchemaWithUniqueId.avsc
@@ -528,6 +544,8 @@ test_files:
528
544
  - spec/consumer_spec.rb
529
545
  - spec/deimos_spec.rb
530
546
  - spec/generators/active_record_generator_spec.rb
547
+ - spec/generators/schema_class/my_schema_with_complex_types_spec.rb
548
+ - spec/generators/schema_class_generator_spec.rb
531
549
  - spec/handlers/my_batch_consumer.rb
532
550
  - spec/handlers/my_consumer.rb
533
551
  - spec/kafka_listener_spec.rb
@@ -543,12 +561,18 @@ test_files:
543
561
  - spec/schema_backends/avro_schema_registry_spec.rb
544
562
  - spec/schema_backends/avro_validation_spec.rb
545
563
  - spec/schema_backends/base_spec.rb
564
+ - spec/schema_classes/generated.rb
565
+ - spec/schema_classes/my_nested_schema.rb
566
+ - spec/schema_classes/my_schema.rb
567
+ - spec/schema_classes/my_schema_key.rb
568
+ - spec/schema_classes/my_schema_with_complex_types.rb
546
569
  - spec/schemas/com/my-namespace/Generated.avsc
547
570
  - spec/schemas/com/my-namespace/MyNestedSchema.avsc
548
571
  - spec/schemas/com/my-namespace/MySchema-key.avsc
549
572
  - spec/schemas/com/my-namespace/MySchema.avsc
550
573
  - spec/schemas/com/my-namespace/MySchemaCompound-key.avsc
551
574
  - spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
575
+ - spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
552
576
  - spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
553
577
  - spec/schemas/com/my-namespace/MySchemaWithId.avsc
554
578
  - spec/schemas/com/my-namespace/MySchemaWithUniqueId.avsc