ruby-kafka 0.5.0.beta4 → 0.5.0.beta5
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 +1 -0
- data/lib/kafka/connection.rb +1 -1
- data/lib/kafka/consumer.rb +1 -0
- data/lib/kafka/fetched_message.rb +1 -1
- data/lib/kafka/socket_with_timeout.rb +16 -3
- data/lib/kafka/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '049f2fa2e6a04ff652cffe3ed630dbfe69e87009'
|
4
|
+
data.tar.gz: ed051c1dbb21aaac9360e58c74fca58d7706a76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08b01eb42a5082deac74cd5ff3136aa50ec16ac34c5ec4818d5a3722b9b46273b3601bd355073d3165c8917a9daf51356a43ff5ec97eceedbfcc6e0450018b79'
|
7
|
+
data.tar.gz: 16114b7e4abe72d82f3ae37cc0cfba4cbfdf798073adc04f1eaea892ac64eed2d96b66f093df1e2b3f1c6ac40f7a5b87146efadbed888d46a32abc4113e1f289
|
data/CHANGELOG.md
CHANGED
@@ -9,6 +9,7 @@ Changes and additions to the library will be listed here.
|
|
9
9
|
- Drops support for Kafka 0.9 in favor of Kafka 0.10 (#381)!
|
10
10
|
- Handle cases where there are no partitions to fetch from by sleeping a bit (#439).
|
11
11
|
- Handle problems with the broker cache (#440).
|
12
|
+
- Shut down more quickly (#438).
|
12
13
|
|
13
14
|
## v0.4.3
|
14
15
|
|
data/lib/kafka/connection.rb
CHANGED
@@ -109,7 +109,7 @@ module Kafka
|
|
109
109
|
|
110
110
|
response
|
111
111
|
end
|
112
|
-
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, EOFError => e
|
112
|
+
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ESHUTDOWN, EOFError => e
|
113
113
|
close
|
114
114
|
|
115
115
|
raise ConnectionError, "Connection error: #{e}"
|
data/lib/kafka/consumer.rb
CHANGED
@@ -19,7 +19,7 @@ module Kafka
|
|
19
19
|
# @return [Time] the timestamp of the message.
|
20
20
|
attr_reader :create_time
|
21
21
|
|
22
|
-
def initialize(value
|
22
|
+
def initialize(value: nil, key: nil, topic:, partition:, offset:, create_time: nil)
|
23
23
|
@value = value
|
24
24
|
@key = key
|
25
25
|
@topic = topic
|
@@ -24,6 +24,9 @@ module Kafka
|
|
24
24
|
|
25
25
|
@timeout = timeout
|
26
26
|
|
27
|
+
# This pipe is used to cancel IO.select calls when sockets are closed.
|
28
|
+
@cancel_reader, @cancel_writer = IO.pipe
|
29
|
+
|
27
30
|
@socket = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)
|
28
31
|
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
29
32
|
|
@@ -57,11 +60,20 @@ module Kafka
|
|
57
60
|
# @raise [Errno::ETIMEDOUT] if the timeout is exceeded.
|
58
61
|
# @return [String] the data that was read from the socket.
|
59
62
|
def read(num_bytes)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
+
rs, _, _ = IO.select([@socket, @cancel_reader], nil, nil, @timeout)
|
64
|
+
|
65
|
+
# The read timed out.
|
66
|
+
raise Errno::ETIMEDOUT if rs.nil?
|
67
|
+
|
68
|
+
# The socket has been closed.
|
69
|
+
raise Errno::ECONNABORTED if rs.include?(@cancel_reader)
|
63
70
|
|
64
71
|
@socket.read(num_bytes)
|
72
|
+
rescue Errno::EBADF
|
73
|
+
# We'll get EBADF if `select` is called with a closed socket, or
|
74
|
+
# if it's closed in the middle of things.
|
75
|
+
raise Errno::ESHUTDOWN if @socket.closed?
|
76
|
+
raise
|
65
77
|
rescue IO::EAGAINWaitReadable
|
66
78
|
retry
|
67
79
|
end
|
@@ -80,6 +92,7 @@ module Kafka
|
|
80
92
|
end
|
81
93
|
|
82
94
|
def close
|
95
|
+
@cancel_writer.puts
|
83
96
|
@socket.close
|
84
97
|
end
|
85
98
|
|
data/lib/kafka/version.rb
CHANGED