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
@@ -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
@@ -130,7 +132,7 @@ module Schemas
130
132
  end
131
133
 
132
134
  # @override
133
- def initialize(a_string: nil,
135
+ def initialize(_from_message: false, a_string: nil,
134
136
  a_int: nil,
135
137
  a_long: nil,
136
138
  a_float: nil,
@@ -142,6 +144,7 @@ module Schemas
142
144
  timestamp: nil,
143
145
  message_id: nil,
144
146
  a_record: nil)
147
+ @_from_message = _from_message
145
148
  super
146
149
  self.a_string = a_string
147
150
  self.a_int = a_int
@@ -202,7 +205,8 @@ module Schemas
202
205
  attr_accessor :response_id
203
206
 
204
207
  # @override
205
- def initialize(response_id: nil)
208
+ def initialize(_from_message: false, response_id: nil)
209
+ @_from_message = _from_message
206
210
  super
207
211
  self.response_id = response_id
208
212
  end
@@ -243,8 +247,9 @@ module Schemas
243
247
  attr_accessor :some_int
244
248
 
245
249
  # @override
246
- def initialize(test_id: nil,
250
+ def initialize(_from_message: false, test_id: nil,
247
251
  some_int: nil)
252
+ @_from_message = _from_message
248
253
  super
249
254
  self.test_id = test_id
250
255
  self.some_int = some_int
@@ -295,10 +300,11 @@ module Schemas
295
300
  attr_accessor :some_optional_int
296
301
 
297
302
  # @override
298
- def initialize(some_int: nil,
303
+ def initialize(_from_message: false, some_int: nil,
299
304
  some_float: nil,
300
305
  some_string: nil,
301
306
  some_optional_int: nil)
307
+ @_from_message = _from_message
302
308
  super
303
309
  self.some_int = some_int
304
310
  self.some_float = some_float
@@ -354,11 +360,12 @@ module Schemas
354
360
  end
355
361
 
356
362
  # @override
357
- def initialize(test_id: nil,
363
+ def initialize(_from_message: false, test_id: nil,
358
364
  test_float: nil,
359
365
  test_array: nil,
360
366
  some_nested_record: nil,
361
367
  some_optional_record: nil)
368
+ @_from_message = _from_message
362
369
  super
363
370
  self.test_id = test_id
364
371
  self.test_float = test_float
@@ -377,6 +384,13 @@ module Schemas
377
384
  'com.my-namespace'
378
385
  end
379
386
 
387
+ def self.tombstone(key)
388
+ record = self.allocate
389
+ record.tombstone_key = key
390
+ record.test_id = key
391
+ record
392
+ end
393
+
380
394
  # @override
381
395
  def as_json(_opts={})
382
396
  {
@@ -400,30 +414,19 @@ module Schemas
400
414
  # Autogenerated Schema for Record at com.my-namespace.MySchema
401
415
  class MySchema < Deimos::SchemaClass::Record
402
416
 
403
- ### Attribute Readers ###
404
- # @return [MySchemaKey]
405
- attr_reader :payload_key
406
-
407
417
  ### Attribute Accessors ###
408
418
  # @return [String]
409
419
  attr_accessor :test_id
410
420
  # @return [Integer]
411
421
  attr_accessor :some_int
412
422
 
413
- ### Attribute Writers ###
414
- # @return [MySchemaKey]
415
- def payload_key=(value)
416
- @payload_key = MySchemaKey.initialize_from_value(value, from_message: self._from_message)
417
- end
418
-
419
423
  # @override
420
- def initialize(test_id: nil,
421
- some_int: nil,
422
- payload_key: nil)
424
+ def initialize(_from_message: false, test_id: nil,
425
+ some_int: nil)
426
+ @_from_message = _from_message
423
427
  super
424
428
  self.test_id = test_id
425
429
  self.some_int = some_int
426
- self.payload_key = payload_key
427
430
  end
428
431
 
429
432
  # @override
@@ -436,19 +439,11 @@ module Schemas
436
439
  'com.my-namespace'
437
440
  end
438
441
 
439
- def self.tombstone(key)
440
- record = self.allocate
441
- record.tombstone_key = MySchemaKey.initialize_from_value(key, from_message: self._from_message)
442
- record.payload_key = key
443
- record
444
- end
445
-
446
442
  # @override
447
443
  def as_json(_opts={})
448
444
  {
449
445
  'test_id' => @test_id,
450
- 'some_int' => @some_int,
451
- 'payload_key' => @payload_key&.as_json
446
+ 'some_int' => @some_int
452
447
  }
453
448
  end
454
449
  end
@@ -471,8 +466,9 @@ module Schemas
471
466
  attr_accessor :part_two
472
467
 
473
468
  # @override
474
- def initialize(part_one: nil,
469
+ def initialize(_from_message: false, part_one: nil,
475
470
  part_two: nil)
471
+ @_from_message = _from_message
476
472
  super
477
473
  self.part_one = part_one
478
474
  self.part_two = part_two
@@ -513,7 +509,8 @@ module Schemas
513
509
  attr_accessor :id
514
510
 
515
511
  # @override
516
- def initialize(id: nil)
512
+ def initialize(_from_message: false, id: nil)
513
+ @_from_message = _from_message
517
514
  super
518
515
  self.id = id
519
516
  end
@@ -552,7 +549,8 @@ module Schemas
552
549
  attr_accessor :test_id
553
550
 
554
551
  # @override
555
- def initialize(test_id: nil)
552
+ def initialize(_from_message: false, test_id: nil)
553
+ @_from_message = _from_message
556
554
  super
557
555
  self.test_id = test_id
558
556
  end
@@ -593,8 +591,9 @@ module Schemas
593
591
  attr_accessor :some_bool
594
592
 
595
593
  # @override
596
- def initialize(test_id: nil,
594
+ def initialize(_from_message: false, test_id: nil,
597
595
  some_bool: nil)
596
+ @_from_message = _from_message
598
597
  super
599
598
  self.test_id = test_id
600
599
  self.some_bool = some_bool
@@ -639,7 +638,8 @@ module Schemas
639
638
  attr_accessor :property
640
639
 
641
640
  # @override
642
- def initialize(property: nil)
641
+ def initialize(_from_message: false, property: nil)
642
+ @_from_message = _from_message
643
643
  super
644
644
  self.property = property
645
645
  end
@@ -676,7 +676,8 @@ module Schemas
676
676
  end
677
677
 
678
678
  # @override
679
- def initialize(properties: {})
679
+ def initialize(_from_message: false, properties: {})
680
+ @_from_message = _from_message
680
681
  super
681
682
  self.properties = properties
682
683
  end
@@ -719,7 +720,8 @@ module Schemas
719
720
  attr_accessor :a_record_field
720
721
 
721
722
  # @override
722
- def initialize(a_record_field: nil)
723
+ def initialize(_from_message: false, a_record_field: nil)
724
+ @_from_message = _from_message
723
725
  super
724
726
  self.a_record_field = a_record_field
725
727
  end
@@ -849,7 +851,7 @@ module Schemas
849
851
  end
850
852
 
851
853
  # @override
852
- def initialize(test_id: nil,
854
+ def initialize(_from_message: false, test_id: nil,
853
855
  test_float: nil,
854
856
  test_string_array: ["test"],
855
857
  test_int_array: [123],
@@ -862,6 +864,7 @@ module Schemas
862
864
  some_enum_array: nil,
863
865
  some_optional_enum: nil,
864
866
  some_enum_with_default: "sym6")
867
+ @_from_message = _from_message
865
868
  super
866
869
  self.test_id = test_id
867
870
  self.test_float = test_float
@@ -932,11 +935,12 @@ module Schemas
932
935
  attr_accessor :timestamp
933
936
 
934
937
  # @override
935
- def initialize(test_id: nil,
938
+ def initialize(_from_message: false, test_id: nil,
936
939
  updated_at: nil,
937
940
  some_int: nil,
938
941
  some_datetime_int: nil,
939
942
  timestamp: nil)
943
+ @_from_message = _from_message
940
944
  super
941
945
  self.test_id = test_id
942
946
  self.updated_at = updated_at
@@ -989,10 +993,11 @@ module Schemas
989
993
  attr_accessor :timestamp
990
994
 
991
995
  # @override
992
- def initialize(test_id: nil,
996
+ def initialize(_from_message: false, test_id: nil,
993
997
  some_int: nil,
994
998
  message_id: nil,
995
999
  timestamp: nil)
1000
+ @_from_message = _from_message
996
1001
  super
997
1002
  self.test_id = test_id
998
1003
  self.some_int = some_int
@@ -1041,9 +1046,10 @@ module Schemas
1041
1046
  attr_accessor :title
1042
1047
 
1043
1048
  # @override
1044
- def initialize(test_id: nil,
1049
+ def initialize(_from_message: false, test_id: nil,
1045
1050
  some_int: nil,
1046
1051
  title: nil)
1052
+ @_from_message = _from_message
1047
1053
  super
1048
1054
  self.test_id = test_id
1049
1055
  self.some_int = some_int
@@ -1092,8 +1098,9 @@ module Schemas
1092
1098
  attr_accessor :record1_id
1093
1099
 
1094
1100
  # @override
1095
- def initialize(record1_map: {},
1101
+ def initialize(_from_message: false, record1_map: {},
1096
1102
  record1_id: 0)
1103
+ @_from_message = _from_message
1097
1104
  super
1098
1105
  self.record1_map = record1_map
1099
1106
  self.record1_id = record1_id
@@ -1126,7 +1133,8 @@ module Schemas
1126
1133
  attr_accessor :record2_id
1127
1134
 
1128
1135
  # @override
1129
- def initialize(record2_id: "")
1136
+ def initialize(_from_message: false, record2_id: "")
1137
+ @_from_message = _from_message
1130
1138
  super
1131
1139
  self.record2_id = record2_id
1132
1140
  end
@@ -1157,7 +1165,8 @@ module Schemas
1157
1165
  attr_accessor :record3_id
1158
1166
 
1159
1167
  # @override
1160
- def initialize(record3_id: 0.0)
1168
+ def initialize(_from_message: false, record3_id: 0.0)
1169
+ @_from_message = _from_message
1161
1170
  super
1162
1171
  self.record3_id = record3_id
1163
1172
  end
@@ -1188,7 +1197,8 @@ module Schemas
1188
1197
  attr_accessor :record4_id
1189
1198
 
1190
1199
  # @override
1191
- def initialize(record4_id: 0)
1200
+ def initialize(_from_message: false, record4_id: 0)
1201
+ @_from_message = _from_message
1192
1202
  super
1193
1203
  self.record4_id = record4_id
1194
1204
  end
@@ -1244,9 +1254,10 @@ module Schemas
1244
1254
  end
1245
1255
 
1246
1256
  # @override
1247
- def initialize(test_id: "",
1257
+ def initialize(_from_message: false, test_id: "",
1248
1258
  test_long: nil,
1249
1259
  test_union_type: nil)
1260
+ @_from_message = _from_message
1250
1261
  super
1251
1262
  self.test_id = test_id
1252
1263
  self.test_long = test_long
@@ -1297,11 +1308,12 @@ module Schemas
1297
1308
  attr_accessor :timestamp
1298
1309
 
1299
1310
  # @override
1300
- def initialize(id: nil,
1311
+ def initialize(_from_message: false, id: nil,
1301
1312
  test_id: nil,
1302
1313
  some_int: nil,
1303
1314
  message_id: nil,
1304
1315
  timestamp: nil)
1316
+ @_from_message = _from_message
1305
1317
  super
1306
1318
  self.id = id
1307
1319
  self.test_id = test_id
@@ -1348,7 +1360,8 @@ module Schemas
1348
1360
  attr_accessor :update_request_id
1349
1361
 
1350
1362
  # @override
1351
- def initialize(update_request_id: nil)
1363
+ def initialize(_from_message: false, update_request_id: nil)
1364
+ @_from_message = _from_message
1352
1365
  super
1353
1366
  self.update_request_id = update_request_id
1354
1367
  end
@@ -1387,7 +1400,8 @@ module Schemas
1387
1400
  attr_accessor :update_response_id
1388
1401
 
1389
1402
  # @override
1390
- def initialize(update_response_id: nil)
1403
+ def initialize(_from_message: false, update_response_id: nil)
1404
+ @_from_message = _from_message
1391
1405
  super
1392
1406
  self.update_response_id = update_response_id
1393
1407
  end
@@ -1442,7 +1456,7 @@ module Schemas
1442
1456
  attr_accessor :created_at
1443
1457
 
1444
1458
  # @override
1445
- def initialize(id: nil,
1459
+ def initialize(_from_message: false, id: nil,
1446
1460
  wibble_id: nil,
1447
1461
  name: nil,
1448
1462
  floop: nil,
@@ -1451,6 +1465,7 @@ module Schemas
1451
1465
  birthday_optional: nil,
1452
1466
  updated_at: nil,
1453
1467
  created_at: nil)
1468
+ @_from_message = _from_message
1454
1469
  super
1455
1470
  self.id = id
1456
1471
  self.wibble_id = wibble_id
@@ -1513,11 +1528,12 @@ module Schemas
1513
1528
  attr_accessor :created_at
1514
1529
 
1515
1530
  # @override
1516
- def initialize(id: nil,
1531
+ def initialize(_from_message: false, id: nil,
1517
1532
  widget_id: nil,
1518
1533
  name: nil,
1519
1534
  updated_at: nil,
1520
1535
  created_at: nil)
1536
+ @_from_message = _from_message
1521
1537
  super
1522
1538
  self.id = id
1523
1539
  self.widget_id = widget_id
@@ -1572,11 +1588,12 @@ module Schemas
1572
1588
  attr_accessor :created_at
1573
1589
 
1574
1590
  # @override
1575
- def initialize(id: nil,
1591
+ def initialize(_from_message: false, id: nil,
1576
1592
  widget_id: nil,
1577
1593
  model_id: nil,
1578
1594
  updated_at: nil,
1579
1595
  created_at: nil)
1596
+ @_from_message = _from_message
1580
1597
  super
1581
1598
  self.id = id
1582
1599
  self.widget_id = widget_id
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.1.2.pre.beta1
4
+ version: 2.1.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: 2025-07-21 00:00:00.000000000 Z
11
+ date: 2025-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro_turf
@@ -596,6 +596,7 @@ files:
596
596
  - spec/schemas/my_namespace/my_schema_with_complex_type.rb
597
597
  - spec/schemas/my_namespace/my_schema_with_date_time.rb
598
598
  - spec/schemas/my_namespace/my_schema_with_id.rb
599
+ - spec/schemas/my_namespace/my_schema_with_title.rb
599
600
  - spec/schemas/my_namespace/my_schema_with_union_type.rb
600
601
  - spec/schemas/my_namespace/my_schema_with_unique_id.rb
601
602
  - spec/schemas/my_namespace/my_updated_schema.rb
@@ -645,9 +646,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
645
646
  version: '0'
646
647
  required_rubygems_version: !ruby/object:Gem::Requirement
647
648
  requirements:
648
- - - ">"
649
+ - - ">="
649
650
  - !ruby/object:Gem::Version
650
- version: 1.3.1
651
+ version: '0'
651
652
  requirements: []
652
653
  rubygems_version: 3.4.10
653
654
  signing_key:
@@ -725,6 +726,7 @@ test_files:
725
726
  - spec/schemas/my_namespace/my_schema_with_complex_type.rb
726
727
  - spec/schemas/my_namespace/my_schema_with_date_time.rb
727
728
  - spec/schemas/my_namespace/my_schema_with_id.rb
729
+ - spec/schemas/my_namespace/my_schema_with_title.rb
728
730
  - spec/schemas/my_namespace/my_schema_with_union_type.rb
729
731
  - spec/schemas/my_namespace/my_schema_with_unique_id.rb
730
732
  - spec/schemas/my_namespace/my_updated_schema.rb