ruby-kafka 0.3.15 → 0.3.16.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +9 -6
- data/README.md +1 -1
- data/lib/kafka/client.rb +5 -6
- data/lib/kafka/datadog.rb +6 -2
- data/lib/kafka/ssl_socket_with_timeout.rb +37 -12
- data/lib/kafka/version.rb +1 -1
- data/ruby-kafka.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b67d149d2ec1a2e2099aebc3372e5519d9085c
|
4
|
+
data.tar.gz: b77bdd543fe069d3758227e649834125abd60fc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b41d4f4a6620e75eb4d9416d4255ca99c05ff36c98e7c350b57a7deb045a68b8028efb43e6510f54dc43294af0ac1d7738d1c7b481240895212b6df1e25d53a
|
7
|
+
data.tar.gz: aba814998139f29f69205669045b765dd1031cb0e35749603b6063d000d8d091e910e110cd2927804ec2f986432e9b411d78fbd75d40a72fba93e08597d89c06
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ Changes and additions to the library will be listed here.
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## v0.3.16.beta1
|
8
|
+
|
9
|
+
- Fix SSL socket timeout (#283).
|
10
|
+
- Update to the latest Datadog gem (#296).
|
11
|
+
- Automatically detect private key type (#297).
|
12
|
+
|
7
13
|
## v0.3.15
|
8
14
|
|
9
15
|
- Allow setting a timeout on a partition pause (#272).
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby-kafka (0.3.15
|
4
|
+
ruby-kafka (0.3.15)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -17,12 +17,12 @@ GEM
|
|
17
17
|
coderay (1.1.0)
|
18
18
|
colored (1.2)
|
19
19
|
diff-lcs (1.2.5)
|
20
|
-
docker-api (1.
|
20
|
+
docker-api (1.32.1)
|
21
21
|
excon (>= 0.38.0)
|
22
22
|
json
|
23
|
-
dogstatsd-ruby (1.
|
23
|
+
dogstatsd-ruby (2.1.0)
|
24
24
|
dotenv (2.1.0)
|
25
|
-
excon (0.
|
25
|
+
excon (0.54.0)
|
26
26
|
i18n (0.7.0)
|
27
27
|
json (1.8.3)
|
28
28
|
method_source (0.8.2)
|
@@ -67,7 +67,7 @@ DEPENDENCIES
|
|
67
67
|
bundler (>= 1.9.5)
|
68
68
|
colored
|
69
69
|
docker-api
|
70
|
-
dogstatsd-ruby
|
70
|
+
dogstatsd-ruby (>= 2.0.0)
|
71
71
|
dotenv
|
72
72
|
pry
|
73
73
|
rake (~> 10.0)
|
@@ -79,5 +79,8 @@ DEPENDENCIES
|
|
79
79
|
snappy
|
80
80
|
timecop
|
81
81
|
|
82
|
+
RUBY VERSION
|
83
|
+
ruby 2.2.3p173
|
84
|
+
|
82
85
|
BUNDLED WITH
|
83
|
-
1.
|
86
|
+
1.13.6
|
data/README.md
CHANGED
@@ -626,7 +626,7 @@ By default, nothing is logged.
|
|
626
626
|
|
627
627
|
### Instrumentation
|
628
628
|
|
629
|
-
Most operations are instrumented using [Active Support Notifications](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html). In order to subscribe to notifications, make sure to require the notifications library
|
629
|
+
Most operations are instrumented using [Active Support Notifications](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html). In order to subscribe to notifications, make sure to require the notifications library:
|
630
630
|
|
631
631
|
```ruby
|
632
632
|
require "active_support/notifications"
|
data/lib/kafka/client.rb
CHANGED
@@ -437,7 +437,7 @@ module Kafka
|
|
437
437
|
if client_cert && client_cert_key
|
438
438
|
ssl_context.set_params(
|
439
439
|
cert: OpenSSL::X509::Certificate.new(client_cert),
|
440
|
-
key: OpenSSL::PKey
|
440
|
+
key: OpenSSL::PKey.read(client_cert_key)
|
441
441
|
)
|
442
442
|
elsif client_cert && !client_cert_key
|
443
443
|
raise ArgumentError, "Kafka client initialized with `ssl_client_cert` but no `ssl_client_cert_key`. Please provide both."
|
@@ -458,14 +458,13 @@ module Kafka
|
|
458
458
|
if seed_brokers.is_a?(String)
|
459
459
|
seed_brokers = seed_brokers.split(",")
|
460
460
|
end
|
461
|
-
|
462
|
-
seed_brokers.
|
463
|
-
connection
|
461
|
+
|
462
|
+
seed_brokers.map do |connection|
|
463
|
+
connection = "kafka://" + connection unless connection =~ /:\/\//
|
464
464
|
uri = URI.parse(connection)
|
465
465
|
uri.port ||= 9092 # Default Kafka port.
|
466
|
-
|
466
|
+
uri
|
467
467
|
end
|
468
|
-
brokers
|
469
468
|
end
|
470
469
|
end
|
471
470
|
end
|
data/lib/kafka/datadog.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
begin
|
2
|
-
require "statsd"
|
2
|
+
require "datadog/statsd"
|
3
3
|
rescue LoadError
|
4
4
|
$stderr.puts "In order to report Kafka client metrics to Datadog you need to install the `dogstatsd-ruby` gem."
|
5
5
|
raise
|
@@ -28,7 +28,7 @@ module Kafka
|
|
28
28
|
STATSD_NAMESPACE = "ruby_kafka"
|
29
29
|
|
30
30
|
def self.statsd
|
31
|
-
@statsd ||= Statsd.new(Statsd::DEFAULT_HOST, Statsd::DEFAULT_HOST, namespace: STATSD_NAMESPACE)
|
31
|
+
@statsd ||= ::Datadog::Statsd.new(::Datadog::Statsd::DEFAULT_HOST, ::Datadog::Statsd::DEFAULT_HOST, namespace: STATSD_NAMESPACE)
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.host=(host)
|
@@ -43,6 +43,10 @@ module Kafka
|
|
43
43
|
statsd.namespace = namespace
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.tags=(tags)
|
47
|
+
statsd.tags = tags
|
48
|
+
end
|
49
|
+
|
46
50
|
class StatsdSubscriber < ActiveSupport::Subscriber
|
47
51
|
private
|
48
52
|
|
@@ -23,6 +23,7 @@ module Kafka
|
|
23
23
|
addr = Socket.getaddrinfo(host, nil)
|
24
24
|
sockaddr = Socket.pack_sockaddr_in(port, addr[0][3])
|
25
25
|
|
26
|
+
@connect_timeout = connect_timeout
|
26
27
|
@timeout = timeout
|
27
28
|
|
28
29
|
@tcp_socket = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)
|
@@ -35,10 +36,10 @@ module Kafka
|
|
35
36
|
# indicating the connection is in progress.
|
36
37
|
@tcp_socket.connect_nonblock(sockaddr)
|
37
38
|
rescue IO::WaitWritable
|
38
|
-
#
|
39
|
+
# select will block until the socket is writable or the timeout
|
39
40
|
# is exceeded, whichever comes first.
|
40
|
-
unless
|
41
|
-
#
|
41
|
+
unless select_with_timeout(@tcp_socket, :connect_write)
|
42
|
+
# select returns nil when the socket is not ready before timeout
|
42
43
|
# seconds have elapsed
|
43
44
|
@tcp_socket.close
|
44
45
|
raise Errno::ETIMEDOUT
|
@@ -64,11 +65,20 @@ module Kafka
|
|
64
65
|
# Instead, you have to retry.
|
65
66
|
@ssl_socket.connect_nonblock
|
66
67
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
|
67
|
-
|
68
|
-
|
68
|
+
if select_with_timeout(@ssl_socket, :connect_read)
|
69
|
+
retry
|
70
|
+
else
|
71
|
+
@ssl_socket.close
|
72
|
+
close
|
73
|
+
raise Errno::ETIMEDOUT
|
74
|
+
end
|
69
75
|
rescue IO::WaitWritable
|
70
|
-
|
71
|
-
|
76
|
+
if select_with_timeout(@ssl_socket, :connect_write)
|
77
|
+
retry
|
78
|
+
else
|
79
|
+
close
|
80
|
+
raise Errno::ETIMEDOUT
|
81
|
+
end
|
72
82
|
end
|
73
83
|
end
|
74
84
|
|
@@ -88,15 +98,17 @@ module Kafka
|
|
88
98
|
# our read buffer.
|
89
99
|
buffer << @ssl_socket.read_nonblock(num_bytes - buffer.length)
|
90
100
|
rescue IO::WaitReadable
|
91
|
-
|
101
|
+
if select_with_timeout(@ssl_socket, :read)
|
102
|
+
retry
|
103
|
+
else
|
92
104
|
raise Errno::ETIMEDOUT
|
93
105
|
end
|
94
|
-
retry
|
95
106
|
rescue IO::WaitWritable
|
96
|
-
|
107
|
+
if select_with_timeout(@ssl_socket, :write)
|
108
|
+
retry
|
109
|
+
else
|
97
110
|
raise Errno::ETIMEDOUT
|
98
111
|
end
|
99
|
-
retry
|
100
112
|
end
|
101
113
|
end
|
102
114
|
buffer
|
@@ -121,7 +133,7 @@ module Kafka
|
|
121
133
|
raise error
|
122
134
|
rescue OpenSSL::SSL::SSLError, Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitWritable => error
|
123
135
|
if error.is_a?(OpenSSL::SSL::SSLError) && error.message == 'write would block'
|
124
|
-
if
|
136
|
+
if select_with_timeout(@ssl_socket, :write)
|
125
137
|
retry
|
126
138
|
else
|
127
139
|
raise Errno::ETIMEDOUT
|
@@ -154,5 +166,18 @@ module Kafka
|
|
154
166
|
def set_encoding(encoding)
|
155
167
|
@tcp_socket.set_encoding(encoding)
|
156
168
|
end
|
169
|
+
|
170
|
+
def select_with_timeout(socket, type)
|
171
|
+
case type
|
172
|
+
when :connect_read
|
173
|
+
IO.select([socket], nil, nil, @connect_timeout)
|
174
|
+
when :connect_write
|
175
|
+
IO.select(nil, [socket], nil, @connect_timeout)
|
176
|
+
when :read
|
177
|
+
IO.select([socket], nil, nil, @timeout)
|
178
|
+
when :write
|
179
|
+
IO.select(nil, [socket], nil, @timeout)
|
180
|
+
end
|
181
|
+
end
|
157
182
|
end
|
158
183
|
end
|
data/lib/kafka/version.rb
CHANGED
data/ruby-kafka.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "snappy"
|
39
39
|
spec.add_development_dependency "colored"
|
40
40
|
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
41
|
-
spec.add_development_dependency "dogstatsd-ruby"
|
41
|
+
spec.add_development_dependency "dogstatsd-ruby", ">= 2.0.0"
|
42
42
|
spec.add_development_dependency "ruby-prof"
|
43
43
|
spec.add_development_dependency "timecop"
|
44
44
|
end
|
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.3.
|
4
|
+
version: 0.3.16.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 2.0.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 2.0.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: ruby-prof
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,9 +317,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
317
317
|
version: 2.1.0
|
318
318
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
319
|
requirements:
|
320
|
-
- - "
|
320
|
+
- - ">"
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version:
|
322
|
+
version: 1.3.1
|
323
323
|
requirements: []
|
324
324
|
rubyforge_project:
|
325
325
|
rubygems_version: 2.4.5.1
|