deimos-ruby 1.15.0 → 1.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/deimos/active_record_producer.rb +1 -1
  4. data/lib/deimos/consumer.rb +3 -1
  5. data/lib/deimos/schema_class/base.rb +2 -25
  6. data/lib/deimos/schema_class/enum.rb +23 -0
  7. data/lib/deimos/schema_class/record.rb +15 -4
  8. data/lib/deimos/test_helpers.rb +3 -2
  9. data/lib/deimos/tracing/datadog.rb +11 -0
  10. data/lib/deimos/tracing/mock.rb +10 -0
  11. data/lib/deimos/tracing/provider.rb +13 -0
  12. data/lib/deimos/utils/db_poller.rb +1 -2
  13. data/lib/deimos/utils/schema_class.rb +16 -2
  14. data/lib/deimos/utils/schema_controller_mixin.rb +7 -1
  15. data/lib/deimos/version.rb +1 -1
  16. data/lib/deimos.rb +1 -2
  17. data/lib/generators/deimos/schema_class/templates/schema_enum.rb.tt +0 -11
  18. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +2 -2
  19. data/lib/generators/deimos/schema_class_generator.rb +6 -10
  20. data/spec/batch_consumer_spec.rb +13 -10
  21. data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +19 -19
  22. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +2 -2
  23. data/spec/schemas/generated.rb +5 -5
  24. data/spec/schemas/my_nested_schema.rb +4 -4
  25. data/spec/schemas/my_schema.rb +2 -2
  26. data/spec/schemas/my_schema_key.rb +1 -1
  27. data/spec/schemas/my_schema_with_circular_reference.rb +3 -3
  28. data/spec/schemas/my_schema_with_complex_type.rb +11 -22
  29. data/spec/snapshots/consumers-no-nest.snap +34 -67
  30. data/spec/snapshots/consumers.snap +35 -79
  31. data/spec/snapshots/consumers_and_producers-no-nest.snap +35 -68
  32. data/spec/snapshots/consumers_and_producers.snap +36 -80
  33. data/spec/snapshots/consumers_circular-no-nest.snap +34 -67
  34. data/spec/snapshots/consumers_circular.snap +35 -79
  35. data/spec/snapshots/consumers_complex_types-no-nest.snap +34 -67
  36. data/spec/snapshots/consumers_complex_types.snap +35 -79
  37. data/spec/snapshots/consumers_nested-no-nest.snap +34 -67
  38. data/spec/snapshots/consumers_nested.snap +35 -79
  39. data/spec/snapshots/namespace_folders.snap +53 -97
  40. data/spec/snapshots/producers_with_key-no-nest.snap +35 -68
  41. data/spec/snapshots/producers_with_key.snap +36 -80
  42. metadata +3 -3
@@ -1,4 +1,4 @@
1
- spec/app/lib/schema_classes/my-namespace/generated.rb:
1
+ spec/app/lib/schema_classes/my_namespace/generated.rb:
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # This file is autogenerated by Deimos, Do NOT modify
@@ -32,7 +32,7 @@ module Schemas; module MyNamespace
32
32
  end
33
33
 
34
34
  # @override
35
- def to_h
35
+ def as_json(_opts={})
36
36
  {
37
37
  'a_record_field' => @a_record_field
38
38
  }
@@ -44,21 +44,10 @@ module Schemas; module MyNamespace
44
44
  # @return ['sym1', 'sym2']
45
45
  attr_accessor :an_enum
46
46
 
47
- # :nodoc:
48
- def initialize(an_enum)
49
- super
50
- self.an_enum = an_enum
51
- end
52
-
53
47
  # @override
54
48
  def symbols
55
49
  %w(sym1 sym2)
56
50
  end
57
-
58
- # @override
59
- def to_h
60
- @an_enum
61
- end
62
51
  end
63
52
 
64
53
 
@@ -140,7 +129,7 @@ module Schemas; module MyNamespace
140
129
  end
141
130
 
142
131
  # @override
143
- def to_h
132
+ def as_json(_opts={})
144
133
  {
145
134
  'a_string' => @a_string,
146
135
  'a_int' => @a_int,
@@ -148,19 +137,19 @@ module Schemas; module MyNamespace
148
137
  'a_float' => @a_float,
149
138
  'a_double' => @a_double,
150
139
  'an_optional_int' => @an_optional_int,
151
- 'an_enum' => @an_enum&.to_h,
140
+ 'an_enum' => @an_enum&.as_json,
152
141
  'an_array' => @an_array,
153
142
  'a_map' => @a_map,
154
143
  'timestamp' => @timestamp,
155
144
  'message_id' => @message_id,
156
- 'a_record' => @a_record&.to_h
145
+ 'a_record' => @a_record&.as_json
157
146
  }
158
147
  end
159
148
  end
160
149
  end; end
161
150
 
162
151
 
163
- spec/app/lib/schema_classes/my-namespace/my_nested_schema.rb:
152
+ spec/app/lib/schema_classes/my_namespace/my_nested_schema.rb:
164
153
  # frozen_string_literal: true
165
154
 
166
155
  # This file is autogenerated by Deimos, Do NOT modify
@@ -206,7 +195,7 @@ module Schemas; module MyNamespace
206
195
  end
207
196
 
208
197
  # @override
209
- def to_h
198
+ def as_json(_opts={})
210
199
  {
211
200
  'some_int' => @some_int,
212
201
  'some_float' => @some_float,
@@ -267,20 +256,20 @@ module Schemas; module MyNamespace
267
256
  end
268
257
 
269
258
  # @override
270
- def to_h
259
+ def as_json(_opts={})
271
260
  {
272
261
  'test_id' => @test_id,
273
262
  'test_float' => @test_float,
274
263
  'test_array' => @test_array,
275
- 'some_nested_record' => @some_nested_record&.to_h,
276
- 'some_optional_record' => @some_optional_record&.to_h
264
+ 'some_nested_record' => @some_nested_record&.as_json,
265
+ 'some_optional_record' => @some_optional_record&.as_json
277
266
  }
278
267
  end
279
268
  end
280
269
  end; end
281
270
 
282
271
 
283
- spec/app/lib/schema_classes/my-namespace/my_schema.rb:
272
+ spec/app/lib/schema_classes/my_namespace/my_schema.rb:
284
273
  # frozen_string_literal: true
285
274
 
286
275
  # This file is autogenerated by Deimos, Do NOT modify
@@ -326,18 +315,18 @@ module Schemas; module MyNamespace
326
315
  end
327
316
 
328
317
  # @override
329
- def to_h
318
+ def as_json(_opts={})
330
319
  {
331
320
  'test_id' => @test_id,
332
321
  'some_int' => @some_int,
333
- 'payload_key' => @payload_key&.to_h
322
+ 'payload_key' => @payload_key&.as_json
334
323
  }
335
324
  end
336
325
  end
337
326
  end; end
338
327
 
339
328
 
340
- spec/app/lib/schema_classes/my-namespace/my_schema_compound_key.rb:
329
+ spec/app/lib/schema_classes/my_namespace/my_schema_compound_key.rb:
341
330
  # frozen_string_literal: true
342
331
 
343
332
  # This file is autogenerated by Deimos, Do NOT modify
@@ -371,7 +360,7 @@ module Schemas; module MyNamespace
371
360
  end
372
361
 
373
362
  # @override
374
- def to_h
363
+ def as_json(_opts={})
375
364
  {
376
365
  'part_one' => @part_one,
377
366
  'part_two' => @part_two
@@ -381,7 +370,7 @@ module Schemas; module MyNamespace
381
370
  end; end
382
371
 
383
372
 
384
- spec/app/lib/schema_classes/my-namespace/my_schema_id_key.rb:
373
+ spec/app/lib/schema_classes/my_namespace/my_schema_id_key.rb:
385
374
  # frozen_string_literal: true
386
375
 
387
376
  # This file is autogenerated by Deimos, Do NOT modify
@@ -411,7 +400,7 @@ module Schemas; module MyNamespace
411
400
  end
412
401
 
413
402
  # @override
414
- def to_h
403
+ def as_json(_opts={})
415
404
  {
416
405
  'id' => @id
417
406
  }
@@ -420,7 +409,7 @@ module Schemas; module MyNamespace
420
409
  end; end
421
410
 
422
411
 
423
- spec/app/lib/schema_classes/my-namespace/my_schema_key.rb:
412
+ spec/app/lib/schema_classes/my_namespace/my_schema_key.rb:
424
413
  # frozen_string_literal: true
425
414
 
426
415
  # This file is autogenerated by Deimos, Do NOT modify
@@ -450,7 +439,7 @@ module Schemas; module MyNamespace
450
439
  end
451
440
 
452
441
  # @override
453
- def to_h
442
+ def as_json(_opts={})
454
443
  {
455
444
  'test_id' => @test_id
456
445
  }
@@ -459,7 +448,7 @@ module Schemas; module MyNamespace
459
448
  end; end
460
449
 
461
450
 
462
- spec/app/lib/schema_classes/my-namespace/my_schema_with_boolean.rb:
451
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_boolean.rb:
463
452
  # frozen_string_literal: true
464
453
 
465
454
  # This file is autogenerated by Deimos, Do NOT modify
@@ -493,7 +482,7 @@ module Schemas; module MyNamespace
493
482
  end
494
483
 
495
484
  # @override
496
- def to_h
485
+ def as_json(_opts={})
497
486
  {
498
487
  'test_id' => @test_id,
499
488
  'some_bool' => @some_bool
@@ -503,7 +492,7 @@ module Schemas; module MyNamespace
503
492
  end; end
504
493
 
505
494
 
506
- spec/app/lib/schema_classes/my-namespace/my_schema_with_circular_reference.rb:
495
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_circular_reference.rb:
507
496
  # frozen_string_literal: true
508
497
 
509
498
  # This file is autogenerated by Deimos, Do NOT modify
@@ -537,7 +526,7 @@ module Schemas; module MyNamespace
537
526
  end
538
527
 
539
528
  # @override
540
- def to_h
529
+ def as_json(_opts={})
541
530
  {
542
531
  'property' => @property
543
532
  }
@@ -574,16 +563,16 @@ module Schemas; module MyNamespace
574
563
  end
575
564
 
576
565
  # @override
577
- def to_h
566
+ def as_json(_opts={})
578
567
  {
579
- 'properties' => @properties.transform_values { |v| v&.to_h }
568
+ 'properties' => @properties.transform_values { |v| v&.as_json }
580
569
  }
581
570
  end
582
571
  end
583
572
  end; end
584
573
 
585
574
 
586
- spec/app/lib/schema_classes/my-namespace/my_schema_with_complex_type.rb:
575
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_complex_type.rb:
587
576
  # frozen_string_literal: true
588
577
 
589
578
  # This file is autogenerated by Deimos, Do NOT modify
@@ -617,7 +606,7 @@ module Schemas; module MyNamespace
617
606
  end
618
607
 
619
608
  # @override
620
- def to_h
609
+ def as_json(_opts={})
621
610
  {
622
611
  'a_record_field' => @a_record_field
623
612
  }
@@ -629,21 +618,10 @@ module Schemas; module MyNamespace
629
618
  # @return ['sym1', 'sym2']
630
619
  attr_accessor :an_enum
631
620
 
632
- # :nodoc:
633
- def initialize(an_enum)
634
- super
635
- self.an_enum = an_enum
636
- end
637
-
638
621
  # @override
639
622
  def symbols
640
623
  %w(sym1 sym2)
641
624
  end
642
-
643
- # @override
644
- def to_h
645
- @an_enum
646
- end
647
625
  end
648
626
 
649
627
  # Autogenerated Schema for Enum at com.my-namespace.AnotherEnum
@@ -651,21 +629,10 @@ module Schemas; module MyNamespace
651
629
  # @return ['sym3', 'sym4']
652
630
  attr_accessor :another_enum
653
631
 
654
- # :nodoc:
655
- def initialize(another_enum)
656
- super
657
- self.another_enum = another_enum
658
- end
659
-
660
632
  # @override
661
633
  def symbols
662
634
  %w(sym3 sym4)
663
635
  end
664
-
665
- # @override
666
- def to_h
667
- @another_enum
668
- end
669
636
  end
670
637
 
671
638
  # Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum
@@ -673,21 +640,10 @@ module Schemas; module MyNamespace
673
640
  # @return ['sym5', 'sym6']
674
641
  attr_accessor :yet_another_enum
675
642
 
676
- # :nodoc:
677
- def initialize(yet_another_enum)
678
- super
679
- self.yet_another_enum = yet_another_enum
680
- end
681
-
682
643
  # @override
683
644
  def symbols
684
645
  %w(sym5 sym6)
685
646
  end
686
-
687
- # @override
688
- def to_h
689
- @yet_another_enum
690
- end
691
647
  end
692
648
 
693
649
 
@@ -804,7 +760,7 @@ module Schemas; module MyNamespace
804
760
  end
805
761
 
806
762
  # @override
807
- def to_h
763
+ def as_json(_opts={})
808
764
  {
809
765
  'test_id' => @test_id,
810
766
  'test_float' => @test_float,
@@ -812,20 +768,20 @@ module Schemas; module MyNamespace
812
768
  'test_int_array' => @test_int_array,
813
769
  'test_optional_int' => @test_optional_int,
814
770
  'some_integer_map' => @some_integer_map,
815
- 'some_record' => @some_record&.to_h,
816
- 'some_optional_record' => @some_optional_record&.to_h,
817
- 'some_record_array' => @some_record_array.map { |v| v&.to_h },
818
- 'some_record_map' => @some_record_map.transform_values { |v| v&.to_h },
819
- 'some_enum_array' => @some_enum_array.map { |v| v&.to_h },
820
- 'some_optional_enum' => @some_optional_enum&.to_h,
821
- 'some_enum_with_default' => @some_enum_with_default&.to_h
771
+ 'some_record' => @some_record&.as_json,
772
+ 'some_optional_record' => @some_optional_record&.as_json,
773
+ 'some_record_array' => @some_record_array.map { |v| v&.as_json },
774
+ 'some_record_map' => @some_record_map.transform_values { |v| v&.as_json },
775
+ 'some_enum_array' => @some_enum_array.map { |v| v&.as_json },
776
+ 'some_optional_enum' => @some_optional_enum&.as_json,
777
+ 'some_enum_with_default' => @some_enum_with_default&.as_json
822
778
  }
823
779
  end
824
780
  end
825
781
  end; end
826
782
 
827
783
 
828
- spec/app/lib/schema_classes/my-namespace/my_schema_with_date_time.rb:
784
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_date_time.rb:
829
785
  # frozen_string_literal: true
830
786
 
831
787
  # This file is autogenerated by Deimos, Do NOT modify
@@ -871,7 +827,7 @@ module Schemas; module MyNamespace
871
827
  end
872
828
 
873
829
  # @override
874
- def to_h
830
+ def as_json(_opts={})
875
831
  {
876
832
  'test_id' => @test_id,
877
833
  'updated_at' => @updated_at,
@@ -884,7 +840,7 @@ module Schemas; module MyNamespace
884
840
  end; end
885
841
 
886
842
 
887
- spec/app/lib/schema_classes/my-namespace/my_schema_with_id.rb:
843
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_id.rb:
888
844
  # frozen_string_literal: true
889
845
 
890
846
  # This file is autogenerated by Deimos, Do NOT modify
@@ -926,7 +882,7 @@ module Schemas; module MyNamespace
926
882
  end
927
883
 
928
884
  # @override
929
- def to_h
885
+ def as_json(_opts={})
930
886
  {
931
887
  'test_id' => @test_id,
932
888
  'some_int' => @some_int,
@@ -938,7 +894,7 @@ module Schemas; module MyNamespace
938
894
  end; end
939
895
 
940
896
 
941
- spec/app/lib/schema_classes/my-namespace/my_schema_with_unique_id.rb:
897
+ spec/app/lib/schema_classes/my_namespace/my_schema_with_unique_id.rb:
942
898
  # frozen_string_literal: true
943
899
 
944
900
  # This file is autogenerated by Deimos, Do NOT modify
@@ -984,7 +940,7 @@ module Schemas; module MyNamespace
984
940
  end
985
941
 
986
942
  # @override
987
- def to_h
943
+ def as_json(_opts={})
988
944
  {
989
945
  'id' => @id,
990
946
  'test_id' => @test_id,
@@ -997,7 +953,7 @@ module Schemas; module MyNamespace
997
953
  end; end
998
954
 
999
955
 
1000
- spec/app/lib/schema_classes/my-namespace/wibble.rb:
956
+ spec/app/lib/schema_classes/my_namespace/wibble.rb:
1001
957
  # frozen_string_literal: true
1002
958
 
1003
959
  # This file is autogenerated by Deimos, Do NOT modify
@@ -1059,7 +1015,7 @@ module Schemas; module MyNamespace
1059
1015
  end
1060
1016
 
1061
1017
  # @override
1062
- def to_h
1018
+ def as_json(_opts={})
1063
1019
  {
1064
1020
  'id' => @id,
1065
1021
  'wibble_id' => @wibble_id,
@@ -1076,7 +1032,7 @@ module Schemas; module MyNamespace
1076
1032
  end; end
1077
1033
 
1078
1034
 
1079
- spec/app/lib/schema_classes/my-namespace/widget.rb:
1035
+ spec/app/lib/schema_classes/my_namespace/widget.rb:
1080
1036
  # frozen_string_literal: true
1081
1037
 
1082
1038
  # This file is autogenerated by Deimos, Do NOT modify
@@ -1122,7 +1078,7 @@ module Schemas; module MyNamespace
1122
1078
  end
1123
1079
 
1124
1080
  # @override
1125
- def to_h
1081
+ def as_json(_opts={})
1126
1082
  {
1127
1083
  'id' => @id,
1128
1084
  'widget_id' => @widget_id,
@@ -1135,7 +1091,7 @@ module Schemas; module MyNamespace
1135
1091
  end; end
1136
1092
 
1137
1093
 
1138
- spec/app/lib/schema_classes/my-namespace/widget_the_second.rb:
1094
+ spec/app/lib/schema_classes/my_namespace/widget_the_second.rb:
1139
1095
  # frozen_string_literal: true
1140
1096
 
1141
1097
  # This file is autogenerated by Deimos, Do NOT modify
@@ -1181,7 +1137,7 @@ module Schemas; module MyNamespace
1181
1137
  end
1182
1138
 
1183
1139
  # @override
1184
- def to_h
1140
+ def as_json(_opts={})
1185
1141
  {
1186
1142
  'id' => @id,
1187
1143
  'widget_id' => @widget_id,
@@ -1224,7 +1180,7 @@ module Schemas; module Request
1224
1180
  end
1225
1181
 
1226
1182
  # @override
1227
- def to_h
1183
+ def as_json(_opts={})
1228
1184
  {
1229
1185
  'request_id' => @request_id
1230
1186
  }
@@ -1263,7 +1219,7 @@ module Schemas; module Request
1263
1219
  end
1264
1220
 
1265
1221
  # @override
1266
- def to_h
1222
+ def as_json(_opts={})
1267
1223
  {
1268
1224
  'request_id' => @request_id
1269
1225
  }
@@ -1302,7 +1258,7 @@ module Schemas; module Request
1302
1258
  end
1303
1259
 
1304
1260
  # @override
1305
- def to_h
1261
+ def as_json(_opts={})
1306
1262
  {
1307
1263
  'update_request_id' => @update_request_id
1308
1264
  }
@@ -1341,7 +1297,7 @@ module Schemas; module Response
1341
1297
  end
1342
1298
 
1343
1299
  # @override
1344
- def to_h
1300
+ def as_json(_opts={})
1345
1301
  {
1346
1302
  'response_id' => @response_id
1347
1303
  }
@@ -1380,7 +1336,7 @@ module Schemas; module Response
1380
1336
  end
1381
1337
 
1382
1338
  # @override
1383
- def to_h
1339
+ def as_json(_opts={})
1384
1340
  {
1385
1341
  'response_id' => @response_id
1386
1342
  }
@@ -1419,7 +1375,7 @@ module Schemas; module Response
1419
1375
  end
1420
1376
 
1421
1377
  # @override
1422
- def to_h
1378
+ def as_json(_opts={})
1423
1379
  {
1424
1380
  'update_response_id' => @update_response_id
1425
1381
  }