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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e781eb534c5c2ee94905fe5665270df1d688689
4
- data.tar.gz: a95297b844741019599e14bae2ca7afa34304538
3
+ metadata.gz: 84b67d149d2ec1a2e2099aebc3372e5519d9085c
4
+ data.tar.gz: b77bdd543fe069d3758227e649834125abd60fc2
5
5
  SHA512:
6
- metadata.gz: f3d32a672b934ccaa48e49b2af92220d2bc7d435a642e43b1161f0a57e419f495c4a569c738cc85a24c0c719da608284164f9f83e96ba2a46c06e13e436d2700
7
- data.tar.gz: 5283ffa3ba2f5968acf24ae73eb5b300ad38dd78907a8524e22d5d45e4ba20ac9caaa9efd6458cf7fddca3b897c1f6ff7344efd7bf55536b178c9c427e669854
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.beta2)
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.25.0)
20
+ docker-api (1.32.1)
21
21
  excon (>= 0.38.0)
22
22
  json
23
- dogstatsd-ruby (1.6.0)
23
+ dogstatsd-ruby (2.1.0)
24
24
  dotenv (2.1.0)
25
- excon (0.45.4)
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.10.6
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 _before_ you require ruby-kafka, e.g.
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::RSA.new(client_cert_key)
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
- brokers = []
462
- seed_brokers.each do |connection|
463
- connection.prepend("kafka://") unless 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
- brokers << uri
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
- # IO.select will block until the socket is writable or the timeout
39
+ # select will block until the socket is writable or the timeout
39
40
  # is exceeded, whichever comes first.
40
- unless IO.select(nil, [@tcp_socket], nil, connect_timeout)
41
- # IO.select returns nil when the socket is not ready before timeout
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
- IO.select([@ssl_socket])
68
- retry
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
- IO.select(nil, [@ssl_socket])
71
- retry
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
- unless IO.select([@ssl_socket], nil, nil, @timeout)
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
- unless IO.select(nil, [@ssl_socket], nil, @timeout)
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 IO.select(nil, [@ssl_socket], nil, @timeout)
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
@@ -1,3 +1,3 @@
1
1
  module Kafka
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16.beta1"
3
3
  end
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.15
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-09-12 00:00:00.000000000 Z
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: '0'
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: '0'
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: '0'
322
+ version: 1.3.1
323
323
  requirements: []
324
324
  rubyforge_project:
325
325
  rubygems_version: 2.4.5.1