bps-kafka 0.1.2 → 0.2.2

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
  SHA256:
3
- metadata.gz: 2947d6ee7913a2387a4300320a5fd44b4b4db096311b4da117a51f620ca44efe
4
- data.tar.gz: faa0f01af5368aa0c2544a0eac7f7a5b59655b0885e3a1c3f5c623a784e2838b
3
+ metadata.gz: 87d68617ad58c810d307efe2f1142306a502eea59098070fa70d1b40a13f49f3
4
+ data.tar.gz: f3d4e4de9ed30b41b8d546c7ef885498c265104ac3ded18dc40cd1e0f45278aa
5
5
  SHA512:
6
- metadata.gz: e820bed323b80633f620312a2070c33c492dda643c7308bdb8869d63cfc8772a66e6e2bfe29a2968c201c854af15eb694fb1250f17cb24c01af1cf7b1f2451f4
7
- data.tar.gz: 3ae553795c664b966e347e2009ff1a0ef9741f9b6932afc79ed13677a29b355b0184a72be0b446c7bd079f9d32537bd748e12ee247291f103fa5bd8020cbdfa0
6
+ metadata.gz: 07bc1b7e4b2c9779489e95375a15cb84015514d25322d8dde2ac5c1a2461f0eb427ae8f53c1cb3695b03ef16fa1f592c51d77b922bc7104f8a785f36ecfa431d
7
+ data.tar.gz: 2b8e3aa881a745f9f9b240b27d890acd1948733080664ddabd25030bffdc4a9b25e0841a8e817be72b48c7168579c9fe0cd42f08fb81e70902e6655ea7ea862b
@@ -93,6 +93,8 @@ module BPS
93
93
  end
94
94
 
95
95
  def close
96
+ super
97
+
96
98
  @producer.shutdown
97
99
  @client.close
98
100
  end
@@ -102,7 +104,7 @@ module BPS
102
104
  def parse_url(url)
103
105
  port = url.port&.to_s || '9092'
104
106
  CGI.unescape(url.host).split(',').map do |addr|
105
- addr << ':' << port unless addr.match(/:\d+$/)
107
+ addr << ':' << port unless /:\d+$/.match?(addr)
106
108
  addr
107
109
  end
108
110
  end
@@ -14,10 +14,10 @@ module BPS
14
14
  # @param [Hash] opts the options.
15
15
  # @option opts [Integer] :max_queue_size (defaults to: 1000)
16
16
  # the maximum number of messages allowed in the queue.
17
- # @option opts [Integer] :delivery_threshold (defaults to: 0)
17
+ # @option opts [Integer] :delivery_threshold (defaults to: 1000)
18
18
  # if greater than zero, the number of buffered messages that will automatically
19
19
  # trigger a delivery.
20
- # @option opts [Integer] :delivery_interval (defaults to: 0) if greater than zero, the number of
20
+ # @option opts [Integer] :delivery_interval (defaults to: 30) if greater than zero, the number of
21
21
  # seconds between automatic message deliveries.
22
22
  def initialize(broker_addrs, **opts) # rubocop:disable Lint/UselessMethodDefinition
23
23
  super
@@ -25,7 +25,7 @@ module BPS
25
25
 
26
26
  private
27
27
 
28
- def init_producer(max_queue_size: 1000, delivery_threshold: 0, delivery_interval: 0)
28
+ def init_producer(max_queue_size: 1000, delivery_threshold: 1000, delivery_interval: 30)
29
29
  @client.async_producer(
30
30
  max_queue_size: max_queue_size,
31
31
  delivery_threshold: delivery_threshold,
@@ -2,33 +2,34 @@ require 'spec_helper'
2
2
  require 'bps/kafka'
3
3
 
4
4
  RSpec.describe 'Kafka', kafka: true do
5
- context 'resolve addrs' do
6
- let(:client) { double('Kafka', producer: nil) }
5
+ context 'with addr resolving' do
6
+ let(:client) { instance_double(::Kafka::Client, producer: nil) }
7
+
7
8
  before { allow(::Kafka).to receive(:new).and_return(client) }
8
9
 
9
- it 'should resolve simple URLs' do
10
+ it 'resolves simple URLs' do
10
11
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
11
- expect(::Kafka).to receive(:new).with(['test.host:9092'], {}).and_return(client)
12
+ allow(::Kafka).to receive(:new).with(['test.host:9092'], {}).and_return(client)
12
13
  else
13
- expect(::Kafka).to receive(:new).with(['test.host:9092']).and_return(client)
14
+ allow(::Kafka).to receive(:new).with(['test.host:9092']).and_return(client)
14
15
  end
15
16
  BPS::Publisher.resolve(URI.parse('kafka+sync://test.host:9092'))
16
17
  end
17
18
 
18
- it 'should resolve URLs with multiple hosts' do
19
+ it 'resolves URLs with multiple hosts' do
19
20
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
20
- expect(::Kafka).to receive(:new).with(['foo.host:9092', 'bar.host:9092'], {}).and_return(client)
21
+ allow(::Kafka).to receive(:new).with(['foo.host:9092', 'bar.host:9092'], {}).and_return(client)
21
22
  else
22
- expect(::Kafka).to receive(:new).with(['foo.host:9092', 'bar.host:9092']).and_return(client)
23
+ allow(::Kafka).to receive(:new).with(['foo.host:9092', 'bar.host:9092']).and_return(client)
23
24
  end
24
25
  BPS::Publisher.resolve(URI.parse('kafka+sync://foo.host,bar.host:9092'))
25
26
  end
26
27
 
27
- it 'should resolve URLs with multiple hosts/ports' do
28
+ it 'resolves URLs with multiple hosts/ports' do
28
29
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7')
29
- expect(::Kafka).to receive(:new).with(['foo.host:9093', 'bar.host:9092'], {}).and_return(client)
30
+ allow(::Kafka).to receive(:new).with(['foo.host:9093', 'bar.host:9092'], {}).and_return(client)
30
31
  else
31
- expect(::Kafka).to receive(:new).with(['foo.host:9093', 'bar.host:9092']).and_return(client)
32
+ allow(::Kafka).to receive(:new).with(['foo.host:9093', 'bar.host:9092']).and_return(client)
32
33
  end
33
34
  BPS::Publisher.resolve(URI.parse('kafka+sync://foo.host%3A9093,bar.host'))
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bps-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bps
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: 0.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: 0.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-kafka
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.1.2
72
+ rubygems_version: 3.2.15
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Kafka adapter for bps