deimos-ruby 2.1.2.pre.beta1 → 2.1.3

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/README.md +1 -1
  4. data/karafka.rb +71 -1
  5. data/lib/deimos/schema_backends/avro_schema_coercer.rb +2 -0
  6. data/lib/deimos/version.rb +1 -1
  7. data/lib/generators/deimos/schema_class_generator.rb +10 -14
  8. data/regenerate_test_schema_classes.rb +0 -66
  9. data/spec/consumer_spec.rb +25 -4
  10. data/spec/schemas/my_namespace/generated.rb +6 -4
  11. data/spec/schemas/my_namespace/my_long_namespace_schema.rb +2 -1
  12. data/spec/schemas/my_namespace/my_nested_schema.rb +6 -4
  13. data/spec/schemas/my_namespace/my_schema.rb +4 -3
  14. data/spec/schemas/my_namespace/my_schema_compound_key.rb +2 -1
  15. data/spec/schemas/my_namespace/my_schema_id_key.rb +2 -1
  16. data/spec/schemas/my_namespace/my_schema_key.rb +2 -1
  17. data/spec/schemas/my_namespace/my_schema_with_boolean.rb +2 -1
  18. data/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +5 -3
  19. data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +11 -9
  20. data/spec/schemas/my_namespace/my_schema_with_date_time.rb +2 -1
  21. data/spec/schemas/my_namespace/my_schema_with_id.rb +2 -1
  22. data/spec/schemas/my_namespace/my_schema_with_title.rb +47 -0
  23. data/spec/schemas/my_namespace/my_schema_with_union_type.rb +12 -7
  24. data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +2 -1
  25. data/spec/schemas/my_namespace/my_updated_schema.rb +2 -1
  26. data/spec/schemas/my_namespace/request/create_topic.rb +2 -1
  27. data/spec/schemas/my_namespace/request/index.rb +2 -1
  28. data/spec/schemas/my_namespace/request/update_request.rb +2 -1
  29. data/spec/schemas/my_namespace/response/create_topic.rb +2 -1
  30. data/spec/schemas/my_namespace/response/index.rb +2 -1
  31. data/spec/schemas/my_namespace/response/update_response.rb +2 -1
  32. data/spec/schemas/my_namespace/wibble.rb +2 -1
  33. data/spec/schemas/my_namespace/widget.rb +2 -1
  34. data/spec/schemas/my_namespace/widget_the_second.rb +2 -1
  35. data/spec/snapshots/consumers-no-nest.snap +65 -36
  36. data/spec/snapshots/consumers.snap +67 -37
  37. data/spec/snapshots/consumers_and_producers-no-nest.snap +60 -58
  38. data/spec/snapshots/consumers_and_producers.snap +62 -59
  39. data/spec/snapshots/consumers_circular-no-nest.snap +65 -36
  40. data/spec/snapshots/consumers_circular.snap +67 -37
  41. data/spec/snapshots/consumers_complex_types-no-nest.snap +65 -36
  42. data/spec/snapshots/consumers_complex_types.snap +67 -37
  43. data/spec/snapshots/consumers_nested-no-nest.snap +58 -29
  44. data/spec/snapshots/consumers_nested.snap +60 -30
  45. data/spec/snapshots/namespace_folders.snap +66 -61
  46. data/spec/snapshots/namespace_map.snap +66 -61
  47. data/spec/snapshots/producers_with_key-no-nest.snap +67 -51
  48. data/spec/snapshots/producers_with_key.snap +69 -52
  49. metadata +6 -4
@@ -17,8 +17,9 @@ module Schemas; module MyNamespace
17
17
  attr_accessor :record1_id
18
18
 
19
19
  # @override
20
- def initialize(record1_map: {},
20
+ def initialize(_from_message: false, record1_map: {},
21
21
  record1_id: 0)
22
+ @_from_message = _from_message
22
23
  super
23
24
  self.record1_map = record1_map
24
25
  self.record1_id = record1_id
@@ -51,7 +52,8 @@ module Schemas; module MyNamespace
51
52
  attr_accessor :record2_id
52
53
 
53
54
  # @override
54
- def initialize(record2_id: "")
55
+ def initialize(_from_message: false, record2_id: "")
56
+ @_from_message = _from_message
55
57
  super
56
58
  self.record2_id = record2_id
57
59
  end
@@ -82,7 +84,8 @@ module Schemas; module MyNamespace
82
84
  attr_accessor :record3_id
83
85
 
84
86
  # @override
85
- def initialize(record3_id: 0.0)
87
+ def initialize(_from_message: false, record3_id: 0.0)
88
+ @_from_message = _from_message
86
89
  super
87
90
  self.record3_id = record3_id
88
91
  end
@@ -113,7 +116,8 @@ module Schemas; module MyNamespace
113
116
  attr_accessor :record4_id
114
117
 
115
118
  # @override
116
- def initialize(record4_id: 0)
119
+ def initialize(_from_message: false, record4_id: 0)
120
+ @_from_message = _from_message
117
121
  super
118
122
  self.record4_id = record4_id
119
123
  end
@@ -150,7 +154,7 @@ module Schemas; module MyNamespace
150
154
  ### Attribute Writers ###
151
155
  # @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
152
156
  def test_union_type=(value)
153
- @test_union_type = initialize_test_union_type_type(value, from_message: @from_message)
157
+ @test_union_type = initialize_test_union_type_type(value, from_message: self._from_message)
154
158
  end
155
159
 
156
160
  # Helper method to determine which schema type to use for test_union_type
@@ -165,13 +169,14 @@ module Schemas; module MyNamespace
165
169
  (value.keys - fields).empty?
166
170
  end
167
171
 
168
- klass.initialize_from_value(value, from_message: @from_message)
172
+ klass.initialize_from_value(value, from_message: self._from_message)
169
173
  end
170
174
 
171
175
  # @override
172
- def initialize(test_id: "",
176
+ def initialize(_from_message: false, test_id: "",
173
177
  test_long: nil,
174
178
  test_union_type: nil)
179
+ @_from_message = _from_message
175
180
  super
176
181
  self.test_id = test_id
177
182
  self.test_long = test_long
@@ -19,11 +19,12 @@ module Schemas; module MyNamespace
19
19
  attr_accessor :timestamp
20
20
 
21
21
  # @override
22
- def initialize(id: nil,
22
+ def initialize(_from_message: false, id: nil,
23
23
  test_id: nil,
24
24
  some_int: nil,
25
25
  message_id: nil,
26
26
  timestamp: nil)
27
+ @_from_message = _from_message
27
28
  super
28
29
  self.id = id
29
30
  self.test_id = test_id
@@ -8,7 +8,8 @@ module Schemas; module Com; module MyNamespace
8
8
 
9
9
  attr_accessor :super_int
10
10
 
11
- def initialize(test_id: nil,
11
+ def initialize(_from_message: false,
12
+ test_id: nil,
12
13
  some_int: nil)
13
14
  super
14
15
  self.super_int = some_int.nil? ? 10 : some_int * 9000
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Request
11
11
  attr_accessor :request_id
12
12
 
13
13
  # @override
14
- def initialize(request_id: nil)
14
+ def initialize(_from_message: false, request_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.request_id = request_id
17
18
  end
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Request
11
11
  attr_accessor :request_id
12
12
 
13
13
  # @override
14
- def initialize(request_id: nil)
14
+ def initialize(_from_message: false, request_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.request_id = request_id
17
18
  end
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Request
11
11
  attr_accessor :update_request_id
12
12
 
13
13
  # @override
14
- def initialize(update_request_id: nil)
14
+ def initialize(_from_message: false, update_request_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.update_request_id = update_request_id
17
18
  end
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Response
11
11
  attr_accessor :response_id
12
12
 
13
13
  # @override
14
- def initialize(response_id: nil)
14
+ def initialize(_from_message: false, response_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.response_id = response_id
17
18
  end
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Response
11
11
  attr_accessor :response_id
12
12
 
13
13
  # @override
14
- def initialize(response_id: nil)
14
+ def initialize(_from_message: false, response_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.response_id = response_id
17
18
  end
@@ -11,7 +11,8 @@ module Schemas; module MyNamespace; module Response
11
11
  attr_accessor :update_response_id
12
12
 
13
13
  # @override
14
- def initialize(update_response_id: nil)
14
+ def initialize(_from_message: false, update_response_id: nil)
15
+ @_from_message = _from_message
15
16
  super
16
17
  self.update_response_id = update_response_id
17
18
  end
@@ -27,7 +27,7 @@ module Schemas; module MyNamespace
27
27
  attr_accessor :created_at
28
28
 
29
29
  # @override
30
- def initialize(id: nil,
30
+ def initialize(_from_message: false, id: nil,
31
31
  wibble_id: nil,
32
32
  name: nil,
33
33
  floop: nil,
@@ -36,6 +36,7 @@ module Schemas; module MyNamespace
36
36
  birthday_optional: nil,
37
37
  updated_at: nil,
38
38
  created_at: nil)
39
+ @_from_message = _from_message
39
40
  super
40
41
  self.id = id
41
42
  self.wibble_id = wibble_id
@@ -19,11 +19,12 @@ module Schemas; module MyNamespace
19
19
  attr_accessor :created_at
20
20
 
21
21
  # @override
22
- def initialize(id: nil,
22
+ def initialize(_from_message: false, id: nil,
23
23
  widget_id: nil,
24
24
  name: nil,
25
25
  updated_at: nil,
26
26
  created_at: nil)
27
+ @_from_message = _from_message
27
28
  super
28
29
  self.id = id
29
30
  self.widget_id = widget_id
@@ -19,11 +19,12 @@ module Schemas; module MyNamespace
19
19
  attr_accessor :created_at
20
20
 
21
21
  # @override
22
- def initialize(id: nil,
22
+ def initialize(_from_message: false, id: nil,
23
23
  widget_id: nil,
24
24
  model_id: nil,
25
25
  updated_at: nil,
26
26
  created_at: nil)
27
+ @_from_message = _from_message
27
28
  super
28
29
  self.id = id
29
30
  self.widget_id = widget_id
@@ -12,7 +12,8 @@ module Schemas
12
12
  attr_accessor :a_record_field
13
13
 
14
14
  # @override
15
- def initialize(a_record_field: nil)
15
+ def initialize(_from_message: false, a_record_field: nil)
16
+ @_from_message = _from_message
16
17
  super
17
18
  self.a_record_field = a_record_field
18
19
  end
@@ -89,7 +90,8 @@ module Schemas
89
90
  attr_accessor :response_id
90
91
 
91
92
  # @override
92
- def initialize(response_id: nil)
93
+ def initialize(_from_message: false, response_id: nil)
94
+ @_from_message = _from_message
93
95
  super
94
96
  self.response_id = response_id
95
97
  end
@@ -163,7 +165,7 @@ module Schemas
163
165
  end
164
166
 
165
167
  # @override
166
- def initialize(a_string: nil,
168
+ def initialize(_from_message: false, a_string: nil,
167
169
  a_int: nil,
168
170
  a_long: nil,
169
171
  a_float: nil,
@@ -175,6 +177,7 @@ module Schemas
175
177
  timestamp: nil,
176
178
  message_id: nil,
177
179
  a_record: nil)
180
+ @_from_message = _from_message
178
181
  super
179
182
  self.a_string = a_string
180
183
  self.a_int = a_int
@@ -200,13 +203,6 @@ module Schemas
200
203
  'com.my-namespace'
201
204
  end
202
205
 
203
- def self.tombstone(key)
204
- record = self.allocate
205
- record.tombstone_key = key
206
- record.a_string = key
207
- record
208
- end
209
-
210
206
  # @override
211
207
  def as_json(_opts={})
212
208
  {
@@ -242,7 +238,8 @@ module Schemas
242
238
  attr_accessor :response_id
243
239
 
244
240
  # @override
245
- def initialize(response_id: nil)
241
+ def initialize(_from_message: false, response_id: nil)
242
+ @_from_message = _from_message
246
243
  super
247
244
  self.response_id = response_id
248
245
  end
@@ -283,8 +280,9 @@ module Schemas
283
280
  attr_accessor :some_int
284
281
 
285
282
  # @override
286
- def initialize(test_id: nil,
283
+ def initialize(_from_message: false, test_id: nil,
287
284
  some_int: nil)
285
+ @_from_message = _from_message
288
286
  super
289
287
  self.test_id = test_id
290
288
  self.some_int = some_int
@@ -331,10 +329,11 @@ module Schemas
331
329
  attr_accessor :some_optional_int
332
330
 
333
331
  # @override
334
- def initialize(some_int: nil,
332
+ def initialize(_from_message: false, some_int: nil,
335
333
  some_float: nil,
336
334
  some_string: nil,
337
335
  some_optional_int: nil)
336
+ @_from_message = _from_message
338
337
  super
339
338
  self.some_int = some_int
340
339
  self.some_float = some_float
@@ -400,11 +399,12 @@ module Schemas
400
399
  end
401
400
 
402
401
  # @override
403
- def initialize(test_id: nil,
402
+ def initialize(_from_message: false, test_id: nil,
404
403
  test_float: nil,
405
404
  test_array: nil,
406
405
  some_nested_record: nil,
407
406
  some_optional_record: nil)
407
+ @_from_message = _from_message
408
408
  super
409
409
  self.test_id = test_id
410
410
  self.test_float = test_float
@@ -423,6 +423,13 @@ module Schemas
423
423
  'com.my-namespace'
424
424
  end
425
425
 
426
+ def self.tombstone(key)
427
+ record = self.allocate
428
+ record.tombstone_key = key
429
+ record.test_id = key
430
+ record
431
+ end
432
+
426
433
  # @override
427
434
  def as_json(_opts={})
428
435
  {
@@ -453,8 +460,9 @@ module Schemas
453
460
  attr_accessor :some_int
454
461
 
455
462
  # @override
456
- def initialize(test_id: nil,
463
+ def initialize(_from_message: false, test_id: nil,
457
464
  some_int: nil)
465
+ @_from_message = _from_message
458
466
  super
459
467
  self.test_id = test_id
460
468
  self.some_int = some_int
@@ -497,8 +505,9 @@ module Schemas
497
505
  attr_accessor :part_two
498
506
 
499
507
  # @override
500
- def initialize(part_one: nil,
508
+ def initialize(_from_message: false, part_one: nil,
501
509
  part_two: nil)
510
+ @_from_message = _from_message
502
511
  super
503
512
  self.part_one = part_one
504
513
  self.part_two = part_two
@@ -539,7 +548,8 @@ module Schemas
539
548
  attr_accessor :id
540
549
 
541
550
  # @override
542
- def initialize(id: nil)
551
+ def initialize(_from_message: false, id: nil)
552
+ @_from_message = _from_message
543
553
  super
544
554
  self.id = id
545
555
  end
@@ -578,7 +588,8 @@ module Schemas
578
588
  attr_accessor :test_id
579
589
 
580
590
  # @override
581
- def initialize(test_id: nil)
591
+ def initialize(_from_message: false, test_id: nil)
592
+ @_from_message = _from_message
582
593
  super
583
594
  self.test_id = test_id
584
595
  end
@@ -619,8 +630,9 @@ module Schemas
619
630
  attr_accessor :some_bool
620
631
 
621
632
  # @override
622
- def initialize(test_id: nil,
633
+ def initialize(_from_message: false, test_id: nil,
623
634
  some_bool: nil)
635
+ @_from_message = _from_message
624
636
  super
625
637
  self.test_id = test_id
626
638
  self.some_bool = some_bool
@@ -669,7 +681,8 @@ module Schemas
669
681
  end
670
682
 
671
683
  # @override
672
- def initialize(properties: {})
684
+ def initialize(_from_message: false, properties: {})
685
+ @_from_message = _from_message
673
686
  super
674
687
  self.properties = properties
675
688
  end
@@ -776,7 +789,7 @@ module Schemas
776
789
  end
777
790
 
778
791
  # @override
779
- def initialize(test_id: nil,
792
+ def initialize(_from_message: false, test_id: nil,
780
793
  test_float: nil,
781
794
  test_string_array: ["test"],
782
795
  test_int_array: [123],
@@ -789,6 +802,7 @@ module Schemas
789
802
  some_enum_array: nil,
790
803
  some_optional_enum: nil,
791
804
  some_enum_with_default: "sym6")
805
+ @_from_message = _from_message
792
806
  super
793
807
  self.test_id = test_id
794
808
  self.test_float = test_float
@@ -859,11 +873,12 @@ module Schemas
859
873
  attr_accessor :timestamp
860
874
 
861
875
  # @override
862
- def initialize(test_id: nil,
876
+ def initialize(_from_message: false, test_id: nil,
863
877
  updated_at: nil,
864
878
  some_int: nil,
865
879
  some_datetime_int: nil,
866
880
  timestamp: nil)
881
+ @_from_message = _from_message
867
882
  super
868
883
  self.test_id = test_id
869
884
  self.updated_at = updated_at
@@ -916,10 +931,11 @@ module Schemas
916
931
  attr_accessor :timestamp
917
932
 
918
933
  # @override
919
- def initialize(test_id: nil,
934
+ def initialize(_from_message: false, test_id: nil,
920
935
  some_int: nil,
921
936
  message_id: nil,
922
937
  timestamp: nil)
938
+ @_from_message = _from_message
923
939
  super
924
940
  self.test_id = test_id
925
941
  self.some_int = some_int
@@ -968,9 +984,10 @@ module Schemas
968
984
  attr_accessor :title
969
985
 
970
986
  # @override
971
- def initialize(test_id: nil,
987
+ def initialize(_from_message: false, test_id: nil,
972
988
  some_int: nil,
973
989
  title: nil)
990
+ @_from_message = _from_message
974
991
  super
975
992
  self.test_id = test_id
976
993
  self.some_int = some_int
@@ -1040,9 +1057,10 @@ module Schemas
1040
1057
  end
1041
1058
 
1042
1059
  # @override
1043
- def initialize(test_id: "",
1060
+ def initialize(_from_message: false, test_id: "",
1044
1061
  test_long: nil,
1045
1062
  test_union_type: nil)
1063
+ @_from_message = _from_message
1046
1064
  super
1047
1065
  self.test_id = test_id
1048
1066
  self.test_long = test_long
@@ -1093,11 +1111,12 @@ module Schemas
1093
1111
  attr_accessor :timestamp
1094
1112
 
1095
1113
  # @override
1096
- def initialize(id: nil,
1114
+ def initialize(_from_message: false, id: nil,
1097
1115
  test_id: nil,
1098
1116
  some_int: nil,
1099
1117
  message_id: nil,
1100
1118
  timestamp: nil)
1119
+ @_from_message = _from_message
1101
1120
  super
1102
1121
  self.id = id
1103
1122
  self.test_id = test_id
@@ -1144,7 +1163,8 @@ module Schemas
1144
1163
  attr_accessor :property
1145
1164
 
1146
1165
  # @override
1147
- def initialize(property: nil)
1166
+ def initialize(_from_message: false, property: nil)
1167
+ @_from_message = _from_message
1148
1168
  super
1149
1169
  self.property = property
1150
1170
  end
@@ -1185,8 +1205,9 @@ module Schemas
1185
1205
  attr_accessor :record1_id
1186
1206
 
1187
1207
  # @override
1188
- def initialize(record1_map: {},
1208
+ def initialize(_from_message: false, record1_map: {},
1189
1209
  record1_id: 0)
1210
+ @_from_message = _from_message
1190
1211
  super
1191
1212
  self.record1_map = record1_map
1192
1213
  self.record1_id = record1_id
@@ -1227,7 +1248,8 @@ module Schemas
1227
1248
  attr_accessor :record2_id
1228
1249
 
1229
1250
  # @override
1230
- def initialize(record2_id: "")
1251
+ def initialize(_from_message: false, record2_id: "")
1252
+ @_from_message = _from_message
1231
1253
  super
1232
1254
  self.record2_id = record2_id
1233
1255
  end
@@ -1266,7 +1288,8 @@ module Schemas
1266
1288
  attr_accessor :record3_id
1267
1289
 
1268
1290
  # @override
1269
- def initialize(record3_id: 0.0)
1291
+ def initialize(_from_message: false, record3_id: 0.0)
1292
+ @_from_message = _from_message
1270
1293
  super
1271
1294
  self.record3_id = record3_id
1272
1295
  end
@@ -1305,7 +1328,8 @@ module Schemas
1305
1328
  attr_accessor :record4_id
1306
1329
 
1307
1330
  # @override
1308
- def initialize(record4_id: 0)
1331
+ def initialize(_from_message: false, record4_id: 0)
1332
+ @_from_message = _from_message
1309
1333
  super
1310
1334
  self.record4_id = record4_id
1311
1335
  end
@@ -1344,7 +1368,8 @@ module Schemas
1344
1368
  attr_accessor :update_request_id
1345
1369
 
1346
1370
  # @override
1347
- def initialize(update_request_id: nil)
1371
+ def initialize(_from_message: false, update_request_id: nil)
1372
+ @_from_message = _from_message
1348
1373
  super
1349
1374
  self.update_request_id = update_request_id
1350
1375
  end
@@ -1383,7 +1408,8 @@ module Schemas
1383
1408
  attr_accessor :update_response_id
1384
1409
 
1385
1410
  # @override
1386
- def initialize(update_response_id: nil)
1411
+ def initialize(_from_message: false, update_response_id: nil)
1412
+ @_from_message = _from_message
1387
1413
  super
1388
1414
  self.update_response_id = update_response_id
1389
1415
  end
@@ -1438,7 +1464,7 @@ module Schemas
1438
1464
  attr_accessor :created_at
1439
1465
 
1440
1466
  # @override
1441
- def initialize(id: nil,
1467
+ def initialize(_from_message: false, id: nil,
1442
1468
  wibble_id: nil,
1443
1469
  name: nil,
1444
1470
  floop: nil,
@@ -1447,6 +1473,7 @@ module Schemas
1447
1473
  birthday_optional: nil,
1448
1474
  updated_at: nil,
1449
1475
  created_at: nil)
1476
+ @_from_message = _from_message
1450
1477
  super
1451
1478
  self.id = id
1452
1479
  self.wibble_id = wibble_id
@@ -1509,11 +1536,12 @@ module Schemas
1509
1536
  attr_accessor :created_at
1510
1537
 
1511
1538
  # @override
1512
- def initialize(id: nil,
1539
+ def initialize(_from_message: false, id: nil,
1513
1540
  widget_id: nil,
1514
1541
  name: nil,
1515
1542
  updated_at: nil,
1516
1543
  created_at: nil)
1544
+ @_from_message = _from_message
1517
1545
  super
1518
1546
  self.id = id
1519
1547
  self.widget_id = widget_id
@@ -1568,11 +1596,12 @@ module Schemas
1568
1596
  attr_accessor :created_at
1569
1597
 
1570
1598
  # @override
1571
- def initialize(id: nil,
1599
+ def initialize(_from_message: false, id: nil,
1572
1600
  widget_id: nil,
1573
1601
  model_id: nil,
1574
1602
  updated_at: nil,
1575
1603
  created_at: nil)
1604
+ @_from_message = _from_message
1576
1605
  super
1577
1606
  self.id = id
1578
1607
  self.widget_id = widget_id