deimos-ruby 1.16.1 → 1.16.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +13 -0
  4. data/Gemfile +6 -0
  5. data/README.md +22 -0
  6. data/lib/deimos/active_record_consume/batch_consumption.rb +7 -2
  7. data/lib/deimos/active_record_consume/batch_slicer.rb +2 -0
  8. data/lib/deimos/active_record_consume/message_consumption.rb +8 -4
  9. data/lib/deimos/active_record_consumer.rb +7 -4
  10. data/lib/deimos/active_record_producer.rb +10 -0
  11. data/lib/deimos/backends/base.rb +4 -2
  12. data/lib/deimos/backends/kafka.rb +1 -0
  13. data/lib/deimos/backends/kafka_async.rb +1 -0
  14. data/lib/deimos/config/configuration.rb +4 -0
  15. data/lib/deimos/config/phobos_config.rb +2 -1
  16. data/lib/deimos/consume/batch_consumption.rb +8 -1
  17. data/lib/deimos/consume/message_consumption.rb +4 -1
  18. data/lib/deimos/instrumentation.rb +11 -4
  19. data/lib/deimos/kafka_message.rb +1 -0
  20. data/lib/deimos/kafka_source.rb +5 -0
  21. data/lib/deimos/kafka_topic_info.rb +4 -0
  22. data/lib/deimos/message.rb +19 -2
  23. data/lib/deimos/metrics/datadog.rb +2 -1
  24. data/lib/deimos/metrics/mock.rb +2 -2
  25. data/lib/deimos/metrics/provider.rb +6 -0
  26. data/lib/deimos/monkey_patches/phobos_cli.rb +1 -1
  27. data/lib/deimos/monkey_patches/phobos_producer.rb +1 -0
  28. data/lib/deimos/producer.rb +12 -6
  29. data/lib/deimos/schema_backends/base.rb +31 -17
  30. data/lib/deimos/schema_backends/mock.rb +2 -2
  31. data/lib/deimos/schema_class/base.rb +9 -5
  32. data/lib/deimos/schema_class/enum.rb +4 -2
  33. data/lib/deimos/schema_class/record.rb +12 -6
  34. data/lib/deimos/shared_config.rb +6 -2
  35. data/lib/deimos/test_helpers.rb +21 -4
  36. data/lib/deimos/tracing/datadog.rb +1 -1
  37. data/lib/deimos/tracing/mock.rb +4 -3
  38. data/lib/deimos/tracing/provider.rb +5 -0
  39. data/lib/deimos/utils/db_poller.rb +9 -1
  40. data/lib/deimos/utils/db_producer.rb +14 -2
  41. data/lib/deimos/utils/deadlock_retry.rb +3 -0
  42. data/lib/deimos/utils/inline_consumer.rb +14 -6
  43. data/lib/deimos/utils/lag_reporter.rb +11 -0
  44. data/lib/deimos/utils/schema_controller_mixin.rb +8 -0
  45. data/lib/deimos/version.rb +1 -1
  46. data/lib/deimos.rb +3 -2
  47. data/lib/generators/deimos/active_record_generator.rb +1 -1
  48. data/lib/generators/deimos/db_backend_generator.rb +1 -0
  49. data/lib/generators/deimos/db_poller_generator.rb +1 -0
  50. data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +13 -5
  51. data/lib/generators/deimos/schema_class_generator.rb +51 -24
  52. data/rbs_collection.lock.yaml +176 -0
  53. data/rbs_collection.yaml +15 -0
  54. data/regenerate_test_schema_classes.rb +68 -0
  55. data/sig/avro.rbs +14 -0
  56. data/sig/defs.rbs +1859 -0
  57. data/sig/fig_tree.rbs +2 -0
  58. data/spec/active_record_producer_spec.rb +24 -0
  59. data/spec/generators/schema_class/my_schema_spec.rb +16 -0
  60. data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +1 -1
  61. data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +32 -24
  62. data/spec/producer_spec.rb +11 -11
  63. data/spec/schemas/{generated.rb → my_namespace/generated.rb} +28 -32
  64. data/spec/schemas/{my_nested_schema.rb → my_namespace/my_nested_schema.rb} +23 -16
  65. data/spec/schemas/{my_schema.rb → my_namespace/my_schema.rb} +12 -5
  66. data/spec/schemas/my_namespace/my_schema_compound_key.rb +41 -0
  67. data/spec/schemas/my_namespace/my_schema_id_key.rb +36 -0
  68. data/spec/schemas/{my_schema_key.rb → my_namespace/my_schema_key.rb} +3 -3
  69. data/spec/schemas/my_namespace/my_schema_with_boolean.rb +41 -0
  70. data/spec/schemas/{my_schema_with_circular_reference.rb → my_namespace/my_schema_with_circular_reference.rb} +15 -10
  71. data/spec/schemas/{my_schema_with_complex_type.rb → my_namespace/my_schema_with_complex_type.rb} +34 -49
  72. data/spec/schemas/my_namespace/my_schema_with_date_time.rb +56 -0
  73. data/spec/schemas/my_namespace/my_schema_with_id.rb +51 -0
  74. data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +56 -0
  75. data/spec/schemas/my_namespace/wibble.rb +76 -0
  76. data/spec/schemas/my_namespace/widget.rb +56 -0
  77. data/spec/schemas/my_namespace/widget_the_second.rb +56 -0
  78. data/spec/schemas/request/create_topic.rb +36 -0
  79. data/spec/schemas/request/index.rb +36 -0
  80. data/spec/schemas/request/update_request.rb +36 -0
  81. data/spec/schemas/response/create_topic.rb +36 -0
  82. data/spec/schemas/response/index.rb +36 -0
  83. data/spec/schemas/response/update_response.rb +36 -0
  84. data/spec/snapshots/consumers-no-nest.snap +93 -86
  85. data/spec/snapshots/consumers.snap +94 -87
  86. data/spec/snapshots/consumers_and_producers-no-nest.snap +108 -87
  87. data/spec/snapshots/consumers_and_producers.snap +109 -88
  88. data/spec/snapshots/consumers_circular-no-nest.snap +93 -86
  89. data/spec/snapshots/consumers_circular.snap +94 -87
  90. data/spec/snapshots/consumers_complex_types-no-nest.snap +93 -86
  91. data/spec/snapshots/consumers_complex_types.snap +94 -87
  92. data/spec/snapshots/consumers_nested-no-nest.snap +93 -86
  93. data/spec/snapshots/consumers_nested.snap +94 -87
  94. data/spec/snapshots/namespace_folders.snap +111 -90
  95. data/spec/snapshots/producers_with_key-no-nest.snap +94 -87
  96. data/spec/snapshots/producers_with_key.snap +95 -88
  97. data/spec/spec_helper.rb +2 -1
  98. metadata +53 -15
@@ -8,7 +8,7 @@ module Schemas
8
8
  class CreateTopic < Deimos::SchemaClass::Record
9
9
 
10
10
  ### Attribute Accessors ###
11
- # @param value [String]
11
+ # @return [String]
12
12
  attr_accessor :response_id
13
13
 
14
14
  # @override
@@ -51,7 +51,7 @@ module Schemas
51
51
  class ARecord < Deimos::SchemaClass::Record
52
52
 
53
53
  ### Attribute Accessors ###
54
- # @param value [String]
54
+ # @return [String]
55
55
  attr_accessor :a_record_field
56
56
 
57
57
  # @override
@@ -97,34 +97,34 @@ module Schemas
97
97
  attr_reader :a_record
98
98
 
99
99
  ### Attribute Accessors ###
100
- # @param value [String]
100
+ # @return [String]
101
101
  attr_accessor :a_string
102
- # @param value [Integer]
102
+ # @return [Integer]
103
103
  attr_accessor :a_int
104
- # @param value [Integer]
104
+ # @return [Integer]
105
105
  attr_accessor :a_long
106
- # @param value [Float]
106
+ # @return [Float]
107
107
  attr_accessor :a_float
108
- # @param value [Float]
108
+ # @return [Float]
109
109
  attr_accessor :a_double
110
- # @param value [nil, Integer]
110
+ # @return [nil, Integer]
111
111
  attr_accessor :an_optional_int
112
- # @param values [Array<Integer>]
112
+ # @return [Array<Integer>]
113
113
  attr_accessor :an_array
114
- # @param values [Hash<String, String>]
114
+ # @return [Hash<String, String>]
115
115
  attr_accessor :a_map
116
- # @param value [String]
116
+ # @return [String]
117
117
  attr_accessor :timestamp
118
- # @param value [String]
118
+ # @return [String]
119
119
  attr_accessor :message_id
120
120
 
121
121
  ### Attribute Writers ###
122
- # @param value [AnEnum]
122
+ # @return [AnEnum]
123
123
  def an_enum=(value)
124
124
  @an_enum = AnEnum.initialize_from_value(value)
125
125
  end
126
126
 
127
- # @param value [ARecord]
127
+ # @return [ARecord]
128
128
  def a_record=(value)
129
129
  @a_record = ARecord.initialize_from_value(value)
130
130
  end
@@ -198,7 +198,7 @@ module Schemas
198
198
  class Index < Deimos::SchemaClass::Record
199
199
 
200
200
  ### Attribute Accessors ###
201
- # @param value [String]
201
+ # @return [String]
202
202
  attr_accessor :response_id
203
203
 
204
204
  # @override
@@ -241,13 +241,13 @@ module Schemas
241
241
  class MyNestedRecord < Deimos::SchemaClass::Record
242
242
 
243
243
  ### Attribute Accessors ###
244
- # @param value [Integer]
244
+ # @return [Integer]
245
245
  attr_accessor :some_int
246
- # @param value [Float]
246
+ # @return [Float]
247
247
  attr_accessor :some_float
248
- # @param value [String]
248
+ # @return [String]
249
249
  attr_accessor :some_string
250
- # @param value [nil, Integer]
250
+ # @return [nil, Integer]
251
251
  attr_accessor :some_optional_int
252
252
 
253
253
  # @override
@@ -291,20 +291,20 @@ module Schemas
291
291
  attr_reader :some_optional_record
292
292
 
293
293
  ### Attribute Accessors ###
294
- # @param value [String]
294
+ # @return [String]
295
295
  attr_accessor :test_id
296
- # @param value [Float]
296
+ # @return [Float]
297
297
  attr_accessor :test_float
298
- # @param values [Array<String>]
298
+ # @return [Array<String>]
299
299
  attr_accessor :test_array
300
300
 
301
301
  ### Attribute Writers ###
302
- # @param value [MyNestedRecord]
302
+ # @return [MyNestedRecord]
303
303
  def some_nested_record=(value)
304
304
  @some_nested_record = MyNestedRecord.initialize_from_value(value)
305
305
  end
306
306
 
307
- # @param value [nil, MyNestedRecord]
307
+ # @return [nil, MyNestedRecord]
308
308
  def some_optional_record=(value)
309
309
  @some_optional_record = MyNestedRecord.initialize_from_value(value)
310
310
  end
@@ -357,9 +357,9 @@ module Schemas
357
357
  class MySchema < Deimos::SchemaClass::Record
358
358
 
359
359
  ### Attribute Accessors ###
360
- # @param value [String]
360
+ # @return [String]
361
361
  attr_accessor :test_id
362
- # @param value [Integer]
362
+ # @return [Integer]
363
363
  attr_accessor :some_int
364
364
 
365
365
  # @override
@@ -401,9 +401,9 @@ module Schemas
401
401
  class MySchemaCompoundKey < Deimos::SchemaClass::Record
402
402
 
403
403
  ### Attribute Accessors ###
404
- # @param value [String]
404
+ # @return [String]
405
405
  attr_accessor :part_one
406
- # @param value [String]
406
+ # @return [String]
407
407
  attr_accessor :part_two
408
408
 
409
409
  # @override
@@ -445,7 +445,7 @@ module Schemas
445
445
  class MySchemaIdKey < Deimos::SchemaClass::Record
446
446
 
447
447
  ### Attribute Accessors ###
448
- # @param value [Integer]
448
+ # @return [Integer]
449
449
  attr_accessor :id
450
450
 
451
451
  # @override
@@ -484,7 +484,7 @@ module Schemas
484
484
  class MySchemaKey < Deimos::SchemaClass::Record
485
485
 
486
486
  ### Attribute Accessors ###
487
- # @param value [String]
487
+ # @return [String]
488
488
  attr_accessor :test_id
489
489
 
490
490
  # @override
@@ -523,9 +523,9 @@ module Schemas
523
523
  class MySchemaWithBoolean < Deimos::SchemaClass::Record
524
524
 
525
525
  ### Attribute Accessors ###
526
- # @param value [String]
526
+ # @return [String]
527
527
  attr_accessor :test_id
528
- # @param value [Boolean]
528
+ # @return [Boolean]
529
529
  attr_accessor :some_bool
530
530
 
531
531
  # @override
@@ -571,7 +571,7 @@ module Schemas
571
571
  class Property < Deimos::SchemaClass::Record
572
572
 
573
573
  ### Attribute Accessors ###
574
- # @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
574
+ # @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
575
575
  attr_accessor :property
576
576
 
577
577
  # @override
@@ -604,9 +604,9 @@ module Schemas
604
604
  attr_reader :properties
605
605
 
606
606
  ### Attribute Writers ###
607
- # @param values [Hash<String, Property>]
607
+ # @return [Hash<String, Property>]
608
608
  def properties=(values)
609
- @properties = values.transform_values do |value|
609
+ @properties = values&.transform_values do |value|
610
610
  Property.initialize_from_value(value)
611
611
  end
612
612
  end
@@ -627,6 +627,13 @@ module Schemas
627
627
  'com.my-namespace'
628
628
  end
629
629
 
630
+ def self.tombstone(key)
631
+ record = self.allocate
632
+ record.tombstone_key = key
633
+ record.a_string = key
634
+ record
635
+ end
636
+
630
637
  # @override
631
638
  def as_json(_opts={})
632
639
  {
@@ -651,7 +658,7 @@ module Schemas
651
658
  class ARecord < Deimos::SchemaClass::Record
652
659
 
653
660
  ### Attribute Accessors ###
654
- # @param value [String]
661
+ # @return [String]
655
662
  attr_accessor :a_record_field
656
663
 
657
664
  # @override
@@ -729,57 +736,57 @@ module Schemas
729
736
  attr_reader :some_enum_with_default
730
737
 
731
738
  ### Attribute Accessors ###
732
- # @param value [String]
739
+ # @return [String]
733
740
  attr_accessor :test_id
734
- # @param value [Float]
741
+ # @return [Float]
735
742
  attr_accessor :test_float
736
- # @param values [Array<String>]
743
+ # @return [Array<String>]
737
744
  attr_accessor :test_string_array
738
- # @param values [Array<Integer>]
745
+ # @return [Array<Integer>]
739
746
  attr_accessor :test_int_array
740
- # @param value [Integer, nil]
747
+ # @return [Integer, nil]
741
748
  attr_accessor :test_optional_int
742
- # @param values [Hash<String, Integer>]
749
+ # @return [Hash<String, Integer>]
743
750
  attr_accessor :some_integer_map
744
751
 
745
752
  ### Attribute Writers ###
746
- # @param value [ARecord]
753
+ # @return [ARecord]
747
754
  def some_record=(value)
748
755
  @some_record = ARecord.initialize_from_value(value)
749
756
  end
750
757
 
751
- # @param value [nil, ARecord]
758
+ # @return [nil, ARecord]
752
759
  def some_optional_record=(value)
753
760
  @some_optional_record = ARecord.initialize_from_value(value)
754
761
  end
755
762
 
756
- # @param values [Array<ARecord>]
763
+ # @return [Array<ARecord>]
757
764
  def some_record_array=(values)
758
- @some_record_array = values.map do |value|
765
+ @some_record_array = values&.map do |value|
759
766
  ARecord.initialize_from_value(value)
760
767
  end
761
768
  end
762
769
 
763
- # @param values [Hash<String, ARecord>]
770
+ # @return [Hash<String, ARecord>]
764
771
  def some_record_map=(values)
765
- @some_record_map = values.transform_values do |value|
772
+ @some_record_map = values&.transform_values do |value|
766
773
  ARecord.initialize_from_value(value)
767
774
  end
768
775
  end
769
776
 
770
- # @param values [Array<AnEnum>]
777
+ # @return [Array<AnEnum>]
771
778
  def some_enum_array=(values)
772
- @some_enum_array = values.map do |value|
779
+ @some_enum_array = values&.map do |value|
773
780
  AnEnum.initialize_from_value(value)
774
781
  end
775
782
  end
776
783
 
777
- # @param value [nil, AnotherEnum]
784
+ # @return [nil, AnotherEnum]
778
785
  def some_optional_enum=(value)
779
786
  @some_optional_enum = AnotherEnum.initialize_from_value(value)
780
787
  end
781
788
 
782
- # @param value [YetAnotherEnum]
789
+ # @return [YetAnotherEnum]
783
790
  def some_enum_with_default=(value)
784
791
  @some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
785
792
  end
@@ -856,15 +863,15 @@ module Schemas
856
863
  class MySchemaWithDateTime < Deimos::SchemaClass::Record
857
864
 
858
865
  ### Attribute Accessors ###
859
- # @param value [String]
866
+ # @return [String]
860
867
  attr_accessor :test_id
861
- # @param value [Integer, nil]
868
+ # @return [Integer, nil]
862
869
  attr_accessor :updated_at
863
- # @param value [nil, Integer]
870
+ # @return [nil, Integer]
864
871
  attr_accessor :some_int
865
- # @param value [nil, Integer]
872
+ # @return [nil, Integer]
866
873
  attr_accessor :some_datetime_int
867
- # @param value [String]
874
+ # @return [String]
868
875
  attr_accessor :timestamp
869
876
 
870
877
  # @override
@@ -915,13 +922,13 @@ module Schemas
915
922
  class MySchemaWithId < Deimos::SchemaClass::Record
916
923
 
917
924
  ### Attribute Accessors ###
918
- # @param value [String]
925
+ # @return [String]
919
926
  attr_accessor :test_id
920
- # @param value [Integer]
927
+ # @return [Integer]
921
928
  attr_accessor :some_int
922
- # @param value [String]
929
+ # @return [String]
923
930
  attr_accessor :message_id
924
- # @param value [String]
931
+ # @return [String]
925
932
  attr_accessor :timestamp
926
933
 
927
934
  # @override
@@ -969,15 +976,15 @@ module Schemas
969
976
  class MySchemaWithUniqueId < Deimos::SchemaClass::Record
970
977
 
971
978
  ### Attribute Accessors ###
972
- # @param value [Integer]
979
+ # @return [Integer]
973
980
  attr_accessor :id
974
- # @param value [String]
981
+ # @return [String]
975
982
  attr_accessor :test_id
976
- # @param value [Integer]
983
+ # @return [Integer]
977
984
  attr_accessor :some_int
978
- # @param value [String]
985
+ # @return [String]
979
986
  attr_accessor :message_id
980
- # @param value [String]
987
+ # @return [String]
981
988
  attr_accessor :timestamp
982
989
 
983
990
  # @override
@@ -1028,7 +1035,7 @@ module Schemas
1028
1035
  class UpdateRequest < Deimos::SchemaClass::Record
1029
1036
 
1030
1037
  ### Attribute Accessors ###
1031
- # @param value [String]
1038
+ # @return [String]
1032
1039
  attr_accessor :update_request_id
1033
1040
 
1034
1041
  # @override
@@ -1067,7 +1074,7 @@ module Schemas
1067
1074
  class UpdateResponse < Deimos::SchemaClass::Record
1068
1075
 
1069
1076
  ### Attribute Accessors ###
1070
- # @param value [String]
1077
+ # @return [String]
1071
1078
  attr_accessor :update_response_id
1072
1079
 
1073
1080
  # @override
@@ -1106,23 +1113,23 @@ module Schemas
1106
1113
  class Wibble < Deimos::SchemaClass::Record
1107
1114
 
1108
1115
  ### Attribute Accessors ###
1109
- # @param value [Integer]
1116
+ # @return [Integer]
1110
1117
  attr_accessor :id
1111
- # @param value [Integer]
1118
+ # @return [Integer]
1112
1119
  attr_accessor :wibble_id
1113
- # @param value [String]
1120
+ # @return [String]
1114
1121
  attr_accessor :name
1115
- # @param value [String]
1122
+ # @return [String]
1116
1123
  attr_accessor :floop
1117
- # @param value [Integer]
1124
+ # @return [Integer]
1118
1125
  attr_accessor :birthday_int
1119
- # @param value [Integer]
1126
+ # @return [Integer]
1120
1127
  attr_accessor :birthday_long
1121
- # @param value [nil, Integer]
1128
+ # @return [nil, Integer]
1122
1129
  attr_accessor :birthday_optional
1123
- # @param value [Integer]
1130
+ # @return [Integer]
1124
1131
  attr_accessor :updated_at
1125
- # @param value [Integer]
1132
+ # @return [Integer]
1126
1133
  attr_accessor :created_at
1127
1134
 
1128
1135
  # @override
@@ -1185,15 +1192,15 @@ module Schemas
1185
1192
  class Widget < Deimos::SchemaClass::Record
1186
1193
 
1187
1194
  ### Attribute Accessors ###
1188
- # @param value [Integer]
1195
+ # @return [Integer]
1189
1196
  attr_accessor :id
1190
- # @param value [Integer]
1197
+ # @return [Integer]
1191
1198
  attr_accessor :widget_id
1192
- # @param value [String]
1199
+ # @return [String]
1193
1200
  attr_accessor :name
1194
- # @param value [Integer]
1201
+ # @return [Integer]
1195
1202
  attr_accessor :updated_at
1196
- # @param value [Integer]
1203
+ # @return [Integer]
1197
1204
  attr_accessor :created_at
1198
1205
 
1199
1206
  # @override
@@ -1244,15 +1251,15 @@ module Schemas
1244
1251
  class WidgetTheSecond < Deimos::SchemaClass::Record
1245
1252
 
1246
1253
  ### Attribute Accessors ###
1247
- # @param value [Integer]
1254
+ # @return [Integer]
1248
1255
  attr_accessor :id
1249
- # @param value [Integer]
1256
+ # @return [Integer]
1250
1257
  attr_accessor :widget_id
1251
- # @param value [String]
1258
+ # @return [String]
1252
1259
  attr_accessor :model_id
1253
- # @param value [Integer]
1260
+ # @return [Integer]
1254
1261
  attr_accessor :updated_at
1255
- # @param value [Integer]
1262
+ # @return [Integer]
1256
1263
  attr_accessor :created_at
1257
1264
 
1258
1265
  # @override