bps-kafka 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/spec/bps/kafka_spec.rb +25 -32
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc71e376289d57e6341560ddefd86c3c44d77b5fe3963ca658bfa44c4124d31f
4
- data.tar.gz: 9ac605f652d7ec7a4a2f3f6460e476d6639b705021ad064240ea8cc2ac03f51b
3
+ metadata.gz: 2947d6ee7913a2387a4300320a5fd44b4b4db096311b4da117a51f620ca44efe
4
+ data.tar.gz: faa0f01af5368aa0c2544a0eac7f7a5b59655b0885e3a1c3f5c623a784e2838b
5
5
  SHA512:
6
- metadata.gz: f7d2cc289e5d7f82ce2dba5538b7f071f5259ee7fd9f9077cf0a2334d157a2bcf00d4b787a86fc733142e1ff17ce7b7f2bfcc1f4db761825de6492d53825eb51
7
- data.tar.gz: dfdb6747738ed57a359e71cd4455203c3da130d8ec31516ddfaf6b4e93f08e1f1f51d74d304ca8d3dfc99a83906c9acb3be540acb83aacf81a0b2e1eefda5561
6
+ metadata.gz: e820bed323b80633f620312a2070c33c492dda643c7308bdb8869d63cfc8772a66e6e2bfe29a2968c201c854af15eb694fb1250f17cb24c01af1cf7b1f2451f4
7
+ data.tar.gz: 3ae553795c664b966e347e2009ff1a0ef9741f9b6932afc79ed13677a29b355b0184a72be0b446c7bd079f9d32537bd748e12ee247291f103fa5bd8020cbdfa0
@@ -1,33 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'bps/kafka'
3
3
 
4
- def kafka_addrs
5
- ENV.fetch('KAFKA_ADDRS', '127.0.0.1:9092').split(',').freeze
6
- end
7
-
8
- run_spec = \
9
- begin
10
- ::Kafka.new(kafka_addrs).brokers
11
- true
12
- rescue StandardError => e
13
- warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
14
- false
15
- end
16
-
17
- helper = proc do
18
- def read_messages(topic_name, num_messages)
19
- client = ::Kafka.new(kafka_addrs)
20
- Enumerator.new do |y|
21
- client.each_message(topic: topic_name, start_from_beginning: true) do |msg|
22
- y << msg.value
23
- end
24
- end.take(num_messages)
25
- ensure
26
- client&.close
27
- end
28
- end
29
-
30
- RSpec.describe 'Kafka' do
4
+ RSpec.describe 'Kafka', kafka: true do
31
5
  context 'resolve addrs' do
32
6
  let(:client) { double('Kafka', producer: nil) }
33
7
  before { allow(::Kafka).to receive(:new).and_return(client) }
@@ -60,11 +34,30 @@ RSpec.describe 'Kafka' do
60
34
  end
61
35
  end
62
36
 
63
- context BPS::Publisher::Kafka, if: run_spec do
64
- it_behaves_like 'publisher', url: "kafka+sync://#{CGI.escape(kafka_addrs.join(','))}/", &helper
65
- end
37
+ describe 'publishers' do
38
+ let(:kafka_addrs) { ENV.fetch('KAFKA_ADDRS', '127.0.0.1:9092').split(',') }
39
+
40
+ def read_messages(topic_name, num_messages)
41
+ client = ::Kafka.new(kafka_addrs)
42
+ Enumerator.new do |y|
43
+ client.each_message(topic: topic_name, start_from_beginning: true) do |msg|
44
+ y << msg.value
45
+ end
46
+ end.take(num_messages)
47
+ ensure
48
+ client&.close
49
+ end
66
50
 
67
- context BPS::Publisher::KafkaAsync, if: run_spec do
68
- it_behaves_like 'publisher', url: "kafka://#{CGI.escape(kafka_addrs.join(','))}/", &helper
51
+ context BPS::Publisher::Kafka do
52
+ let(:publisher_url) { "kafka+sync://#{CGI.escape(kafka_addrs.join(','))}/" }
53
+
54
+ it_behaves_like 'publisher'
55
+ end
56
+
57
+ context BPS::Publisher::KafkaAsync do
58
+ let(:publisher_url) { "kafka://#{CGI.escape(kafka_addrs.join(','))}/" }
59
+
60
+ it_behaves_like 'publisher'
61
+ end
69
62
  end
70
63
  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.1
4
+ version: 0.1.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-10-02 00:00:00.000000000 Z
11
+ date: 2020-11-09 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.1
19
+ version: 0.1.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.1
26
+ version: 0.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-kafka
29
29
  requirement: !ruby/object:Gem::Requirement