ruby-kafka 0.6.2 → 0.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/kafka/broker.rb +6 -0
- data/lib/kafka/client.rb +21 -1
- data/lib/kafka/cluster.rb +7 -0
- data/lib/kafka/fetcher.rb +4 -5
- data/lib/kafka/protocol.rb +3 -0
- data/lib/kafka/protocol/describe_groups_request.rb +27 -0
- data/lib/kafka/protocol/describe_groups_response.rb +73 -0
- data/lib/kafka/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b311a24cc8c5a81b7f0e7f930f4e0d28488d14ecaec2456ca482ac86889c3344
|
|
4
|
+
data.tar.gz: 8315a0b6b22bb4b7ef9393af789101508091b84ae895fb3a80250ba68ce61118
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f1e7818c5276401f556a093e746c811d13f31c056d0c9f415bd5ef91ce38bbe50b7f9b1849ed5529c9e3e134261d147a89e27d10f31d268d8bb1e6335178a17
|
|
7
|
+
data.tar.gz: 5d79aa51abd414624f79e1f6d64a110ff57ee0adb289503a2862d383b1b9e73344718224d93f54fef0f59ffda004a845111626cb03b9c8d8623a47797159afc7
|
data/CHANGELOG.md
CHANGED
data/lib/kafka/broker.rb
CHANGED
data/lib/kafka/client.rb
CHANGED
|
@@ -277,8 +277,19 @@ module Kafka
|
|
|
277
277
|
# than the session window.
|
|
278
278
|
# @param offset_retention_time [Integer] the time period that committed
|
|
279
279
|
# offsets will be retained, in seconds. Defaults to the broker setting.
|
|
280
|
+
# @param fetcher_max_queue_size [Integer] max number of items in the fetch queue that
|
|
281
|
+
# are stored for further processing. Note, that each item in the queue represents a
|
|
282
|
+
# response from a single broker.
|
|
280
283
|
# @return [Consumer]
|
|
281
|
-
def consumer(
|
|
284
|
+
def consumer(
|
|
285
|
+
group_id:,
|
|
286
|
+
session_timeout: 30,
|
|
287
|
+
offset_commit_interval: 10,
|
|
288
|
+
offset_commit_threshold: 0,
|
|
289
|
+
heartbeat_interval: 10,
|
|
290
|
+
offset_retention_time: nil,
|
|
291
|
+
fetcher_max_queue_size: 100
|
|
292
|
+
)
|
|
282
293
|
cluster = initialize_cluster
|
|
283
294
|
|
|
284
295
|
instrumenter = DecoratingInstrumenter.new(@instrumenter, {
|
|
@@ -301,6 +312,7 @@ module Kafka
|
|
|
301
312
|
cluster: initialize_cluster,
|
|
302
313
|
logger: @logger,
|
|
303
314
|
instrumenter: instrumenter,
|
|
315
|
+
max_queue_size: fetcher_max_queue_size
|
|
304
316
|
)
|
|
305
317
|
|
|
306
318
|
offset_manager = OffsetManager.new(
|
|
@@ -540,6 +552,14 @@ module Kafka
|
|
|
540
552
|
@cluster.alter_topic(name, configs)
|
|
541
553
|
end
|
|
542
554
|
|
|
555
|
+
# Describe a consumer group
|
|
556
|
+
#
|
|
557
|
+
# @param group_id [String] the id of the consumer group
|
|
558
|
+
# @return [Kafka::Protocol::DescribeGroupsResponse::Group]
|
|
559
|
+
def describe_group(group_id)
|
|
560
|
+
@cluster.describe_group(group_id)
|
|
561
|
+
end
|
|
562
|
+
|
|
543
563
|
# Create partitions for a topic.
|
|
544
564
|
#
|
|
545
565
|
# @param name [String] the name of the topic.
|
data/lib/kafka/cluster.rb
CHANGED
|
@@ -255,6 +255,13 @@ module Kafka
|
|
|
255
255
|
nil
|
|
256
256
|
end
|
|
257
257
|
|
|
258
|
+
def describe_group(group_id)
|
|
259
|
+
response = get_group_coordinator(group_id: group_id).describe_groups(group_ids: [group_id])
|
|
260
|
+
group = response.groups.first
|
|
261
|
+
Protocol.handle_error(group.error_code)
|
|
262
|
+
group
|
|
263
|
+
end
|
|
264
|
+
|
|
258
265
|
def create_partitions_for(name, num_partitions:, timeout:)
|
|
259
266
|
options = {
|
|
260
267
|
topics: [[name, num_partitions, nil]],
|
data/lib/kafka/fetcher.rb
CHANGED
|
@@ -4,14 +4,13 @@ require "kafka/fetch_operation"
|
|
|
4
4
|
|
|
5
5
|
module Kafka
|
|
6
6
|
class Fetcher
|
|
7
|
-
MAX_QUEUE_SIZE = 100
|
|
8
|
-
|
|
9
7
|
attr_reader :queue
|
|
10
8
|
|
|
11
|
-
def initialize(cluster:, logger:, instrumenter:)
|
|
9
|
+
def initialize(cluster:, logger:, instrumenter:, max_queue_size:)
|
|
12
10
|
@cluster = cluster
|
|
13
11
|
@logger = logger
|
|
14
12
|
@instrumenter = instrumenter
|
|
13
|
+
@max_queue_size = max_queue_size
|
|
15
14
|
|
|
16
15
|
@queue = Queue.new
|
|
17
16
|
@commands = Queue.new
|
|
@@ -89,10 +88,10 @@ module Kafka
|
|
|
89
88
|
send("handle_#{cmd}", *args)
|
|
90
89
|
elsif !@running
|
|
91
90
|
sleep 0.1
|
|
92
|
-
elsif @queue.size <
|
|
91
|
+
elsif @queue.size < @max_queue_size
|
|
93
92
|
step
|
|
94
93
|
else
|
|
95
|
-
@logger.warn "Reached max fetcher queue size (#{
|
|
94
|
+
@logger.warn "Reached max fetcher queue size (#{@max_queue_size}), sleeping 1s"
|
|
96
95
|
sleep 1
|
|
97
96
|
end
|
|
98
97
|
end
|
data/lib/kafka/protocol.rb
CHANGED
|
@@ -25,6 +25,7 @@ module Kafka
|
|
|
25
25
|
HEARTBEAT_API = 12
|
|
26
26
|
LEAVE_GROUP_API = 13
|
|
27
27
|
SYNC_GROUP_API = 14
|
|
28
|
+
DESCRIBE_GROUPS_API = 15
|
|
28
29
|
LIST_GROUPS_API = 16
|
|
29
30
|
SASL_HANDSHAKE_API = 17
|
|
30
31
|
API_VERSIONS_API = 18
|
|
@@ -180,3 +181,5 @@ require "kafka/protocol/create_partitions_request"
|
|
|
180
181
|
require "kafka/protocol/create_partitions_response"
|
|
181
182
|
require "kafka/protocol/list_groups_request"
|
|
182
183
|
require "kafka/protocol/list_groups_response"
|
|
184
|
+
require "kafka/protocol/describe_groups_request"
|
|
185
|
+
require "kafka/protocol/describe_groups_response"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kafka
|
|
4
|
+
module Protocol
|
|
5
|
+
class DescribeGroupsRequest
|
|
6
|
+
def initialize(group_ids:)
|
|
7
|
+
@group_ids = group_ids
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def api_key
|
|
11
|
+
DESCRIBE_GROUPS_API
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def api_version
|
|
15
|
+
0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def response_class
|
|
19
|
+
Protocol::DescribeGroupsResponse
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def encode(encoder)
|
|
23
|
+
encoder.write_array(@group_ids) { |group_id| encoder.write_string(group_id) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kafka
|
|
4
|
+
module Protocol
|
|
5
|
+
class DescribeGroupsResponse
|
|
6
|
+
class Group
|
|
7
|
+
attr_reader :error_code, :group_id, :state, :members, :protocol
|
|
8
|
+
|
|
9
|
+
def initialize(error_code:, group_id:, protocol_type:, protocol:, state:, members:)
|
|
10
|
+
@error_code = error_code
|
|
11
|
+
@group_id = group_id
|
|
12
|
+
@protocol_type = protocol_type
|
|
13
|
+
@protocol = protocol
|
|
14
|
+
@state = state
|
|
15
|
+
@members = members
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Member
|
|
20
|
+
attr_reader :member_id, :client_id, :client_host, :member_assignment
|
|
21
|
+
|
|
22
|
+
def initialize(member_id:, client_id:, client_host:, member_assignment:)
|
|
23
|
+
@member_id = member_id
|
|
24
|
+
@client_id = client_id
|
|
25
|
+
@client_host = client_host
|
|
26
|
+
@member_assignment = member_assignment
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
attr_reader :error_code, :groups
|
|
31
|
+
|
|
32
|
+
def initialize(groups:)
|
|
33
|
+
@groups = groups
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.decode(decoder)
|
|
37
|
+
groups = decoder.array do
|
|
38
|
+
error_code = decoder.int16
|
|
39
|
+
group_id = decoder.string
|
|
40
|
+
state = decoder.string
|
|
41
|
+
protocol_type = decoder.string
|
|
42
|
+
protocol = decoder.string
|
|
43
|
+
|
|
44
|
+
members = decoder.array do
|
|
45
|
+
member_id = decoder.string
|
|
46
|
+
client_id = decoder.string
|
|
47
|
+
client_host = decoder.string
|
|
48
|
+
metadata = decoder.bytes
|
|
49
|
+
assignment = MemberAssignment.decode(Decoder.from_string(decoder.bytes))
|
|
50
|
+
|
|
51
|
+
Member.new(
|
|
52
|
+
member_id: member_id,
|
|
53
|
+
client_id: client_id,
|
|
54
|
+
client_host: client_host,
|
|
55
|
+
member_assignment: assignment
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Group.new(
|
|
60
|
+
error_code: error_code,
|
|
61
|
+
group_id: group_id,
|
|
62
|
+
state: state,
|
|
63
|
+
protocol_type: protocol_type,
|
|
64
|
+
protocol: protocol,
|
|
65
|
+
members: members
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
new(groups: groups)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/kafka/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-kafka
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Schierbeck
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-05-
|
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -351,6 +351,8 @@ files:
|
|
|
351
351
|
- lib/kafka/protocol/delete_topics_response.rb
|
|
352
352
|
- lib/kafka/protocol/describe_configs_request.rb
|
|
353
353
|
- lib/kafka/protocol/describe_configs_response.rb
|
|
354
|
+
- lib/kafka/protocol/describe_groups_request.rb
|
|
355
|
+
- lib/kafka/protocol/describe_groups_response.rb
|
|
354
356
|
- lib/kafka/protocol/encoder.rb
|
|
355
357
|
- lib/kafka/protocol/fetch_request.rb
|
|
356
358
|
- lib/kafka/protocol/fetch_response.rb
|