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.
- checksums.yaml +4 -4
- data/spec/bps/kafka_spec.rb +25 -32
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2947d6ee7913a2387a4300320a5fd44b4b4db096311b4da117a51f620ca44efe
|
4
|
+
data.tar.gz: faa0f01af5368aa0c2544a0eac7f7a5b59655b0885e3a1c3f5c623a784e2838b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e820bed323b80633f620312a2070c33c492dda643c7308bdb8869d63cfc8772a66e6e2bfe29a2968c201c854af15eb694fb1250f17cb24c01af1cf7b1f2451f4
|
7
|
+
data.tar.gz: 3ae553795c664b966e347e2009ff1a0ef9741f9b6932afc79ed13677a29b355b0184a72be0b446c7bd079f9d32537bd748e12ee247291f103fa5bd8020cbdfa0
|
data/spec/bps/kafka_spec.rb
CHANGED
@@ -1,33 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'bps/kafka'
|
3
3
|
|
4
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
68
|
-
|
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.
|
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-
|
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.
|
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.
|
26
|
+
version: 0.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-kafka
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|