krakow 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +25 -0
- data/LICENSE +13 -0
- data/README.md +62 -9
- data/krakow.gemspec +3 -1
- data/lib/krakow/command/cls.rb +3 -4
- data/lib/krakow/command/fin.rb +13 -4
- data/lib/krakow/command/identify.rb +22 -9
- data/lib/krakow/command/mpub.rb +14 -4
- data/lib/krakow/command/nop.rb +3 -4
- data/lib/krakow/command/pub.rb +15 -5
- data/lib/krakow/command/rdy.rb +13 -4
- data/lib/krakow/command/req.rb +14 -4
- data/lib/krakow/command/sub.rb +14 -4
- data/lib/krakow/command/touch.rb +13 -4
- data/lib/krakow/command.rb +25 -3
- data/lib/krakow/connection.rb +286 -60
- data/lib/krakow/connection_features/deflate.rb +26 -1
- data/lib/krakow/connection_features/snappy_frames.rb +34 -3
- data/lib/krakow/connection_features/ssl.rb +43 -1
- data/lib/krakow/connection_features.rb +1 -0
- data/lib/krakow/consumer.rb +162 -49
- data/lib/krakow/discovery.rb +17 -6
- data/lib/krakow/distribution/default.rb +61 -33
- data/lib/krakow/distribution.rb +107 -57
- data/lib/krakow/exceptions.rb +14 -0
- data/lib/krakow/frame_type/error.rb +13 -7
- data/lib/krakow/frame_type/message.rb +47 -4
- data/lib/krakow/frame_type/response.rb +14 -4
- data/lib/krakow/frame_type.rb +20 -8
- data/lib/krakow/producer/http.rb +95 -6
- data/lib/krakow/producer.rb +60 -17
- data/lib/krakow/utils/lazy.rb +99 -40
- data/lib/krakow/utils/logging.rb +11 -0
- data/lib/krakow/utils.rb +3 -0
- data/lib/krakow/version.rb +3 -1
- data/lib/krakow.rb +1 -0
- metadata +11 -11
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -34
- data/test/spec.rb +0 -81
- data/test/specs/consumer.rb +0 -49
- data/test/specs/http_producer.rb +0 -123
- data/test/specs/producer.rb +0 -20
data/test/specs/http_producer.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
describe Krakow do
|
2
|
-
|
3
|
-
describe Krakow::Producer::Http do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@http = Krakow::Test._http_producer
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should write single messages successfully' do
|
10
|
-
response = @http.write('msg')
|
11
|
-
Krakow::Command::Pub.ok.must_include response.status_txt
|
12
|
-
end
|
13
|
-
it 'should write multiple messages successfully' do
|
14
|
-
response = @http.write('msg1', 'msg2', 'msg3')
|
15
|
-
Krakow::Command::Mpub.ok.must_include response.status_txt
|
16
|
-
end
|
17
|
-
it 'should create topic' do
|
18
|
-
response = @http.create_topic
|
19
|
-
response.status_code.must_equal 200
|
20
|
-
response.status_txt.must_equal 'OK'
|
21
|
-
end
|
22
|
-
it 'should delete topic' do
|
23
|
-
c_response = @http.create_topic
|
24
|
-
c_response.status_code.must_equal 200
|
25
|
-
c_response.status_txt.must_equal 'OK'
|
26
|
-
d_response = @http.delete_topic
|
27
|
-
d_response.status_code.must_equal 200
|
28
|
-
d_response.status_txt.must_equal 'OK'
|
29
|
-
end
|
30
|
-
it 'should create channel' do
|
31
|
-
c_response = @http.create_topic
|
32
|
-
c_response.status_code.must_equal 200
|
33
|
-
c_response.status_txt.must_equal 'OK'
|
34
|
-
ch_response = @http.create_channel('fubar')
|
35
|
-
ch_response.status_code.must_equal 200
|
36
|
-
ch_response.status_txt.must_equal 'OK'
|
37
|
-
end
|
38
|
-
it 'should delete channel' do
|
39
|
-
c_response = @http.create_topic
|
40
|
-
c_response.status_code.must_equal 200
|
41
|
-
c_response.status_txt.must_equal 'OK'
|
42
|
-
ch_response = @http.create_channel('fubar')
|
43
|
-
ch_response.status_code.must_equal 200
|
44
|
-
ch_response.status_txt.must_equal 'OK'
|
45
|
-
dch_response = @http.delete_channel('fubar')
|
46
|
-
dch_response.status_code.must_equal 200
|
47
|
-
dch_response.status_txt.must_equal 'OK'
|
48
|
-
end
|
49
|
-
it 'should empty topic' do
|
50
|
-
@consumer.terminate
|
51
|
-
@http.write('msg1', 'msg2', 'msg3').status_code.must_equal 200
|
52
|
-
et_response = @http.empty_topic
|
53
|
-
et_response.status_code.must_equal 200
|
54
|
-
et_response.status_txt.must_equal 'OK'
|
55
|
-
@consumer = Krakow::Test._consumer
|
56
|
-
sleep(0.2)
|
57
|
-
@consumer.connections.wont_be :empty?
|
58
|
-
@consumer.queue.must_be :empty?
|
59
|
-
end
|
60
|
-
it 'should empty channel' do
|
61
|
-
@consumer.terminate
|
62
|
-
@http.write('msg0')
|
63
|
-
@http.pause_channel('chan2').status_code.must_equal 200
|
64
|
-
consumer1 = Krakow::Test._consumer(:channel => 'chan1')
|
65
|
-
consumer2 = Krakow::Test._consumer(:channel => 'chan2')
|
66
|
-
@http.write('msg1', 'msg2', 'msg3').status_code.must_equal 200
|
67
|
-
sleep(0.5)
|
68
|
-
consumer1.queue.size.must_equal 4
|
69
|
-
consumer2.queue.size.must_equal 0
|
70
|
-
@http.empty_channel('chan2').status_code.must_equal 200
|
71
|
-
@http.unpause_channel('chan2').status_code.must_equal 200
|
72
|
-
sleep(0.5)
|
73
|
-
consumer1.queue.size.must_equal 4
|
74
|
-
consumer2.queue.size.must_equal 0
|
75
|
-
consumer1.terminate
|
76
|
-
consumer2.terminate
|
77
|
-
end
|
78
|
-
it 'should pause channel' do
|
79
|
-
@consumer.terminate
|
80
|
-
@http.write('msg0')
|
81
|
-
@http.pause_channel('chan2').status_code.must_equal 200
|
82
|
-
consumer1 = Krakow::Test._consumer(:channel => 'chan1')
|
83
|
-
consumer2 = Krakow::Test._consumer(:channel => 'chan2')
|
84
|
-
@http.write('msg1', 'msg2', 'msg3').status_code.must_equal 200
|
85
|
-
sleep(0.5)
|
86
|
-
consumer1.queue.size.must_equal 4
|
87
|
-
consumer2.queue.size.must_equal 0
|
88
|
-
consumer1.terminate
|
89
|
-
consumer2.terminate
|
90
|
-
end
|
91
|
-
it 'should unpause channel' do
|
92
|
-
@consumer.terminate
|
93
|
-
@http.write('msg0')
|
94
|
-
@http.pause_channel('chan2').status_code.must_equal 200
|
95
|
-
consumer1 = Krakow::Test._consumer(:channel => 'chan1')
|
96
|
-
consumer2 = Krakow::Test._consumer(:channel => 'chan2')
|
97
|
-
@http.write('msg1', 'msg2', 'msg3').status_code.must_equal 200
|
98
|
-
sleep(0.5)
|
99
|
-
consumer1.queue.size.must_equal 4
|
100
|
-
consumer2.queue.size.must_equal 0
|
101
|
-
@http.unpause_channel('chan2').status_code.must_equal 200
|
102
|
-
sleep(0.5)
|
103
|
-
consumer2.queue.size.must_equal 4
|
104
|
-
consumer1.terminate
|
105
|
-
consumer2.terminate
|
106
|
-
end
|
107
|
-
it 'should return stats' do
|
108
|
-
stat = @http.stats
|
109
|
-
stat.status_code.must_equal 200
|
110
|
-
stat.data.must_be_kind_of Hash
|
111
|
-
end
|
112
|
-
it 'should ping' do
|
113
|
-
@http.ping.status_code.must_equal 200
|
114
|
-
end
|
115
|
-
it 'should fetch info' do
|
116
|
-
infos = @http.info
|
117
|
-
infos.status_code.must_equal 200
|
118
|
-
infos.data.must_be_kind_of Hash
|
119
|
-
end
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
data/test/specs/producer.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
describe Krakow do
|
2
|
-
|
3
|
-
describe Krakow::Producer do
|
4
|
-
|
5
|
-
it 'should be connected' do
|
6
|
-
@producer.connected?.must_equal true
|
7
|
-
end
|
8
|
-
it 'should write single messages successfully' do
|
9
|
-
response = @producer.write('msg')
|
10
|
-
response.must_be_kind_of Krakow::FrameType::Response
|
11
|
-
Krakow::Command::Pub.ok.must_include response.content
|
12
|
-
end
|
13
|
-
it 'should write multiple messages successfully' do
|
14
|
-
response = @producer.write('msg1', 'msg2', 'msg3')
|
15
|
-
response.must_be_kind_of Krakow::FrameType::Response
|
16
|
-
Krakow::Command::Mpub.ok.must_include response.content
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|