deimos-ruby 1.16.1 → 1.16.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +6 -0
- data/README.md +22 -0
- data/lib/deimos/active_record_consume/batch_consumption.rb +7 -2
- data/lib/deimos/active_record_consume/batch_slicer.rb +2 -0
- data/lib/deimos/active_record_consume/message_consumption.rb +8 -4
- data/lib/deimos/active_record_consumer.rb +7 -4
- data/lib/deimos/active_record_producer.rb +10 -0
- data/lib/deimos/backends/base.rb +4 -2
- data/lib/deimos/backends/kafka.rb +1 -0
- data/lib/deimos/backends/kafka_async.rb +1 -0
- data/lib/deimos/config/configuration.rb +4 -0
- data/lib/deimos/config/phobos_config.rb +2 -1
- data/lib/deimos/consume/batch_consumption.rb +8 -1
- data/lib/deimos/consume/message_consumption.rb +4 -1
- data/lib/deimos/instrumentation.rb +11 -4
- data/lib/deimos/kafka_message.rb +1 -0
- data/lib/deimos/kafka_source.rb +5 -0
- data/lib/deimos/kafka_topic_info.rb +4 -0
- data/lib/deimos/message.rb +19 -2
- data/lib/deimos/metrics/datadog.rb +2 -1
- data/lib/deimos/metrics/mock.rb +2 -2
- data/lib/deimos/metrics/provider.rb +6 -0
- data/lib/deimos/monkey_patches/phobos_cli.rb +1 -1
- data/lib/deimos/monkey_patches/phobos_producer.rb +1 -0
- data/lib/deimos/producer.rb +12 -6
- data/lib/deimos/schema_backends/base.rb +31 -17
- data/lib/deimos/schema_backends/mock.rb +2 -2
- data/lib/deimos/schema_class/base.rb +9 -5
- data/lib/deimos/schema_class/enum.rb +4 -2
- data/lib/deimos/schema_class/record.rb +12 -6
- data/lib/deimos/shared_config.rb +6 -2
- data/lib/deimos/test_helpers.rb +21 -4
- data/lib/deimos/tracing/datadog.rb +1 -1
- data/lib/deimos/tracing/mock.rb +4 -3
- data/lib/deimos/tracing/provider.rb +5 -0
- data/lib/deimos/utils/db_poller.rb +9 -1
- data/lib/deimos/utils/db_producer.rb +14 -2
- data/lib/deimos/utils/deadlock_retry.rb +3 -0
- data/lib/deimos/utils/inline_consumer.rb +14 -6
- data/lib/deimos/utils/lag_reporter.rb +11 -0
- data/lib/deimos/utils/schema_controller_mixin.rb +8 -0
- data/lib/deimos/version.rb +1 -1
- data/lib/deimos.rb +3 -2
- data/lib/generators/deimos/active_record_generator.rb +1 -1
- data/lib/generators/deimos/db_backend_generator.rb +1 -0
- data/lib/generators/deimos/db_poller_generator.rb +1 -0
- data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +13 -5
- data/lib/generators/deimos/schema_class_generator.rb +51 -24
- data/rbs_collection.lock.yaml +176 -0
- data/rbs_collection.yaml +15 -0
- data/regenerate_test_schema_classes.rb +68 -0
- data/sig/avro.rbs +14 -0
- data/sig/defs.rbs +1859 -0
- data/sig/fig_tree.rbs +2 -0
- data/spec/active_record_producer_spec.rb +24 -0
- data/spec/generators/schema_class/my_schema_spec.rb +16 -0
- data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +1 -1
- data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +32 -24
- data/spec/producer_spec.rb +11 -11
- data/spec/schemas/{generated.rb → my_namespace/generated.rb} +28 -32
- data/spec/schemas/{my_nested_schema.rb → my_namespace/my_nested_schema.rb} +23 -16
- data/spec/schemas/{my_schema.rb → my_namespace/my_schema.rb} +12 -5
- data/spec/schemas/my_namespace/my_schema_compound_key.rb +41 -0
- data/spec/schemas/my_namespace/my_schema_id_key.rb +36 -0
- data/spec/schemas/{my_schema_key.rb → my_namespace/my_schema_key.rb} +3 -3
- data/spec/schemas/my_namespace/my_schema_with_boolean.rb +41 -0
- data/spec/schemas/{my_schema_with_circular_reference.rb → my_namespace/my_schema_with_circular_reference.rb} +15 -10
- data/spec/schemas/{my_schema_with_complex_type.rb → my_namespace/my_schema_with_complex_type.rb} +34 -49
- data/spec/schemas/my_namespace/my_schema_with_date_time.rb +56 -0
- data/spec/schemas/my_namespace/my_schema_with_id.rb +51 -0
- data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +56 -0
- data/spec/schemas/my_namespace/wibble.rb +76 -0
- data/spec/schemas/my_namespace/widget.rb +56 -0
- data/spec/schemas/my_namespace/widget_the_second.rb +56 -0
- data/spec/schemas/request/create_topic.rb +36 -0
- data/spec/schemas/request/index.rb +36 -0
- data/spec/schemas/request/update_request.rb +36 -0
- data/spec/schemas/response/create_topic.rb +36 -0
- data/spec/schemas/response/index.rb +36 -0
- data/spec/schemas/response/update_response.rb +36 -0
- data/spec/snapshots/consumers-no-nest.snap +93 -86
- data/spec/snapshots/consumers.snap +94 -87
- data/spec/snapshots/consumers_and_producers-no-nest.snap +108 -87
- data/spec/snapshots/consumers_and_producers.snap +109 -88
- data/spec/snapshots/consumers_circular-no-nest.snap +93 -86
- data/spec/snapshots/consumers_circular.snap +94 -87
- data/spec/snapshots/consumers_complex_types-no-nest.snap +93 -86
- data/spec/snapshots/consumers_complex_types.snap +94 -87
- data/spec/snapshots/consumers_nested-no-nest.snap +93 -86
- data/spec/snapshots/consumers_nested.snap +94 -87
- data/spec/snapshots/namespace_folders.snap +111 -90
- data/spec/snapshots/producers_with_key-no-nest.snap +94 -87
- data/spec/snapshots/producers_with_key.snap +95 -88
- data/spec/spec_helper.rb +2 -1
- metadata +53 -15
@@ -8,7 +8,7 @@ module Schemas
|
|
8
8
|
class ARecord < Deimos::SchemaClass::Record
|
9
9
|
|
10
10
|
### Attribute Accessors ###
|
11
|
-
# @
|
11
|
+
# @return [String]
|
12
12
|
attr_accessor :a_record_field
|
13
13
|
|
14
14
|
# @override
|
@@ -85,7 +85,7 @@ module Schemas
|
|
85
85
|
class CreateTopic < Deimos::SchemaClass::Record
|
86
86
|
|
87
87
|
### Attribute Accessors ###
|
88
|
-
# @
|
88
|
+
# @return [String]
|
89
89
|
attr_accessor :response_id
|
90
90
|
|
91
91
|
# @override
|
@@ -130,34 +130,34 @@ module Schemas
|
|
130
130
|
attr_reader :a_record
|
131
131
|
|
132
132
|
### Attribute Accessors ###
|
133
|
-
# @
|
133
|
+
# @return [String]
|
134
134
|
attr_accessor :a_string
|
135
|
-
# @
|
135
|
+
# @return [Integer]
|
136
136
|
attr_accessor :a_int
|
137
|
-
# @
|
137
|
+
# @return [Integer]
|
138
138
|
attr_accessor :a_long
|
139
|
-
# @
|
139
|
+
# @return [Float]
|
140
140
|
attr_accessor :a_float
|
141
|
-
# @
|
141
|
+
# @return [Float]
|
142
142
|
attr_accessor :a_double
|
143
|
-
# @
|
143
|
+
# @return [nil, Integer]
|
144
144
|
attr_accessor :an_optional_int
|
145
|
-
# @
|
145
|
+
# @return [Array<Integer>]
|
146
146
|
attr_accessor :an_array
|
147
|
-
# @
|
147
|
+
# @return [Hash<String, String>]
|
148
148
|
attr_accessor :a_map
|
149
|
-
# @
|
149
|
+
# @return [String]
|
150
150
|
attr_accessor :timestamp
|
151
|
-
# @
|
151
|
+
# @return [String]
|
152
152
|
attr_accessor :message_id
|
153
153
|
|
154
154
|
### Attribute Writers ###
|
155
|
-
# @
|
155
|
+
# @return [AnEnum]
|
156
156
|
def an_enum=(value)
|
157
157
|
@an_enum = AnEnum.initialize_from_value(value)
|
158
158
|
end
|
159
159
|
|
160
|
-
# @
|
160
|
+
# @return [ARecord]
|
161
161
|
def a_record=(value)
|
162
162
|
@a_record = ARecord.initialize_from_value(value)
|
163
163
|
end
|
@@ -231,7 +231,7 @@ module Schemas
|
|
231
231
|
class Index < Deimos::SchemaClass::Record
|
232
232
|
|
233
233
|
### Attribute Accessors ###
|
234
|
-
# @
|
234
|
+
# @return [String]
|
235
235
|
attr_accessor :response_id
|
236
236
|
|
237
237
|
# @override
|
@@ -270,13 +270,13 @@ module Schemas
|
|
270
270
|
class MyNestedRecord < Deimos::SchemaClass::Record
|
271
271
|
|
272
272
|
### Attribute Accessors ###
|
273
|
-
# @
|
273
|
+
# @return [Integer]
|
274
274
|
attr_accessor :some_int
|
275
|
-
# @
|
275
|
+
# @return [Float]
|
276
276
|
attr_accessor :some_float
|
277
|
-
# @
|
277
|
+
# @return [String]
|
278
278
|
attr_accessor :some_string
|
279
|
-
# @
|
279
|
+
# @return [nil, Integer]
|
280
280
|
attr_accessor :some_optional_int
|
281
281
|
|
282
282
|
# @override
|
@@ -330,20 +330,20 @@ module Schemas
|
|
330
330
|
attr_reader :some_optional_record
|
331
331
|
|
332
332
|
### Attribute Accessors ###
|
333
|
-
# @
|
333
|
+
# @return [String]
|
334
334
|
attr_accessor :test_id
|
335
|
-
# @
|
335
|
+
# @return [Float]
|
336
336
|
attr_accessor :test_float
|
337
|
-
# @
|
337
|
+
# @return [Array<String>]
|
338
338
|
attr_accessor :test_array
|
339
339
|
|
340
340
|
### Attribute Writers ###
|
341
|
-
# @
|
341
|
+
# @return [MyNestedRecord]
|
342
342
|
def some_nested_record=(value)
|
343
343
|
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
344
344
|
end
|
345
345
|
|
346
|
-
# @
|
346
|
+
# @return [nil, MyNestedRecord]
|
347
347
|
def some_optional_record=(value)
|
348
348
|
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
349
349
|
end
|
@@ -372,6 +372,13 @@ module Schemas
|
|
372
372
|
'com.my-namespace'
|
373
373
|
end
|
374
374
|
|
375
|
+
def self.tombstone(key)
|
376
|
+
record = self.allocate
|
377
|
+
record.tombstone_key = key
|
378
|
+
record.test_id = key
|
379
|
+
record
|
380
|
+
end
|
381
|
+
|
375
382
|
# @override
|
376
383
|
def as_json(_opts={})
|
377
384
|
{
|
@@ -396,9 +403,9 @@ module Schemas
|
|
396
403
|
class MySchema < Deimos::SchemaClass::Record
|
397
404
|
|
398
405
|
### Attribute Accessors ###
|
399
|
-
# @
|
406
|
+
# @return [String]
|
400
407
|
attr_accessor :test_id
|
401
|
-
# @
|
408
|
+
# @return [Integer]
|
402
409
|
attr_accessor :some_int
|
403
410
|
|
404
411
|
# @override
|
@@ -440,9 +447,9 @@ module Schemas
|
|
440
447
|
class MySchemaCompoundKey < Deimos::SchemaClass::Record
|
441
448
|
|
442
449
|
### Attribute Accessors ###
|
443
|
-
# @
|
450
|
+
# @return [String]
|
444
451
|
attr_accessor :part_one
|
445
|
-
# @
|
452
|
+
# @return [String]
|
446
453
|
attr_accessor :part_two
|
447
454
|
|
448
455
|
# @override
|
@@ -484,7 +491,7 @@ module Schemas
|
|
484
491
|
class MySchemaIdKey < Deimos::SchemaClass::Record
|
485
492
|
|
486
493
|
### Attribute Accessors ###
|
487
|
-
# @
|
494
|
+
# @return [Integer]
|
488
495
|
attr_accessor :id
|
489
496
|
|
490
497
|
# @override
|
@@ -523,7 +530,7 @@ module Schemas
|
|
523
530
|
class MySchemaKey < Deimos::SchemaClass::Record
|
524
531
|
|
525
532
|
### Attribute Accessors ###
|
526
|
-
# @
|
533
|
+
# @return [String]
|
527
534
|
attr_accessor :test_id
|
528
535
|
|
529
536
|
# @override
|
@@ -562,9 +569,9 @@ module Schemas
|
|
562
569
|
class MySchemaWithBoolean < Deimos::SchemaClass::Record
|
563
570
|
|
564
571
|
### Attribute Accessors ###
|
565
|
-
# @
|
572
|
+
# @return [String]
|
566
573
|
attr_accessor :test_id
|
567
|
-
# @
|
574
|
+
# @return [Boolean]
|
568
575
|
attr_accessor :some_bool
|
569
576
|
|
570
577
|
# @override
|
@@ -610,9 +617,9 @@ module Schemas
|
|
610
617
|
attr_reader :properties
|
611
618
|
|
612
619
|
### Attribute Writers ###
|
613
|
-
# @
|
620
|
+
# @return [Hash<String, Property>]
|
614
621
|
def properties=(values)
|
615
|
-
@properties = values
|
622
|
+
@properties = values&.transform_values do |value|
|
616
623
|
Property.initialize_from_value(value)
|
617
624
|
end
|
618
625
|
end
|
@@ -669,57 +676,57 @@ module Schemas
|
|
669
676
|
attr_reader :some_enum_with_default
|
670
677
|
|
671
678
|
### Attribute Accessors ###
|
672
|
-
# @
|
679
|
+
# @return [String]
|
673
680
|
attr_accessor :test_id
|
674
|
-
# @
|
681
|
+
# @return [Float]
|
675
682
|
attr_accessor :test_float
|
676
|
-
# @
|
683
|
+
# @return [Array<String>]
|
677
684
|
attr_accessor :test_string_array
|
678
|
-
# @
|
685
|
+
# @return [Array<Integer>]
|
679
686
|
attr_accessor :test_int_array
|
680
|
-
# @
|
687
|
+
# @return [Integer, nil]
|
681
688
|
attr_accessor :test_optional_int
|
682
|
-
# @
|
689
|
+
# @return [Hash<String, Integer>]
|
683
690
|
attr_accessor :some_integer_map
|
684
691
|
|
685
692
|
### Attribute Writers ###
|
686
|
-
# @
|
693
|
+
# @return [ARecord]
|
687
694
|
def some_record=(value)
|
688
695
|
@some_record = ARecord.initialize_from_value(value)
|
689
696
|
end
|
690
697
|
|
691
|
-
# @
|
698
|
+
# @return [nil, ARecord]
|
692
699
|
def some_optional_record=(value)
|
693
700
|
@some_optional_record = ARecord.initialize_from_value(value)
|
694
701
|
end
|
695
702
|
|
696
|
-
# @
|
703
|
+
# @return [Array<ARecord>]
|
697
704
|
def some_record_array=(values)
|
698
|
-
@some_record_array = values
|
705
|
+
@some_record_array = values&.map do |value|
|
699
706
|
ARecord.initialize_from_value(value)
|
700
707
|
end
|
701
708
|
end
|
702
709
|
|
703
|
-
# @
|
710
|
+
# @return [Hash<String, ARecord>]
|
704
711
|
def some_record_map=(values)
|
705
|
-
@some_record_map = values
|
712
|
+
@some_record_map = values&.transform_values do |value|
|
706
713
|
ARecord.initialize_from_value(value)
|
707
714
|
end
|
708
715
|
end
|
709
716
|
|
710
|
-
# @
|
717
|
+
# @return [Array<AnEnum>]
|
711
718
|
def some_enum_array=(values)
|
712
|
-
@some_enum_array = values
|
719
|
+
@some_enum_array = values&.map do |value|
|
713
720
|
AnEnum.initialize_from_value(value)
|
714
721
|
end
|
715
722
|
end
|
716
723
|
|
717
|
-
# @
|
724
|
+
# @return [nil, AnotherEnum]
|
718
725
|
def some_optional_enum=(value)
|
719
726
|
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
720
727
|
end
|
721
728
|
|
722
|
-
# @
|
729
|
+
# @return [YetAnotherEnum]
|
723
730
|
def some_enum_with_default=(value)
|
724
731
|
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
725
732
|
end
|
@@ -796,15 +803,15 @@ module Schemas
|
|
796
803
|
class MySchemaWithDateTime < Deimos::SchemaClass::Record
|
797
804
|
|
798
805
|
### Attribute Accessors ###
|
799
|
-
# @
|
806
|
+
# @return [String]
|
800
807
|
attr_accessor :test_id
|
801
|
-
# @
|
808
|
+
# @return [Integer, nil]
|
802
809
|
attr_accessor :updated_at
|
803
|
-
# @
|
810
|
+
# @return [nil, Integer]
|
804
811
|
attr_accessor :some_int
|
805
|
-
# @
|
812
|
+
# @return [nil, Integer]
|
806
813
|
attr_accessor :some_datetime_int
|
807
|
-
# @
|
814
|
+
# @return [String]
|
808
815
|
attr_accessor :timestamp
|
809
816
|
|
810
817
|
# @override
|
@@ -855,13 +862,13 @@ module Schemas
|
|
855
862
|
class MySchemaWithId < Deimos::SchemaClass::Record
|
856
863
|
|
857
864
|
### Attribute Accessors ###
|
858
|
-
# @
|
865
|
+
# @return [String]
|
859
866
|
attr_accessor :test_id
|
860
|
-
# @
|
867
|
+
# @return [Integer]
|
861
868
|
attr_accessor :some_int
|
862
|
-
# @
|
869
|
+
# @return [String]
|
863
870
|
attr_accessor :message_id
|
864
|
-
# @
|
871
|
+
# @return [String]
|
865
872
|
attr_accessor :timestamp
|
866
873
|
|
867
874
|
# @override
|
@@ -909,15 +916,15 @@ module Schemas
|
|
909
916
|
class MySchemaWithUniqueId < Deimos::SchemaClass::Record
|
910
917
|
|
911
918
|
### Attribute Accessors ###
|
912
|
-
# @
|
919
|
+
# @return [Integer]
|
913
920
|
attr_accessor :id
|
914
|
-
# @
|
921
|
+
# @return [String]
|
915
922
|
attr_accessor :test_id
|
916
|
-
# @
|
923
|
+
# @return [Integer]
|
917
924
|
attr_accessor :some_int
|
918
|
-
# @
|
925
|
+
# @return [String]
|
919
926
|
attr_accessor :message_id
|
920
|
-
# @
|
927
|
+
# @return [String]
|
921
928
|
attr_accessor :timestamp
|
922
929
|
|
923
930
|
# @override
|
@@ -968,7 +975,7 @@ module Schemas
|
|
968
975
|
class Property < Deimos::SchemaClass::Record
|
969
976
|
|
970
977
|
### Attribute Accessors ###
|
971
|
-
# @
|
978
|
+
# @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
|
972
979
|
attr_accessor :property
|
973
980
|
|
974
981
|
# @override
|
@@ -1007,7 +1014,7 @@ module Schemas
|
|
1007
1014
|
class UpdateRequest < Deimos::SchemaClass::Record
|
1008
1015
|
|
1009
1016
|
### Attribute Accessors ###
|
1010
|
-
# @
|
1017
|
+
# @return [String]
|
1011
1018
|
attr_accessor :update_request_id
|
1012
1019
|
|
1013
1020
|
# @override
|
@@ -1046,7 +1053,7 @@ module Schemas
|
|
1046
1053
|
class UpdateResponse < Deimos::SchemaClass::Record
|
1047
1054
|
|
1048
1055
|
### Attribute Accessors ###
|
1049
|
-
# @
|
1056
|
+
# @return [String]
|
1050
1057
|
attr_accessor :update_response_id
|
1051
1058
|
|
1052
1059
|
# @override
|
@@ -1085,23 +1092,23 @@ module Schemas
|
|
1085
1092
|
class Wibble < Deimos::SchemaClass::Record
|
1086
1093
|
|
1087
1094
|
### Attribute Accessors ###
|
1088
|
-
# @
|
1095
|
+
# @return [Integer]
|
1089
1096
|
attr_accessor :id
|
1090
|
-
# @
|
1097
|
+
# @return [Integer]
|
1091
1098
|
attr_accessor :wibble_id
|
1092
|
-
# @
|
1099
|
+
# @return [String]
|
1093
1100
|
attr_accessor :name
|
1094
|
-
# @
|
1101
|
+
# @return [String]
|
1095
1102
|
attr_accessor :floop
|
1096
|
-
# @
|
1103
|
+
# @return [Integer]
|
1097
1104
|
attr_accessor :birthday_int
|
1098
|
-
# @
|
1105
|
+
# @return [Integer]
|
1099
1106
|
attr_accessor :birthday_long
|
1100
|
-
# @
|
1107
|
+
# @return [nil, Integer]
|
1101
1108
|
attr_accessor :birthday_optional
|
1102
|
-
# @
|
1109
|
+
# @return [Integer]
|
1103
1110
|
attr_accessor :updated_at
|
1104
|
-
# @
|
1111
|
+
# @return [Integer]
|
1105
1112
|
attr_accessor :created_at
|
1106
1113
|
|
1107
1114
|
# @override
|
@@ -1164,15 +1171,15 @@ module Schemas
|
|
1164
1171
|
class Widget < Deimos::SchemaClass::Record
|
1165
1172
|
|
1166
1173
|
### Attribute Accessors ###
|
1167
|
-
# @
|
1174
|
+
# @return [Integer]
|
1168
1175
|
attr_accessor :id
|
1169
|
-
# @
|
1176
|
+
# @return [Integer]
|
1170
1177
|
attr_accessor :widget_id
|
1171
|
-
# @
|
1178
|
+
# @return [String]
|
1172
1179
|
attr_accessor :name
|
1173
|
-
# @
|
1180
|
+
# @return [Integer]
|
1174
1181
|
attr_accessor :updated_at
|
1175
|
-
# @
|
1182
|
+
# @return [Integer]
|
1176
1183
|
attr_accessor :created_at
|
1177
1184
|
|
1178
1185
|
# @override
|
@@ -1223,15 +1230,15 @@ module Schemas
|
|
1223
1230
|
class WidgetTheSecond < Deimos::SchemaClass::Record
|
1224
1231
|
|
1225
1232
|
### Attribute Accessors ###
|
1226
|
-
# @
|
1233
|
+
# @return [Integer]
|
1227
1234
|
attr_accessor :id
|
1228
|
-
# @
|
1235
|
+
# @return [Integer]
|
1229
1236
|
attr_accessor :widget_id
|
1230
|
-
# @
|
1237
|
+
# @return [String]
|
1231
1238
|
attr_accessor :model_id
|
1232
|
-
# @
|
1239
|
+
# @return [Integer]
|
1233
1240
|
attr_accessor :updated_at
|
1234
|
-
# @
|
1241
|
+
# @return [Integer]
|
1235
1242
|
attr_accessor :created_at
|
1236
1243
|
|
1237
1244
|
# @override
|