karafka-rdkafka 0.20.0-arm64-darwin

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 (102) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODEOWNERS +3 -0
  3. data/.github/FUNDING.yml +1 -0
  4. data/.github/workflows/ci_linux_x86_64_gnu.yml +249 -0
  5. data/.github/workflows/ci_linux_x86_64_musl.yml +205 -0
  6. data/.github/workflows/ci_macos_arm64.yml +306 -0
  7. data/.github/workflows/push_linux_x86_64_gnu.yml +64 -0
  8. data/.github/workflows/push_linux_x86_64_musl.yml +77 -0
  9. data/.github/workflows/push_macos_arm64.yml +54 -0
  10. data/.github/workflows/push_ruby.yml +37 -0
  11. data/.github/workflows/verify-action-pins.yml +16 -0
  12. data/.gitignore +15 -0
  13. data/.rspec +2 -0
  14. data/.ruby-gemset +1 -0
  15. data/.ruby-version +1 -0
  16. data/.yardopts +2 -0
  17. data/CHANGELOG.md +330 -0
  18. data/Gemfile +5 -0
  19. data/MIT-LICENSE +22 -0
  20. data/README.md +177 -0
  21. data/Rakefile +96 -0
  22. data/docker-compose.yml +25 -0
  23. data/ext/README.md +19 -0
  24. data/ext/Rakefile +131 -0
  25. data/ext/build_common.sh +361 -0
  26. data/ext/build_linux_x86_64_gnu.sh +306 -0
  27. data/ext/build_linux_x86_64_musl.sh +763 -0
  28. data/ext/build_macos_arm64.sh +550 -0
  29. data/ext/librdkafka.dylib +0 -0
  30. data/karafka-rdkafka.gemspec +88 -0
  31. data/lib/rdkafka/abstract_handle.rb +116 -0
  32. data/lib/rdkafka/admin/acl_binding_result.rb +51 -0
  33. data/lib/rdkafka/admin/config_binding_result.rb +30 -0
  34. data/lib/rdkafka/admin/config_resource_binding_result.rb +18 -0
  35. data/lib/rdkafka/admin/create_acl_handle.rb +28 -0
  36. data/lib/rdkafka/admin/create_acl_report.rb +24 -0
  37. data/lib/rdkafka/admin/create_partitions_handle.rb +30 -0
  38. data/lib/rdkafka/admin/create_partitions_report.rb +6 -0
  39. data/lib/rdkafka/admin/create_topic_handle.rb +32 -0
  40. data/lib/rdkafka/admin/create_topic_report.rb +24 -0
  41. data/lib/rdkafka/admin/delete_acl_handle.rb +30 -0
  42. data/lib/rdkafka/admin/delete_acl_report.rb +23 -0
  43. data/lib/rdkafka/admin/delete_groups_handle.rb +28 -0
  44. data/lib/rdkafka/admin/delete_groups_report.rb +24 -0
  45. data/lib/rdkafka/admin/delete_topic_handle.rb +32 -0
  46. data/lib/rdkafka/admin/delete_topic_report.rb +24 -0
  47. data/lib/rdkafka/admin/describe_acl_handle.rb +30 -0
  48. data/lib/rdkafka/admin/describe_acl_report.rb +24 -0
  49. data/lib/rdkafka/admin/describe_configs_handle.rb +33 -0
  50. data/lib/rdkafka/admin/describe_configs_report.rb +48 -0
  51. data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +33 -0
  52. data/lib/rdkafka/admin/incremental_alter_configs_report.rb +48 -0
  53. data/lib/rdkafka/admin.rb +832 -0
  54. data/lib/rdkafka/bindings.rb +584 -0
  55. data/lib/rdkafka/callbacks.rb +415 -0
  56. data/lib/rdkafka/config.rb +398 -0
  57. data/lib/rdkafka/consumer/headers.rb +79 -0
  58. data/lib/rdkafka/consumer/message.rb +86 -0
  59. data/lib/rdkafka/consumer/partition.rb +57 -0
  60. data/lib/rdkafka/consumer/topic_partition_list.rb +190 -0
  61. data/lib/rdkafka/consumer.rb +663 -0
  62. data/lib/rdkafka/error.rb +201 -0
  63. data/lib/rdkafka/helpers/oauth.rb +58 -0
  64. data/lib/rdkafka/helpers/time.rb +14 -0
  65. data/lib/rdkafka/metadata.rb +115 -0
  66. data/lib/rdkafka/native_kafka.rb +139 -0
  67. data/lib/rdkafka/producer/delivery_handle.rb +48 -0
  68. data/lib/rdkafka/producer/delivery_report.rb +45 -0
  69. data/lib/rdkafka/producer/partitions_count_cache.rb +216 -0
  70. data/lib/rdkafka/producer.rb +497 -0
  71. data/lib/rdkafka/version.rb +7 -0
  72. data/lib/rdkafka.rb +54 -0
  73. data/renovate.json +92 -0
  74. data/spec/rdkafka/abstract_handle_spec.rb +117 -0
  75. data/spec/rdkafka/admin/create_acl_handle_spec.rb +56 -0
  76. data/spec/rdkafka/admin/create_acl_report_spec.rb +18 -0
  77. data/spec/rdkafka/admin/create_topic_handle_spec.rb +54 -0
  78. data/spec/rdkafka/admin/create_topic_report_spec.rb +16 -0
  79. data/spec/rdkafka/admin/delete_acl_handle_spec.rb +85 -0
  80. data/spec/rdkafka/admin/delete_acl_report_spec.rb +72 -0
  81. data/spec/rdkafka/admin/delete_topic_handle_spec.rb +54 -0
  82. data/spec/rdkafka/admin/delete_topic_report_spec.rb +16 -0
  83. data/spec/rdkafka/admin/describe_acl_handle_spec.rb +85 -0
  84. data/spec/rdkafka/admin/describe_acl_report_spec.rb +73 -0
  85. data/spec/rdkafka/admin_spec.rb +970 -0
  86. data/spec/rdkafka/bindings_spec.rb +198 -0
  87. data/spec/rdkafka/callbacks_spec.rb +20 -0
  88. data/spec/rdkafka/config_spec.rb +258 -0
  89. data/spec/rdkafka/consumer/headers_spec.rb +73 -0
  90. data/spec/rdkafka/consumer/message_spec.rb +139 -0
  91. data/spec/rdkafka/consumer/partition_spec.rb +57 -0
  92. data/spec/rdkafka/consumer/topic_partition_list_spec.rb +248 -0
  93. data/spec/rdkafka/consumer_spec.rb +1296 -0
  94. data/spec/rdkafka/error_spec.rb +95 -0
  95. data/spec/rdkafka/metadata_spec.rb +79 -0
  96. data/spec/rdkafka/native_kafka_spec.rb +130 -0
  97. data/spec/rdkafka/producer/delivery_handle_spec.rb +60 -0
  98. data/spec/rdkafka/producer/delivery_report_spec.rb +25 -0
  99. data/spec/rdkafka/producer/partitions_count_cache_spec.rb +359 -0
  100. data/spec/rdkafka/producer_spec.rb +1528 -0
  101. data/spec/spec_helper.rb +195 -0
  102. metadata +275 -0
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Rdkafka::Consumer::Partition do
4
+ let(:offset) { 100 }
5
+ let(:err) { 0 }
6
+ subject { Rdkafka::Consumer::Partition.new(1, offset, err) }
7
+
8
+ it "should have a partition" do
9
+ expect(subject.partition).to eq 1
10
+ end
11
+
12
+ it "should have an offset" do
13
+ expect(subject.offset).to eq 100
14
+ end
15
+
16
+ it "should have an err code" do
17
+ expect(subject.err).to eq 0
18
+ end
19
+
20
+ describe "#to_s" do
21
+ it "should return a human readable representation" do
22
+ expect(subject.to_s).to eq "<Partition 1 offset=100>"
23
+ end
24
+ end
25
+
26
+ describe "#inspect" do
27
+ it "should return a human readable representation" do
28
+ expect(subject.to_s).to eq "<Partition 1 offset=100>"
29
+ end
30
+
31
+ context "without offset" do
32
+ let(:offset) { nil }
33
+
34
+ it "should return a human readable representation" do
35
+ expect(subject.to_s).to eq "<Partition 1>"
36
+ end
37
+ end
38
+
39
+ context "with err code" do
40
+ let(:err) { 1 }
41
+
42
+ it "should return a human readable representation" do
43
+ expect(subject.to_s).to eq "<Partition 1 offset=100 err=1>"
44
+ end
45
+ end
46
+ end
47
+
48
+ describe "#==" do
49
+ it "should equal another partition with the same content" do
50
+ expect(subject).to eq Rdkafka::Consumer::Partition.new(1, 100)
51
+ end
52
+
53
+ it "should not equal another partition with different content" do
54
+ expect(subject).not_to eq Rdkafka::Consumer::Partition.new(2, 101)
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,248 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Rdkafka::Consumer::TopicPartitionList do
4
+ it "should create a new list and add unassigned topics" do
5
+ list = Rdkafka::Consumer::TopicPartitionList.new
6
+
7
+ expect(list.count).to eq 0
8
+ expect(list.empty?).to be true
9
+
10
+ list.add_topic("topic1")
11
+ list.add_topic("topic2")
12
+
13
+ expect(list.count).to eq 2
14
+ expect(list.empty?).to be false
15
+
16
+ hash = list.to_h
17
+ expect(hash.count).to eq 2
18
+ expect(hash).to eq ({
19
+ "topic1" => nil,
20
+ "topic2" => nil
21
+ })
22
+ end
23
+
24
+ it "should create a new list and add assigned topics as a range" do
25
+ list = Rdkafka::Consumer::TopicPartitionList.new
26
+
27
+ expect(list.count).to eq 0
28
+ expect(list.empty?).to be true
29
+
30
+ list.add_topic("topic1", (0..2))
31
+ list.add_topic("topic2", (0..1))
32
+
33
+ expect(list.count).to eq 5
34
+ expect(list.empty?).to be false
35
+
36
+ hash = list.to_h
37
+ expect(hash.count).to eq 2
38
+ expect(hash["topic1"]).to eq([
39
+ Rdkafka::Consumer::Partition.new(0, nil),
40
+ Rdkafka::Consumer::Partition.new(1, nil),
41
+ Rdkafka::Consumer::Partition.new(2, nil)
42
+ ])
43
+ expect(hash["topic2"]).to eq([
44
+ Rdkafka::Consumer::Partition.new(0, nil),
45
+ Rdkafka::Consumer::Partition.new(1, nil)
46
+ ])
47
+ end
48
+
49
+ it "should create a new list and add assigned topics as an array" do
50
+ list = Rdkafka::Consumer::TopicPartitionList.new
51
+
52
+ expect(list.count).to eq 0
53
+ expect(list.empty?).to be true
54
+
55
+ list.add_topic("topic1", [0, 1, 2])
56
+ list.add_topic("topic2", [0, 1])
57
+
58
+ expect(list.count).to eq 5
59
+ expect(list.empty?).to be false
60
+
61
+ hash = list.to_h
62
+ expect(hash.count).to eq 2
63
+ expect(hash["topic1"]).to eq([
64
+ Rdkafka::Consumer::Partition.new(0, nil),
65
+ Rdkafka::Consumer::Partition.new(1, nil),
66
+ Rdkafka::Consumer::Partition.new(2, nil)
67
+ ])
68
+ expect(hash["topic2"]).to eq([
69
+ Rdkafka::Consumer::Partition.new(0, nil),
70
+ Rdkafka::Consumer::Partition.new(1, nil)
71
+ ])
72
+ end
73
+
74
+ it "should create a new list and add assigned topics as a count" do
75
+ list = Rdkafka::Consumer::TopicPartitionList.new
76
+
77
+ expect(list.count).to eq 0
78
+ expect(list.empty?).to be true
79
+
80
+ list.add_topic("topic1", 3)
81
+ list.add_topic("topic2", 2)
82
+
83
+ expect(list.count).to eq 5
84
+ expect(list.empty?).to be false
85
+
86
+ hash = list.to_h
87
+ expect(hash.count).to eq 2
88
+ expect(hash["topic1"]).to eq([
89
+ Rdkafka::Consumer::Partition.new(0, nil),
90
+ Rdkafka::Consumer::Partition.new(1, nil),
91
+ Rdkafka::Consumer::Partition.new(2, nil)
92
+ ])
93
+ expect(hash["topic2"]).to eq([
94
+ Rdkafka::Consumer::Partition.new(0, nil),
95
+ Rdkafka::Consumer::Partition.new(1, nil)
96
+ ])
97
+ end
98
+
99
+ it "should create a new list and add topics and partitions with an offset" do
100
+ list = Rdkafka::Consumer::TopicPartitionList.new
101
+
102
+ expect(list.count).to eq 0
103
+ expect(list.empty?).to be true
104
+
105
+ list.add_topic_and_partitions_with_offsets("topic1", 0 => 5, 1 => 6, 2 => 7)
106
+
107
+ hash = list.to_h
108
+ expect(hash.count).to eq 1
109
+ expect(hash["topic1"]).to eq([
110
+ Rdkafka::Consumer::Partition.new(0, 5),
111
+ Rdkafka::Consumer::Partition.new(1, 6),
112
+ Rdkafka::Consumer::Partition.new(2, 7)
113
+ ])
114
+ end
115
+
116
+ describe "#to_s" do
117
+ let(:expected) do
118
+ if RUBY_VERSION >= '3.4.0'
119
+ "<TopicPartitionList: {\"topic1\" => [<Partition 0>, <Partition 1>]}>"
120
+ else
121
+ "<TopicPartitionList: {\"topic1\"=>[<Partition 0>, <Partition 1>]}>"
122
+ end
123
+ end
124
+
125
+ it "should return a human readable representation" do
126
+ list = Rdkafka::Consumer::TopicPartitionList.new
127
+ list.add_topic("topic1", [0, 1])
128
+
129
+ expect(list.to_s).to eq expected
130
+ end
131
+ end
132
+
133
+ describe "#==" do
134
+ subject do
135
+ Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
136
+ list.add_topic("topic1", [0])
137
+ end
138
+ end
139
+
140
+ it "should equal another partition with the same content" do
141
+ other = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
142
+ list.add_topic("topic1", [0])
143
+ end
144
+ expect(subject).to eq other
145
+ end
146
+
147
+ it "should not equal another partition with different content" do
148
+ expect(subject).not_to eq Rdkafka::Consumer::TopicPartitionList.new
149
+ end
150
+ end
151
+
152
+ describe ".from_native_tpl" do
153
+ it "should create a list from an existing native list" do
154
+ pointer = Rdkafka::Bindings.rd_kafka_topic_partition_list_new(5)
155
+ Rdkafka::Bindings.rd_kafka_topic_partition_list_add(
156
+ pointer,
157
+ "topic",
158
+ -1
159
+ )
160
+ list = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(pointer)
161
+
162
+ other = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
163
+ list.add_topic("topic")
164
+ end
165
+
166
+ expect(list).to eq other
167
+ end
168
+
169
+ it "should create a list from an existing native list with offsets" do
170
+ pointer = Rdkafka::Bindings.rd_kafka_topic_partition_list_new(5)
171
+ Rdkafka::Bindings.rd_kafka_topic_partition_list_add(
172
+ pointer,
173
+ "topic",
174
+ 0
175
+ )
176
+ Rdkafka::Bindings.rd_kafka_topic_partition_list_set_offset(
177
+ pointer,
178
+ "topic",
179
+ 0,
180
+ 100
181
+ )
182
+ list = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(pointer)
183
+
184
+ other = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
185
+ list.add_topic_and_partitions_with_offsets("topic", 0 => 100)
186
+ end
187
+
188
+ expect(list).to eq other
189
+ end
190
+ end
191
+
192
+ describe "#to_native_tpl" do
193
+ it "should create a native list" do
194
+ list = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
195
+ list.add_topic("topic")
196
+ end
197
+
198
+ tpl = list.to_native_tpl
199
+
200
+ other = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(tpl)
201
+
202
+ expect(list).to eq other
203
+ end
204
+
205
+ it "should create a native list with partitions" do
206
+ list = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
207
+ list.add_topic("topic", 0..16)
208
+ end
209
+
210
+ tpl = list.to_native_tpl
211
+
212
+ other = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(tpl)
213
+
214
+ expect(list).to eq other
215
+ end
216
+
217
+ it "should create a native list with offsets" do
218
+ list = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
219
+ list.add_topic_and_partitions_with_offsets("topic", 0 => 100)
220
+ end
221
+
222
+ tpl = list.to_native_tpl
223
+
224
+ other = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(tpl)
225
+
226
+ expect(list).to eq other
227
+ end
228
+
229
+ it "should create a native list with timetamp offsets if offsets are Time" do
230
+ list = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
231
+ list.add_topic_and_partitions_with_offsets("topic", 0 => Time.at(1505069646, 250_000))
232
+ end
233
+
234
+ tpl = list.to_native_tpl
235
+
236
+ compare_list = Rdkafka::Consumer::TopicPartitionList.new.tap do |list|
237
+ list.add_topic_and_partitions_with_offsets(
238
+ "topic",
239
+ 0 => (Time.at(1505069646, 250_000).to_f * 1000).floor
240
+ )
241
+ end
242
+
243
+ native_list = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(tpl)
244
+
245
+ expect(native_list).to eq compare_list
246
+ end
247
+ end
248
+ end