deimos-ruby 2.0.17 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -0
- data/karafka.rb +1 -0
- data/lib/deimos/schema_class/enum.rb +1 -1
- data/lib/deimos/schema_class/record.rb +21 -3
- data/lib/deimos/test_helpers.rb +18 -6
- data/lib/deimos/utils/schema_class.rb +1 -1
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +3 -2
- data/lib/generators/deimos/schema_class_generator.rb +3 -3
- data/spec/batch_consumer_spec.rb +14 -12
- data/spec/consumer_spec.rb +51 -5
- data/spec/schemas/my_namespace/generated.rb +2 -2
- data/spec/schemas/my_namespace/my_nested_schema.rb +2 -2
- data/spec/schemas/my_namespace/my_schema.rb +2 -2
- data/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +1 -1
- data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +9 -9
- data/spec/schemas/my_namespace/my_schema_with_union_type.rb +38 -23
- data/spec/snapshots/consumers-no-nest.snap +16 -15
- data/spec/snapshots/consumers.snap +16 -15
- data/spec/snapshots/consumers_and_producers-no-nest.snap +18 -17
- data/spec/snapshots/consumers_and_producers.snap +18 -17
- data/spec/snapshots/consumers_circular-no-nest.snap +16 -15
- data/spec/snapshots/consumers_circular.snap +16 -15
- data/spec/snapshots/consumers_complex_types-no-nest.snap +16 -15
- data/spec/snapshots/consumers_complex_types.snap +16 -15
- data/spec/snapshots/consumers_nested-no-nest.snap +16 -15
- data/spec/snapshots/consumers_nested.snap +16 -15
- data/spec/snapshots/namespace_folders.snap +18 -17
- data/spec/snapshots/namespace_map.snap +18 -17
- data/spec/snapshots/producers_with_key-no-nest.snap +18 -17
- data/spec/snapshots/producers_with_key.snap +18 -17
- data/spec/spec_helper.rb +1 -1
- metadata +3 -2
@@ -121,12 +121,12 @@ module Schemas
|
|
121
121
|
### Attribute Writers ###
|
122
122
|
# @return [AnEnum]
|
123
123
|
def an_enum=(value)
|
124
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
124
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
|
125
125
|
end
|
126
126
|
|
127
127
|
# @return [ARecord]
|
128
128
|
def a_record=(value)
|
129
|
-
@a_record = ARecord.initialize_from_value(value)
|
129
|
+
@a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
130
130
|
end
|
131
131
|
|
132
132
|
# @override
|
@@ -345,12 +345,12 @@ module Schemas
|
|
345
345
|
### Attribute Writers ###
|
346
346
|
# @return [MyNestedRecord]
|
347
347
|
def some_nested_record=(value)
|
348
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
348
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
349
349
|
end
|
350
350
|
|
351
351
|
# @return [nil, MyNestedRecord]
|
352
352
|
def some_optional_record=(value)
|
353
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
353
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
354
354
|
end
|
355
355
|
|
356
356
|
# @override
|
@@ -658,7 +658,7 @@ module Schemas
|
|
658
658
|
# @return [Hash<String, Property>]
|
659
659
|
def properties=(values)
|
660
660
|
@properties = values&.transform_values do |value|
|
661
|
-
Property.initialize_from_value(value)
|
661
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
662
662
|
end
|
663
663
|
end
|
664
664
|
|
@@ -796,43 +796,43 @@ module Schemas
|
|
796
796
|
### Attribute Writers ###
|
797
797
|
# @return [ARecord]
|
798
798
|
def some_record=(value)
|
799
|
-
@some_record = ARecord.initialize_from_value(value)
|
799
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
800
800
|
end
|
801
801
|
|
802
802
|
# @return [nil, ARecord]
|
803
803
|
def some_optional_record=(value)
|
804
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
804
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
805
805
|
end
|
806
806
|
|
807
807
|
# @return [Array<ARecord>]
|
808
808
|
def some_record_array=(values)
|
809
809
|
@some_record_array = values&.map do |value|
|
810
|
-
ARecord.initialize_from_value(value)
|
810
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
811
811
|
end
|
812
812
|
end
|
813
813
|
|
814
814
|
# @return [Hash<String, ARecord>]
|
815
815
|
def some_record_map=(values)
|
816
816
|
@some_record_map = values&.transform_values do |value|
|
817
|
-
ARecord.initialize_from_value(value)
|
817
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
818
818
|
end
|
819
819
|
end
|
820
820
|
|
821
821
|
# @return [Array<AnEnum>]
|
822
822
|
def some_enum_array=(values)
|
823
823
|
@some_enum_array = values&.map do |value|
|
824
|
-
AnEnum.initialize_from_value(value)
|
824
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
825
825
|
end
|
826
826
|
end
|
827
827
|
|
828
828
|
# @return [nil, AnotherEnum]
|
829
829
|
def some_optional_enum=(value)
|
830
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
830
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
831
831
|
end
|
832
832
|
|
833
833
|
# @return [YetAnotherEnum]
|
834
834
|
def some_enum_with_default=(value)
|
835
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
835
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
836
836
|
end
|
837
837
|
|
838
838
|
# @override
|
@@ -1212,13 +1212,14 @@ module Schemas
|
|
1212
1212
|
### Attribute Writers ###
|
1213
1213
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1214
1214
|
def test_union_type=(value)
|
1215
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1215
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
|
1216
1216
|
end
|
1217
1217
|
|
1218
1218
|
# Helper method to determine which schema type to use for test_union_type
|
1219
1219
|
# @param value [Hash, nil]
|
1220
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1220
1221
|
# @return [Object, nil]
|
1221
|
-
def initialize_test_union_type_type(value)
|
1222
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1222
1223
|
return nil if value.nil?
|
1223
1224
|
|
1224
1225
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1226,7 +1227,7 @@ module Schemas
|
|
1226
1227
|
(value.keys - fields).empty?
|
1227
1228
|
end
|
1228
1229
|
|
1229
|
-
klass.initialize_from_value(value)
|
1230
|
+
klass.initialize_from_value(value, from_message: self._from_message)
|
1230
1231
|
end
|
1231
1232
|
|
1232
1233
|
# @override
|
@@ -82,12 +82,12 @@ module Schemas; module Com; module MyNamespace
|
|
82
82
|
### Attribute Writers ###
|
83
83
|
# @return [AnEnum]
|
84
84
|
def an_enum=(value)
|
85
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
85
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
|
86
86
|
end
|
87
87
|
|
88
88
|
# @return [ARecord]
|
89
89
|
def a_record=(value)
|
90
|
-
@a_record = ARecord.initialize_from_value(value)
|
90
|
+
@a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
91
91
|
end
|
92
92
|
|
93
93
|
# @override
|
@@ -230,12 +230,12 @@ module Schemas; module Com; module MyNamespace
|
|
230
230
|
### Attribute Writers ###
|
231
231
|
# @return [MyNestedRecord]
|
232
232
|
def some_nested_record=(value)
|
233
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
233
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
234
234
|
end
|
235
235
|
|
236
236
|
# @return [nil, MyNestedRecord]
|
237
237
|
def some_optional_record=(value)
|
238
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
238
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
239
239
|
end
|
240
240
|
|
241
241
|
# @override
|
@@ -305,7 +305,7 @@ module Schemas; module Com; module MyNamespace
|
|
305
305
|
### Attribute Writers ###
|
306
306
|
# @return [MySchemaKey]
|
307
307
|
def payload_key=(value)
|
308
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
308
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
|
309
309
|
end
|
310
310
|
|
311
311
|
# @override
|
@@ -330,7 +330,7 @@ module Schemas; module Com; module MyNamespace
|
|
330
330
|
|
331
331
|
def self.tombstone(key)
|
332
332
|
record = self.allocate
|
333
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
333
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
|
334
334
|
record.payload_key = key
|
335
335
|
record
|
336
336
|
end
|
@@ -563,7 +563,7 @@ module Schemas; module Com; module MyNamespace
|
|
563
563
|
# @return [Hash<String, Property>]
|
564
564
|
def properties=(values)
|
565
565
|
@properties = values&.transform_values do |value|
|
566
|
-
Property.initialize_from_value(value)
|
566
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
567
567
|
end
|
568
568
|
end
|
569
569
|
|
@@ -701,43 +701,43 @@ module Schemas; module Com; module MyNamespace
|
|
701
701
|
### Attribute Writers ###
|
702
702
|
# @return [ARecord]
|
703
703
|
def some_record=(value)
|
704
|
-
@some_record = ARecord.initialize_from_value(value)
|
704
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
705
705
|
end
|
706
706
|
|
707
707
|
# @return [nil, ARecord]
|
708
708
|
def some_optional_record=(value)
|
709
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
709
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
710
710
|
end
|
711
711
|
|
712
712
|
# @return [Array<ARecord>]
|
713
713
|
def some_record_array=(values)
|
714
714
|
@some_record_array = values&.map do |value|
|
715
|
-
ARecord.initialize_from_value(value)
|
715
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
716
716
|
end
|
717
717
|
end
|
718
718
|
|
719
719
|
# @return [Hash<String, ARecord>]
|
720
720
|
def some_record_map=(values)
|
721
721
|
@some_record_map = values&.transform_values do |value|
|
722
|
-
ARecord.initialize_from_value(value)
|
722
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
723
723
|
end
|
724
724
|
end
|
725
725
|
|
726
726
|
# @return [Array<AnEnum>]
|
727
727
|
def some_enum_array=(values)
|
728
728
|
@some_enum_array = values&.map do |value|
|
729
|
-
AnEnum.initialize_from_value(value)
|
729
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
730
730
|
end
|
731
731
|
end
|
732
732
|
|
733
733
|
# @return [nil, AnotherEnum]
|
734
734
|
def some_optional_enum=(value)
|
735
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
735
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
736
736
|
end
|
737
737
|
|
738
738
|
# @return [YetAnotherEnum]
|
739
739
|
def some_enum_with_default=(value)
|
740
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
740
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
741
741
|
end
|
742
742
|
|
743
743
|
# @override
|
@@ -1117,13 +1117,14 @@ module Schemas; module Com; module MyNamespace
|
|
1117
1117
|
### Attribute Writers ###
|
1118
1118
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1119
1119
|
def test_union_type=(value)
|
1120
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1120
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
|
1121
1121
|
end
|
1122
1122
|
|
1123
1123
|
# Helper method to determine which schema type to use for test_union_type
|
1124
1124
|
# @param value [Hash, nil]
|
1125
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1125
1126
|
# @return [Object, nil]
|
1126
|
-
def initialize_test_union_type_type(value)
|
1127
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1127
1128
|
return nil if value.nil?
|
1128
1129
|
|
1129
1130
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1131,7 +1132,7 @@ module Schemas; module Com; module MyNamespace
|
|
1131
1132
|
(value.keys - fields).empty?
|
1132
1133
|
end
|
1133
1134
|
|
1134
|
-
klass.initialize_from_value(value)
|
1135
|
+
klass.initialize_from_value(value, from_message: self._from_message)
|
1135
1136
|
end
|
1136
1137
|
|
1137
1138
|
# @override
|
@@ -82,12 +82,12 @@ module Schemas; module MyNamespace
|
|
82
82
|
### Attribute Writers ###
|
83
83
|
# @return [AnEnum]
|
84
84
|
def an_enum=(value)
|
85
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
85
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
|
86
86
|
end
|
87
87
|
|
88
88
|
# @return [ARecord]
|
89
89
|
def a_record=(value)
|
90
|
-
@a_record = ARecord.initialize_from_value(value)
|
90
|
+
@a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
91
91
|
end
|
92
92
|
|
93
93
|
# @override
|
@@ -274,12 +274,12 @@ module Schemas; module MyNamespace
|
|
274
274
|
### Attribute Writers ###
|
275
275
|
# @return [MyNestedRecord]
|
276
276
|
def some_nested_record=(value)
|
277
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
277
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
278
278
|
end
|
279
279
|
|
280
280
|
# @return [nil, MyNestedRecord]
|
281
281
|
def some_optional_record=(value)
|
282
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
282
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
283
283
|
end
|
284
284
|
|
285
285
|
# @override
|
@@ -349,7 +349,7 @@ module Schemas; module MyNamespace
|
|
349
349
|
### Attribute Writers ###
|
350
350
|
# @return [MySchemaKey]
|
351
351
|
def payload_key=(value)
|
352
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
352
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
|
353
353
|
end
|
354
354
|
|
355
355
|
# @override
|
@@ -374,7 +374,7 @@ module Schemas; module MyNamespace
|
|
374
374
|
|
375
375
|
def self.tombstone(key)
|
376
376
|
record = self.allocate
|
377
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
377
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
|
378
378
|
record.payload_key = key
|
379
379
|
record
|
380
380
|
end
|
@@ -607,7 +607,7 @@ module Schemas; module MyNamespace
|
|
607
607
|
# @return [Hash<String, Property>]
|
608
608
|
def properties=(values)
|
609
609
|
@properties = values&.transform_values do |value|
|
610
|
-
Property.initialize_from_value(value)
|
610
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
611
611
|
end
|
612
612
|
end
|
613
613
|
|
@@ -745,43 +745,43 @@ module Schemas; module MyNamespace
|
|
745
745
|
### Attribute Writers ###
|
746
746
|
# @return [ARecord]
|
747
747
|
def some_record=(value)
|
748
|
-
@some_record = ARecord.initialize_from_value(value)
|
748
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
749
749
|
end
|
750
750
|
|
751
751
|
# @return [nil, ARecord]
|
752
752
|
def some_optional_record=(value)
|
753
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
753
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
754
754
|
end
|
755
755
|
|
756
756
|
# @return [Array<ARecord>]
|
757
757
|
def some_record_array=(values)
|
758
758
|
@some_record_array = values&.map do |value|
|
759
|
-
ARecord.initialize_from_value(value)
|
759
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
760
760
|
end
|
761
761
|
end
|
762
762
|
|
763
763
|
# @return [Hash<String, ARecord>]
|
764
764
|
def some_record_map=(values)
|
765
765
|
@some_record_map = values&.transform_values do |value|
|
766
|
-
ARecord.initialize_from_value(value)
|
766
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
767
767
|
end
|
768
768
|
end
|
769
769
|
|
770
770
|
# @return [Array<AnEnum>]
|
771
771
|
def some_enum_array=(values)
|
772
772
|
@some_enum_array = values&.map do |value|
|
773
|
-
AnEnum.initialize_from_value(value)
|
773
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
774
774
|
end
|
775
775
|
end
|
776
776
|
|
777
777
|
# @return [nil, AnotherEnum]
|
778
778
|
def some_optional_enum=(value)
|
779
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
779
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
780
780
|
end
|
781
781
|
|
782
782
|
# @return [YetAnotherEnum]
|
783
783
|
def some_enum_with_default=(value)
|
784
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
784
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
785
785
|
end
|
786
786
|
|
787
787
|
# @override
|
@@ -1161,13 +1161,14 @@ module Schemas; module MyNamespace
|
|
1161
1161
|
### Attribute Writers ###
|
1162
1162
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1163
1163
|
def test_union_type=(value)
|
1164
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1164
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
|
1165
1165
|
end
|
1166
1166
|
|
1167
1167
|
# Helper method to determine which schema type to use for test_union_type
|
1168
1168
|
# @param value [Hash, nil]
|
1169
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1169
1170
|
# @return [Object, nil]
|
1170
|
-
def initialize_test_union_type_type(value)
|
1171
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1171
1172
|
return nil if value.nil?
|
1172
1173
|
|
1173
1174
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1175,7 +1176,7 @@ module Schemas; module MyNamespace
|
|
1175
1176
|
(value.keys - fields).empty?
|
1176
1177
|
end
|
1177
1178
|
|
1178
|
-
klass.initialize_from_value(value)
|
1179
|
+
klass.initialize_from_value(value, from_message: self._from_message)
|
1179
1180
|
end
|
1180
1181
|
|
1181
1182
|
# @override
|
@@ -154,12 +154,12 @@ module Schemas
|
|
154
154
|
### Attribute Writers ###
|
155
155
|
# @return [AnEnum]
|
156
156
|
def an_enum=(value)
|
157
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
157
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
|
158
158
|
end
|
159
159
|
|
160
160
|
# @return [ARecord]
|
161
161
|
def a_record=(value)
|
162
|
-
@a_record = ARecord.initialize_from_value(value)
|
162
|
+
@a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
163
163
|
end
|
164
164
|
|
165
165
|
# @override
|
@@ -384,12 +384,12 @@ module Schemas
|
|
384
384
|
### Attribute Writers ###
|
385
385
|
# @return [MyNestedRecord]
|
386
386
|
def some_nested_record=(value)
|
387
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
387
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
388
388
|
end
|
389
389
|
|
390
390
|
# @return [nil, MyNestedRecord]
|
391
391
|
def some_optional_record=(value)
|
392
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
392
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
393
393
|
end
|
394
394
|
|
395
395
|
# @override
|
@@ -452,7 +452,7 @@ module Schemas
|
|
452
452
|
### Attribute Writers ###
|
453
453
|
# @return [MySchemaKey]
|
454
454
|
def payload_key=(value)
|
455
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
455
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
|
456
456
|
end
|
457
457
|
|
458
458
|
# @override
|
@@ -477,7 +477,7 @@ module Schemas
|
|
477
477
|
|
478
478
|
def self.tombstone(key)
|
479
479
|
record = self.allocate
|
480
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
480
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
|
481
481
|
record.payload_key = key
|
482
482
|
record
|
483
483
|
end
|
@@ -677,7 +677,7 @@ module Schemas
|
|
677
677
|
# @return [Hash<String, Property>]
|
678
678
|
def properties=(values)
|
679
679
|
@properties = values&.transform_values do |value|
|
680
|
-
Property.initialize_from_value(value)
|
680
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
681
681
|
end
|
682
682
|
end
|
683
683
|
|
@@ -749,43 +749,43 @@ module Schemas
|
|
749
749
|
### Attribute Writers ###
|
750
750
|
# @return [ARecord]
|
751
751
|
def some_record=(value)
|
752
|
-
@some_record = ARecord.initialize_from_value(value)
|
752
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
753
753
|
end
|
754
754
|
|
755
755
|
# @return [nil, ARecord]
|
756
756
|
def some_optional_record=(value)
|
757
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
757
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
758
758
|
end
|
759
759
|
|
760
760
|
# @return [Array<ARecord>]
|
761
761
|
def some_record_array=(values)
|
762
762
|
@some_record_array = values&.map do |value|
|
763
|
-
ARecord.initialize_from_value(value)
|
763
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
764
764
|
end
|
765
765
|
end
|
766
766
|
|
767
767
|
# @return [Hash<String, ARecord>]
|
768
768
|
def some_record_map=(values)
|
769
769
|
@some_record_map = values&.transform_values do |value|
|
770
|
-
ARecord.initialize_from_value(value)
|
770
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
771
771
|
end
|
772
772
|
end
|
773
773
|
|
774
774
|
# @return [Array<AnEnum>]
|
775
775
|
def some_enum_array=(values)
|
776
776
|
@some_enum_array = values&.map do |value|
|
777
|
-
AnEnum.initialize_from_value(value)
|
777
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
778
778
|
end
|
779
779
|
end
|
780
780
|
|
781
781
|
# @return [nil, AnotherEnum]
|
782
782
|
def some_optional_enum=(value)
|
783
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
783
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
784
784
|
end
|
785
785
|
|
786
786
|
# @return [YetAnotherEnum]
|
787
787
|
def some_enum_with_default=(value)
|
788
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
788
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
789
789
|
end
|
790
790
|
|
791
791
|
# @override
|
@@ -1034,13 +1034,14 @@ module Schemas
|
|
1034
1034
|
### Attribute Writers ###
|
1035
1035
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1036
1036
|
def test_union_type=(value)
|
1037
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1037
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
|
1038
1038
|
end
|
1039
1039
|
|
1040
1040
|
# Helper method to determine which schema type to use for test_union_type
|
1041
1041
|
# @param value [Hash, nil]
|
1042
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1042
1043
|
# @return [Object, nil]
|
1043
|
-
def initialize_test_union_type_type(value)
|
1044
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1044
1045
|
return nil if value.nil?
|
1045
1046
|
|
1046
1047
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1048,7 +1049,7 @@ module Schemas
|
|
1048
1049
|
(value.keys - fields).empty?
|
1049
1050
|
end
|
1050
1051
|
|
1051
|
-
klass.initialize_from_value(value)
|
1052
|
+
klass.initialize_from_value(value, from_message: self._from_message)
|
1052
1053
|
end
|
1053
1054
|
|
1054
1055
|
# @override
|
@@ -121,12 +121,12 @@ module Schemas
|
|
121
121
|
### Attribute Writers ###
|
122
122
|
# @return [AnEnum]
|
123
123
|
def an_enum=(value)
|
124
|
-
@an_enum = AnEnum.initialize_from_value(value)
|
124
|
+
@an_enum = AnEnum.initialize_from_value(value, from_message: self._from_message)
|
125
125
|
end
|
126
126
|
|
127
127
|
# @return [ARecord]
|
128
128
|
def a_record=(value)
|
129
|
-
@a_record = ARecord.initialize_from_value(value)
|
129
|
+
@a_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
130
130
|
end
|
131
131
|
|
132
132
|
# @override
|
@@ -345,12 +345,12 @@ module Schemas
|
|
345
345
|
### Attribute Writers ###
|
346
346
|
# @return [MyNestedRecord]
|
347
347
|
def some_nested_record=(value)
|
348
|
-
@some_nested_record = MyNestedRecord.initialize_from_value(value)
|
348
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
349
349
|
end
|
350
350
|
|
351
351
|
# @return [nil, MyNestedRecord]
|
352
352
|
def some_optional_record=(value)
|
353
|
-
@some_optional_record = MyNestedRecord.initialize_from_value(value)
|
353
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
354
354
|
end
|
355
355
|
|
356
356
|
# @override
|
@@ -413,7 +413,7 @@ module Schemas
|
|
413
413
|
### Attribute Writers ###
|
414
414
|
# @return [MySchemaKey]
|
415
415
|
def payload_key=(value)
|
416
|
-
@payload_key = MySchemaKey.initialize_from_value(value)
|
416
|
+
@payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
|
417
417
|
end
|
418
418
|
|
419
419
|
# @override
|
@@ -438,7 +438,7 @@ module Schemas
|
|
438
438
|
|
439
439
|
def self.tombstone(key)
|
440
440
|
record = self.allocate
|
441
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key)
|
441
|
+
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
|
442
442
|
record.payload_key = key
|
443
443
|
record
|
444
444
|
end
|
@@ -671,7 +671,7 @@ module Schemas
|
|
671
671
|
# @return [Hash<String, Property>]
|
672
672
|
def properties=(values)
|
673
673
|
@properties = values&.transform_values do |value|
|
674
|
-
Property.initialize_from_value(value)
|
674
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
675
675
|
end
|
676
676
|
end
|
677
677
|
|
@@ -809,43 +809,43 @@ module Schemas
|
|
809
809
|
### Attribute Writers ###
|
810
810
|
# @return [ARecord]
|
811
811
|
def some_record=(value)
|
812
|
-
@some_record = ARecord.initialize_from_value(value)
|
812
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
813
813
|
end
|
814
814
|
|
815
815
|
# @return [nil, ARecord]
|
816
816
|
def some_optional_record=(value)
|
817
|
-
@some_optional_record = ARecord.initialize_from_value(value)
|
817
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
818
818
|
end
|
819
819
|
|
820
820
|
# @return [Array<ARecord>]
|
821
821
|
def some_record_array=(values)
|
822
822
|
@some_record_array = values&.map do |value|
|
823
|
-
ARecord.initialize_from_value(value)
|
823
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
824
824
|
end
|
825
825
|
end
|
826
826
|
|
827
827
|
# @return [Hash<String, ARecord>]
|
828
828
|
def some_record_map=(values)
|
829
829
|
@some_record_map = values&.transform_values do |value|
|
830
|
-
ARecord.initialize_from_value(value)
|
830
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
831
831
|
end
|
832
832
|
end
|
833
833
|
|
834
834
|
# @return [Array<AnEnum>]
|
835
835
|
def some_enum_array=(values)
|
836
836
|
@some_enum_array = values&.map do |value|
|
837
|
-
AnEnum.initialize_from_value(value)
|
837
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
838
838
|
end
|
839
839
|
end
|
840
840
|
|
841
841
|
# @return [nil, AnotherEnum]
|
842
842
|
def some_optional_enum=(value)
|
843
|
-
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
843
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
844
844
|
end
|
845
845
|
|
846
846
|
# @return [YetAnotherEnum]
|
847
847
|
def some_enum_with_default=(value)
|
848
|
-
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
848
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
849
849
|
end
|
850
850
|
|
851
851
|
# @override
|
@@ -1225,13 +1225,14 @@ module Schemas
|
|
1225
1225
|
### Attribute Writers ###
|
1226
1226
|
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
1227
1227
|
def test_union_type=(value)
|
1228
|
-
@test_union_type = initialize_test_union_type_type(value)
|
1228
|
+
@test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
|
1229
1229
|
end
|
1230
1230
|
|
1231
1231
|
# Helper method to determine which schema type to use for test_union_type
|
1232
1232
|
# @param value [Hash, nil]
|
1233
|
+
# @param from_message [Boolean] whether this was initialized from a real Avro message
|
1233
1234
|
# @return [Object, nil]
|
1234
|
-
def initialize_test_union_type_type(value)
|
1235
|
+
def initialize_test_union_type_type(value, from_message: false)
|
1235
1236
|
return nil if value.nil?
|
1236
1237
|
|
1237
1238
|
klass = [Record1, Record2, Record3, Record4].find do |candidate|
|
@@ -1239,7 +1240,7 @@ module Schemas
|
|
1239
1240
|
(value.keys - fields).empty?
|
1240
1241
|
end
|
1241
1242
|
|
1242
|
-
klass.initialize_from_value(value)
|
1243
|
+
klass.initialize_from_value(value, from_message: self._from_message)
|
1243
1244
|
end
|
1244
1245
|
|
1245
1246
|
# @override
|
data/spec/spec_helper.rb
CHANGED
@@ -223,11 +223,11 @@ RSpec.configure do |config|
|
|
223
223
|
|
224
224
|
config.before(:each) do
|
225
225
|
Deimos.config.reset!
|
226
|
+
set_karafka_config(:reraise_errors, true)
|
226
227
|
Deimos.configure do |deimos_config|
|
227
228
|
deimos_config.producers.backend = :kafka
|
228
229
|
deimos_config.schema.nest_child_schemas = true
|
229
230
|
deimos_config.schema.path = File.join(File.expand_path(__dir__), 'schemas')
|
230
|
-
deimos_config.consumers.reraise_errors = true
|
231
231
|
deimos_config.schema.registry_url = ENV['SCHEMA_REGISTRY'] || 'http://localhost:8081'
|
232
232
|
deimos_config.logger = Logger.new('/dev/null')
|
233
233
|
deimos_config.logger.level = Logger::INFO
|
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: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|
@@ -436,6 +436,7 @@ files:
|
|
436
436
|
- docs/INTEGRATION_TESTS.md
|
437
437
|
- docs/PULL_REQUEST_TEMPLATE.md
|
438
438
|
- docs/UPGRADING.md
|
439
|
+
- karafka.rb
|
439
440
|
- lib/deimos.rb
|
440
441
|
- lib/deimos/active_record_consume/batch_consumption.rb
|
441
442
|
- lib/deimos/active_record_consume/batch_record.rb
|