deimos-ruby 2.1.2 → 2.1.4
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 +6 -0
- data/karafka.rb +71 -1
- data/lib/deimos/schema_backends/avro_schema_coercer.rb +2 -0
- data/lib/deimos/schema_class/record.rb +2 -2
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/schema_class/templates/schema_enum.rb.tt +6 -3
- data/lib/generators/deimos/schema_class_generator.rb +10 -14
- data/regenerate_test_schema_classes.rb +0 -66
- data/spec/schemas/my_namespace/my_schema.rb +1 -1
- data/spec/schemas/my_namespace/my_updated_schema.rb +2 -1
- data/spec/snapshots/consumers-no-nest.snap +95 -45
- data/spec/snapshots/consumers.snap +107 -49
- data/spec/snapshots/consumers_and_producers-no-nest.snap +90 -67
- data/spec/snapshots/consumers_and_producers.snap +102 -71
- data/spec/snapshots/consumers_circular-no-nest.snap +95 -45
- data/spec/snapshots/consumers_circular.snap +107 -49
- data/spec/snapshots/consumers_complex_types-no-nest.snap +95 -45
- data/spec/snapshots/consumers_complex_types.snap +107 -49
- data/spec/snapshots/consumers_nested-no-nest.snap +88 -38
- data/spec/snapshots/consumers_nested.snap +100 -42
- data/spec/snapshots/namespace_folders.snap +106 -73
- data/spec/snapshots/namespace_map.snap +106 -73
- data/spec/snapshots/producers_with_key-no-nest.snap +97 -60
- data/spec/snapshots/producers_with_key.snap +109 -64
- metadata +2 -2
@@ -12,7 +12,8 @@ module Schemas
|
|
12
12
|
attr_accessor :response_id
|
13
13
|
|
14
14
|
# @override
|
15
|
-
def initialize(response_id: nil)
|
15
|
+
def initialize(_from_message: false, response_id: nil)
|
16
|
+
@_from_message = _from_message
|
16
17
|
super
|
17
18
|
self.response_id = response_id
|
18
19
|
end
|
@@ -55,7 +56,8 @@ module Schemas
|
|
55
56
|
attr_accessor :a_record_field
|
56
57
|
|
57
58
|
# @override
|
58
|
-
def initialize(a_record_field: nil)
|
59
|
+
def initialize(_from_message: false, a_record_field: nil)
|
60
|
+
@_from_message = _from_message
|
59
61
|
super
|
60
62
|
self.a_record_field = a_record_field
|
61
63
|
end
|
@@ -80,13 +82,20 @@ module Schemas
|
|
80
82
|
|
81
83
|
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
82
84
|
class AnEnum < Deimos::SchemaClass::Enum
|
83
|
-
# @return ['sym1', 'sym2']
|
84
|
-
attr_accessor :an_enum
|
85
|
-
|
86
85
|
# @override
|
87
86
|
def symbols
|
88
87
|
%w(sym1 sym2)
|
89
88
|
end
|
89
|
+
|
90
|
+
|
91
|
+
def sym1?
|
92
|
+
@value == 'sym1'
|
93
|
+
end
|
94
|
+
|
95
|
+
def sym2?
|
96
|
+
@value == 'sym2'
|
97
|
+
end
|
98
|
+
|
90
99
|
end
|
91
100
|
|
92
101
|
|
@@ -130,7 +139,7 @@ module Schemas
|
|
130
139
|
end
|
131
140
|
|
132
141
|
# @override
|
133
|
-
def initialize(a_string: nil,
|
142
|
+
def initialize(_from_message: false, a_string: nil,
|
134
143
|
a_int: nil,
|
135
144
|
a_long: nil,
|
136
145
|
a_float: nil,
|
@@ -142,6 +151,7 @@ module Schemas
|
|
142
151
|
timestamp: nil,
|
143
152
|
message_id: nil,
|
144
153
|
a_record: nil)
|
154
|
+
@_from_message = _from_message
|
145
155
|
super
|
146
156
|
self.a_string = a_string
|
147
157
|
self.a_int = a_int
|
@@ -167,13 +177,6 @@ module Schemas
|
|
167
177
|
'com.my-namespace'
|
168
178
|
end
|
169
179
|
|
170
|
-
def self.tombstone(key)
|
171
|
-
record = self.allocate
|
172
|
-
record.tombstone_key = key
|
173
|
-
record.a_string = key
|
174
|
-
record
|
175
|
-
end
|
176
|
-
|
177
180
|
# @override
|
178
181
|
def as_json(_opts={})
|
179
182
|
{
|
@@ -209,7 +212,8 @@ module Schemas
|
|
209
212
|
attr_accessor :response_id
|
210
213
|
|
211
214
|
# @override
|
212
|
-
def initialize(response_id: nil)
|
215
|
+
def initialize(_from_message: false, response_id: nil)
|
216
|
+
@_from_message = _from_message
|
213
217
|
super
|
214
218
|
self.response_id = response_id
|
215
219
|
end
|
@@ -250,8 +254,9 @@ module Schemas
|
|
250
254
|
attr_accessor :some_int
|
251
255
|
|
252
256
|
# @override
|
253
|
-
def initialize(test_id: nil,
|
257
|
+
def initialize(_from_message: false, test_id: nil,
|
254
258
|
some_int: nil)
|
259
|
+
@_from_message = _from_message
|
255
260
|
super
|
256
261
|
self.test_id = test_id
|
257
262
|
self.some_int = some_int
|
@@ -302,10 +307,11 @@ module Schemas
|
|
302
307
|
attr_accessor :some_optional_int
|
303
308
|
|
304
309
|
# @override
|
305
|
-
def initialize(some_int: nil,
|
310
|
+
def initialize(_from_message: false, some_int: nil,
|
306
311
|
some_float: nil,
|
307
312
|
some_string: nil,
|
308
313
|
some_optional_int: nil)
|
314
|
+
@_from_message = _from_message
|
309
315
|
super
|
310
316
|
self.some_int = some_int
|
311
317
|
self.some_float = some_float
|
@@ -361,11 +367,12 @@ module Schemas
|
|
361
367
|
end
|
362
368
|
|
363
369
|
# @override
|
364
|
-
def initialize(test_id: nil,
|
370
|
+
def initialize(_from_message: false, test_id: nil,
|
365
371
|
test_float: nil,
|
366
372
|
test_array: nil,
|
367
373
|
some_nested_record: nil,
|
368
374
|
some_optional_record: nil)
|
375
|
+
@_from_message = _from_message
|
369
376
|
super
|
370
377
|
self.test_id = test_id
|
371
378
|
self.test_float = test_float
|
@@ -414,30 +421,19 @@ module Schemas
|
|
414
421
|
# Autogenerated Schema for Record at com.my-namespace.MySchema
|
415
422
|
class MySchema < Deimos::SchemaClass::Record
|
416
423
|
|
417
|
-
### Attribute Readers ###
|
418
|
-
# @return [MySchemaKey]
|
419
|
-
attr_reader :payload_key
|
420
|
-
|
421
424
|
### Attribute Accessors ###
|
422
425
|
# @return [String]
|
423
426
|
attr_accessor :test_id
|
424
427
|
# @return [Integer]
|
425
428
|
attr_accessor :some_int
|
426
429
|
|
427
|
-
### Attribute Writers ###
|
428
|
-
# @return [MySchemaKey]
|
429
|
-
def payload_key=(value)
|
430
|
-
@payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
|
431
|
-
end
|
432
|
-
|
433
430
|
# @override
|
434
|
-
def initialize(test_id: nil,
|
435
|
-
some_int: nil
|
436
|
-
|
431
|
+
def initialize(_from_message: false, test_id: nil,
|
432
|
+
some_int: nil)
|
433
|
+
@_from_message = _from_message
|
437
434
|
super
|
438
435
|
self.test_id = test_id
|
439
436
|
self.some_int = some_int
|
440
|
-
self.payload_key = payload_key
|
441
437
|
end
|
442
438
|
|
443
439
|
# @override
|
@@ -450,19 +446,11 @@ module Schemas
|
|
450
446
|
'com.my-namespace'
|
451
447
|
end
|
452
448
|
|
453
|
-
def self.tombstone(key)
|
454
|
-
record = self.allocate
|
455
|
-
record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
|
456
|
-
record.payload_key = key
|
457
|
-
record
|
458
|
-
end
|
459
|
-
|
460
449
|
# @override
|
461
450
|
def as_json(_opts={})
|
462
451
|
{
|
463
452
|
'test_id' => @test_id,
|
464
|
-
'some_int' => @some_int
|
465
|
-
'payload_key' => @payload_key&.as_json
|
453
|
+
'some_int' => @some_int
|
466
454
|
}
|
467
455
|
end
|
468
456
|
end
|
@@ -485,8 +473,9 @@ module Schemas
|
|
485
473
|
attr_accessor :part_two
|
486
474
|
|
487
475
|
# @override
|
488
|
-
def initialize(part_one: nil,
|
476
|
+
def initialize(_from_message: false, part_one: nil,
|
489
477
|
part_two: nil)
|
478
|
+
@_from_message = _from_message
|
490
479
|
super
|
491
480
|
self.part_one = part_one
|
492
481
|
self.part_two = part_two
|
@@ -527,7 +516,8 @@ module Schemas
|
|
527
516
|
attr_accessor :id
|
528
517
|
|
529
518
|
# @override
|
530
|
-
def initialize(id: nil)
|
519
|
+
def initialize(_from_message: false, id: nil)
|
520
|
+
@_from_message = _from_message
|
531
521
|
super
|
532
522
|
self.id = id
|
533
523
|
end
|
@@ -566,7 +556,8 @@ module Schemas
|
|
566
556
|
attr_accessor :test_id
|
567
557
|
|
568
558
|
# @override
|
569
|
-
def initialize(test_id: nil)
|
559
|
+
def initialize(_from_message: false, test_id: nil)
|
560
|
+
@_from_message = _from_message
|
570
561
|
super
|
571
562
|
self.test_id = test_id
|
572
563
|
end
|
@@ -607,8 +598,9 @@ module Schemas
|
|
607
598
|
attr_accessor :some_bool
|
608
599
|
|
609
600
|
# @override
|
610
|
-
def initialize(test_id: nil,
|
601
|
+
def initialize(_from_message: false, test_id: nil,
|
611
602
|
some_bool: nil)
|
603
|
+
@_from_message = _from_message
|
612
604
|
super
|
613
605
|
self.test_id = test_id
|
614
606
|
self.some_bool = some_bool
|
@@ -653,7 +645,8 @@ module Schemas
|
|
653
645
|
attr_accessor :property
|
654
646
|
|
655
647
|
# @override
|
656
|
-
def initialize(property: nil)
|
648
|
+
def initialize(_from_message: false, property: nil)
|
649
|
+
@_from_message = _from_message
|
657
650
|
super
|
658
651
|
self.property = property
|
659
652
|
end
|
@@ -690,7 +683,8 @@ module Schemas
|
|
690
683
|
end
|
691
684
|
|
692
685
|
# @override
|
693
|
-
def initialize(properties: {})
|
686
|
+
def initialize(_from_message: false, properties: {})
|
687
|
+
@_from_message = _from_message
|
694
688
|
super
|
695
689
|
self.properties = properties
|
696
690
|
end
|
@@ -733,7 +727,8 @@ module Schemas
|
|
733
727
|
attr_accessor :a_record_field
|
734
728
|
|
735
729
|
# @override
|
736
|
-
def initialize(a_record_field: nil)
|
730
|
+
def initialize(_from_message: false, a_record_field: nil)
|
731
|
+
@_from_message = _from_message
|
737
732
|
super
|
738
733
|
self.a_record_field = a_record_field
|
739
734
|
end
|
@@ -758,35 +753,56 @@ module Schemas
|
|
758
753
|
|
759
754
|
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
760
755
|
class AnEnum < Deimos::SchemaClass::Enum
|
761
|
-
# @return ['sym1', 'sym2']
|
762
|
-
attr_accessor :an_enum
|
763
|
-
|
764
756
|
# @override
|
765
757
|
def symbols
|
766
758
|
%w(sym1 sym2)
|
767
759
|
end
|
760
|
+
|
761
|
+
|
762
|
+
def sym1?
|
763
|
+
@value == 'sym1'
|
764
|
+
end
|
765
|
+
|
766
|
+
def sym2?
|
767
|
+
@value == 'sym2'
|
768
|
+
end
|
769
|
+
|
768
770
|
end
|
769
771
|
|
770
772
|
# Autogenerated Schema for Enum at com.my-namespace.AnotherEnum
|
771
773
|
class AnotherEnum < Deimos::SchemaClass::Enum
|
772
|
-
# @return ['sym3', 'sym4']
|
773
|
-
attr_accessor :another_enum
|
774
|
-
|
775
774
|
# @override
|
776
775
|
def symbols
|
777
776
|
%w(sym3 sym4)
|
778
777
|
end
|
778
|
+
|
779
|
+
|
780
|
+
def sym3?
|
781
|
+
@value == 'sym3'
|
782
|
+
end
|
783
|
+
|
784
|
+
def sym4?
|
785
|
+
@value == 'sym4'
|
786
|
+
end
|
787
|
+
|
779
788
|
end
|
780
789
|
|
781
790
|
# Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum
|
782
791
|
class YetAnotherEnum < Deimos::SchemaClass::Enum
|
783
|
-
# @return ['sym5', 'sym6']
|
784
|
-
attr_accessor :yet_another_enum
|
785
|
-
|
786
792
|
# @override
|
787
793
|
def symbols
|
788
794
|
%w(sym5 sym6)
|
789
795
|
end
|
796
|
+
|
797
|
+
|
798
|
+
def sym5?
|
799
|
+
@value == 'sym5'
|
800
|
+
end
|
801
|
+
|
802
|
+
def sym6?
|
803
|
+
@value == 'sym6'
|
804
|
+
end
|
805
|
+
|
790
806
|
end
|
791
807
|
|
792
808
|
|
@@ -863,7 +879,7 @@ module Schemas
|
|
863
879
|
end
|
864
880
|
|
865
881
|
# @override
|
866
|
-
def initialize(test_id: nil,
|
882
|
+
def initialize(_from_message: false, test_id: nil,
|
867
883
|
test_float: nil,
|
868
884
|
test_string_array: ["test"],
|
869
885
|
test_int_array: [123],
|
@@ -876,6 +892,7 @@ module Schemas
|
|
876
892
|
some_enum_array: nil,
|
877
893
|
some_optional_enum: nil,
|
878
894
|
some_enum_with_default: "sym6")
|
895
|
+
@_from_message = _from_message
|
879
896
|
super
|
880
897
|
self.test_id = test_id
|
881
898
|
self.test_float = test_float
|
@@ -946,11 +963,12 @@ module Schemas
|
|
946
963
|
attr_accessor :timestamp
|
947
964
|
|
948
965
|
# @override
|
949
|
-
def initialize(test_id: nil,
|
966
|
+
def initialize(_from_message: false, test_id: nil,
|
950
967
|
updated_at: nil,
|
951
968
|
some_int: nil,
|
952
969
|
some_datetime_int: nil,
|
953
970
|
timestamp: nil)
|
971
|
+
@_from_message = _from_message
|
954
972
|
super
|
955
973
|
self.test_id = test_id
|
956
974
|
self.updated_at = updated_at
|
@@ -1003,10 +1021,11 @@ module Schemas
|
|
1003
1021
|
attr_accessor :timestamp
|
1004
1022
|
|
1005
1023
|
# @override
|
1006
|
-
def initialize(test_id: nil,
|
1024
|
+
def initialize(_from_message: false, test_id: nil,
|
1007
1025
|
some_int: nil,
|
1008
1026
|
message_id: nil,
|
1009
1027
|
timestamp: nil)
|
1028
|
+
@_from_message = _from_message
|
1010
1029
|
super
|
1011
1030
|
self.test_id = test_id
|
1012
1031
|
self.some_int = some_int
|
@@ -1055,9 +1074,10 @@ module Schemas
|
|
1055
1074
|
attr_accessor :title
|
1056
1075
|
|
1057
1076
|
# @override
|
1058
|
-
def initialize(test_id: nil,
|
1077
|
+
def initialize(_from_message: false, test_id: nil,
|
1059
1078
|
some_int: nil,
|
1060
1079
|
title: nil)
|
1080
|
+
@_from_message = _from_message
|
1061
1081
|
super
|
1062
1082
|
self.test_id = test_id
|
1063
1083
|
self.some_int = some_int
|
@@ -1106,8 +1126,9 @@ module Schemas
|
|
1106
1126
|
attr_accessor :record1_id
|
1107
1127
|
|
1108
1128
|
# @override
|
1109
|
-
def initialize(record1_map: {},
|
1129
|
+
def initialize(_from_message: false, record1_map: {},
|
1110
1130
|
record1_id: 0)
|
1131
|
+
@_from_message = _from_message
|
1111
1132
|
super
|
1112
1133
|
self.record1_map = record1_map
|
1113
1134
|
self.record1_id = record1_id
|
@@ -1140,7 +1161,8 @@ module Schemas
|
|
1140
1161
|
attr_accessor :record2_id
|
1141
1162
|
|
1142
1163
|
# @override
|
1143
|
-
def initialize(record2_id: "")
|
1164
|
+
def initialize(_from_message: false, record2_id: "")
|
1165
|
+
@_from_message = _from_message
|
1144
1166
|
super
|
1145
1167
|
self.record2_id = record2_id
|
1146
1168
|
end
|
@@ -1171,7 +1193,8 @@ module Schemas
|
|
1171
1193
|
attr_accessor :record3_id
|
1172
1194
|
|
1173
1195
|
# @override
|
1174
|
-
def initialize(record3_id: 0.0)
|
1196
|
+
def initialize(_from_message: false, record3_id: 0.0)
|
1197
|
+
@_from_message = _from_message
|
1175
1198
|
super
|
1176
1199
|
self.record3_id = record3_id
|
1177
1200
|
end
|
@@ -1202,7 +1225,8 @@ module Schemas
|
|
1202
1225
|
attr_accessor :record4_id
|
1203
1226
|
|
1204
1227
|
# @override
|
1205
|
-
def initialize(record4_id: 0)
|
1228
|
+
def initialize(_from_message: false, record4_id: 0)
|
1229
|
+
@_from_message = _from_message
|
1206
1230
|
super
|
1207
1231
|
self.record4_id = record4_id
|
1208
1232
|
end
|
@@ -1258,9 +1282,10 @@ module Schemas
|
|
1258
1282
|
end
|
1259
1283
|
|
1260
1284
|
# @override
|
1261
|
-
def initialize(test_id: "",
|
1285
|
+
def initialize(_from_message: false, test_id: "",
|
1262
1286
|
test_long: nil,
|
1263
1287
|
test_union_type: nil)
|
1288
|
+
@_from_message = _from_message
|
1264
1289
|
super
|
1265
1290
|
self.test_id = test_id
|
1266
1291
|
self.test_long = test_long
|
@@ -1311,11 +1336,12 @@ module Schemas
|
|
1311
1336
|
attr_accessor :timestamp
|
1312
1337
|
|
1313
1338
|
# @override
|
1314
|
-
def initialize(id: nil,
|
1339
|
+
def initialize(_from_message: false, id: nil,
|
1315
1340
|
test_id: nil,
|
1316
1341
|
some_int: nil,
|
1317
1342
|
message_id: nil,
|
1318
1343
|
timestamp: nil)
|
1344
|
+
@_from_message = _from_message
|
1319
1345
|
super
|
1320
1346
|
self.id = id
|
1321
1347
|
self.test_id = test_id
|
@@ -1362,7 +1388,8 @@ module Schemas
|
|
1362
1388
|
attr_accessor :update_request_id
|
1363
1389
|
|
1364
1390
|
# @override
|
1365
|
-
def initialize(update_request_id: nil)
|
1391
|
+
def initialize(_from_message: false, update_request_id: nil)
|
1392
|
+
@_from_message = _from_message
|
1366
1393
|
super
|
1367
1394
|
self.update_request_id = update_request_id
|
1368
1395
|
end
|
@@ -1401,7 +1428,8 @@ module Schemas
|
|
1401
1428
|
attr_accessor :update_response_id
|
1402
1429
|
|
1403
1430
|
# @override
|
1404
|
-
def initialize(update_response_id: nil)
|
1431
|
+
def initialize(_from_message: false, update_response_id: nil)
|
1432
|
+
@_from_message = _from_message
|
1405
1433
|
super
|
1406
1434
|
self.update_response_id = update_response_id
|
1407
1435
|
end
|
@@ -1456,7 +1484,7 @@ module Schemas
|
|
1456
1484
|
attr_accessor :created_at
|
1457
1485
|
|
1458
1486
|
# @override
|
1459
|
-
def initialize(id: nil,
|
1487
|
+
def initialize(_from_message: false, id: nil,
|
1460
1488
|
wibble_id: nil,
|
1461
1489
|
name: nil,
|
1462
1490
|
floop: nil,
|
@@ -1465,6 +1493,7 @@ module Schemas
|
|
1465
1493
|
birthday_optional: nil,
|
1466
1494
|
updated_at: nil,
|
1467
1495
|
created_at: nil)
|
1496
|
+
@_from_message = _from_message
|
1468
1497
|
super
|
1469
1498
|
self.id = id
|
1470
1499
|
self.wibble_id = wibble_id
|
@@ -1527,11 +1556,12 @@ module Schemas
|
|
1527
1556
|
attr_accessor :created_at
|
1528
1557
|
|
1529
1558
|
# @override
|
1530
|
-
def initialize(id: nil,
|
1559
|
+
def initialize(_from_message: false, id: nil,
|
1531
1560
|
widget_id: nil,
|
1532
1561
|
name: nil,
|
1533
1562
|
updated_at: nil,
|
1534
1563
|
created_at: nil)
|
1564
|
+
@_from_message = _from_message
|
1535
1565
|
super
|
1536
1566
|
self.id = id
|
1537
1567
|
self.widget_id = widget_id
|
@@ -1586,11 +1616,12 @@ module Schemas
|
|
1586
1616
|
attr_accessor :created_at
|
1587
1617
|
|
1588
1618
|
# @override
|
1589
|
-
def initialize(id: nil,
|
1619
|
+
def initialize(_from_message: false, id: nil,
|
1590
1620
|
widget_id: nil,
|
1591
1621
|
model_id: nil,
|
1592
1622
|
updated_at: nil,
|
1593
1623
|
created_at: nil)
|
1624
|
+
@_from_message = _from_message
|
1594
1625
|
super
|
1595
1626
|
self.id = id
|
1596
1627
|
self.widget_id = widget_id
|