ruby-kafka 0.5.0.beta4 → 0.5.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a79f7b7fd4484721c6ec49e2f43ddde653fe512
4
- data.tar.gz: ab46aedab7380f46ae94d643b2c120e4b77d2f40
3
+ metadata.gz: '049f2fa2e6a04ff652cffe3ed630dbfe69e87009'
4
+ data.tar.gz: ed051c1dbb21aaac9360e58c74fca58d7706a76a
5
5
  SHA512:
6
- metadata.gz: d94eab42cfda6905b8b694ea1dfab99b5cf272771c08dab81db32c334816f0aee3f751f0c28c32f029f6401175ae86636114f62f5867a06c9eca479ad309aec5
7
- data.tar.gz: f0b9e5b9ccb765dbca5df8b43aa39d1fe39a624e6172f80cd81f0ceb5acb6616be99df2f334f2a19070147199d74397fc8d0d7bc76c999c3258f373ae210c0d4
6
+ metadata.gz: '08b01eb42a5082deac74cd5ff3136aa50ec16ac34c5ec4818d5a3722b9b46273b3601bd355073d3165c8917a9daf51356a43ff5ec97eceedbfcc6e0450018b79'
7
+ data.tar.gz: 16114b7e4abe72d82f3ae37cc0cfba4cbfdf798073adc04f1eaea892ac64eed2d96b66f093df1e2b3f1c6ac40f7a5b87146efadbed888d46a32abc4113e1f289
@@ -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
 
@@ -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}"
@@ -94,6 +94,7 @@ module Kafka
94
94
  # @return [nil]
95
95
  def stop
96
96
  @running = false
97
+ @cluster.disconnect
97
98
  end
98
99
 
99
100
  # Pause processing of a specific topic partition.
@@ -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:, key:, topic:, partition:, offset:, create_time:)
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
- unless IO.select([@socket], nil, nil, @timeout)
61
- raise Errno::ETIMEDOUT
62
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module Kafka
2
- VERSION = "0.5.0.beta4"
2
+ VERSION = "0.5.0.beta5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta4
4
+ version: 0.5.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck