onstomp 1.0.1 → 1.0.2
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/Gemfile +4 -0
- data/README.md +3 -3
- data/lib/onstomp/failover/client.rb +12 -5
- data/lib/onstomp/failover/pools/base.rb +3 -3
- data/lib/onstomp/failover/uri.rb +3 -7
- data/lib/onstomp/version.rb +1 -1
- data/spec/onstomp/failover/client_spec.rb +15 -1
- data/spec/onstomp/failover/uri_spec.rb +4 -22
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 1.0.2
|
4
|
+
* allow failover clients to be constructed from regular OnStomp::Client
|
5
|
+
instances, allowing fully configured SSL connections.
|
6
|
+
|
7
|
+
## 1.0.1
|
8
|
+
* improved failover buffer handling
|
9
|
+
* added RECEIPT driven failover buffer handling - more reliable, but slower
|
10
|
+
as it requests receipts for nearly all frames.
|
11
|
+
|
12
|
+
## 1.0.0
|
13
|
+
* initial release
|
14
|
+
* support for STOMP 1.0 and STOMP 1.1 protocols
|
15
|
+
* fully featured client with event bindings and non-blocking IO
|
16
|
+
* experimental support for open-uri STOMP interface
|
17
|
+
* experimental support for failover/reliable connection handling
|
18
|
+
|
3
19
|
## 1.0pre - 2011-03-30
|
4
20
|
* initial pre-release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -48,9 +48,9 @@ style API for working with message brokers.
|
|
48
48
|
|
49
49
|
## Further Reading
|
50
50
|
|
51
|
-
* A {file:
|
52
|
-
* A {file:
|
53
|
-
* A {file:
|
51
|
+
* A {file:extra_doc/UserNarrative.md User's Narrative}
|
52
|
+
* A {file:extra_doc/DeveloperNarrative.md Developers's Narrative}
|
53
|
+
* A {file:extra_doc/CHANGELOG.md History of Changes}
|
54
54
|
|
55
55
|
## License
|
56
56
|
|
@@ -32,13 +32,20 @@ class OnStomp::Failover::Client
|
|
32
32
|
# @return [true,false]
|
33
33
|
attr_configurable_bool :randomize, :default => false
|
34
34
|
|
35
|
-
attr_reader :uri, :
|
35
|
+
attr_reader :uri, :hosts,
|
36
|
+
:client_pool, :active_client, :frame_buffer, :connection
|
36
37
|
|
37
38
|
def initialize(uris, options={})
|
38
|
-
|
39
|
+
if uris.is_a? Array
|
40
|
+
@uri = OnStomp::Failover::URI::FAILOVER.new [], nil
|
41
|
+
@hosts = uris
|
42
|
+
else
|
43
|
+
@uri = OnStomp::Failover::URI::FAILOVER.parse uris
|
44
|
+
@hosts = @uri.failover_uris
|
45
|
+
end
|
39
46
|
@client_mutex = Mutex.new
|
40
47
|
configure_configurable options
|
41
|
-
create_client_pool
|
48
|
+
create_client_pool hosts
|
42
49
|
@active_client = nil
|
43
50
|
@connection = nil
|
44
51
|
@frame_buffer = buffer.new self
|
@@ -118,8 +125,8 @@ class OnStomp::Failover::Client
|
|
118
125
|
sleep(retry_delay) if retry_delay > 0 && attempt > 1
|
119
126
|
end
|
120
127
|
|
121
|
-
def create_client_pool
|
122
|
-
@client_pool = pool.new
|
128
|
+
def create_client_pool hosts
|
129
|
+
@client_pool = pool.new hosts
|
123
130
|
on_connection_closed do |client, *_|
|
124
131
|
unless @disconnecting
|
125
132
|
trigger_failover_event(:lost, :on, active_client)
|
@@ -8,9 +8,9 @@ class OnStomp::Failover::Pools::Base
|
|
8
8
|
|
9
9
|
# Creates a new client pool by mapping an array of URIs into an array of
|
10
10
|
# {OnStomp::Client clients}.
|
11
|
-
def initialize
|
12
|
-
@clients =
|
13
|
-
OnStomp::Client.new
|
11
|
+
def initialize hosts
|
12
|
+
@clients = hosts.map do |h|
|
13
|
+
h.is_a?(OnStomp::Client) ? h : OnStomp::Client.new(h)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/onstomp/failover/uri.rb
CHANGED
@@ -12,9 +12,7 @@ module OnStomp::Failover::URI
|
|
12
12
|
|
13
13
|
attr_reader :failover_uris
|
14
14
|
def initialize uris, query
|
15
|
-
@failover_uris = uris
|
16
|
-
u.is_a?(::URI) ? u : ::URI.parse(u.strip)
|
17
|
-
end
|
15
|
+
@failover_uris = uris
|
18
16
|
super 'failover', nil, nil, nil, nil, '', "(#{uris.join(',')})", query, nil
|
19
17
|
end
|
20
18
|
|
@@ -42,12 +40,10 @@ module OnStomp::Failover::URI
|
|
42
40
|
# @param [Array<String or URI>] uri_arr
|
43
41
|
# @return [FAILOVER]
|
44
42
|
def parse uri_str
|
45
|
-
if uri_str
|
46
|
-
self.new uri_str, nil
|
47
|
-
elsif uri_str =~ FAILOVER_REG
|
43
|
+
if uri_str =~ FAILOVER_REG
|
48
44
|
self.new $1.split(','), $2
|
49
45
|
else
|
50
|
-
raise OnStomp::Failover::InvalidFailoverURIError, uri_str
|
46
|
+
raise OnStomp::Failover::InvalidFailoverURIError, uri_str.inspect
|
51
47
|
end
|
52
48
|
end
|
53
49
|
end
|
data/lib/onstomp/version.rb
CHANGED
@@ -13,6 +13,20 @@ module OnStomp::Failover
|
|
13
13
|
c.stub(:active_client => active_client)
|
14
14
|
end
|
15
15
|
}
|
16
|
+
describe "initialize" do
|
17
|
+
it "should be initialized by string" do
|
18
|
+
c = Client.new('failover:(stomp:///,stomp+ssl:///)')
|
19
|
+
c.uri.to_s.should == 'failover:(stomp:///,stomp+ssl:///)'
|
20
|
+
c.hosts.should == ['stomp:///', 'stomp+ssl:///']
|
21
|
+
end
|
22
|
+
it "should be initialized by array" do
|
23
|
+
real_client = OnStomp::Client.new('stomp+ssl:///')
|
24
|
+
c = Client.new(['stomp:///', real_client])
|
25
|
+
c.uri.to_s.should == 'failover:()'
|
26
|
+
c.hosts.should == ['stomp:///', real_client]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
16
30
|
describe ".connected?" do
|
17
31
|
it "should be connected if it has an active client that's connected" do
|
18
32
|
active_client.stub(:connected? => true)
|
@@ -67,7 +81,7 @@ module OnStomp::Failover
|
|
67
81
|
# Get the hooks installed on our mocks
|
68
82
|
active_client.stub(:connection => connection)
|
69
83
|
client.stub(:client_pool => client_pool)
|
70
|
-
client.__send__ :create_client_pool
|
84
|
+
client.__send__ :create_client_pool, []
|
71
85
|
end
|
72
86
|
it "should do nothing special if there is no active client" do
|
73
87
|
client.stub(:active_client => nil)
|
@@ -11,42 +11,24 @@ module OnStomp::Failover
|
|
11
11
|
it "should parse failover:(uri1,uri2...)?failoverParam1=..." do
|
12
12
|
uri = parse_failover_uri 'failover:(stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld)?param=blah¶m2=testing'
|
13
13
|
uri.query.should == 'param=blah¶m2=testing'
|
14
|
-
uri.failover_uris.
|
15
|
-
uri.failover_uris.map { |u| u.host }.should == ['host.domain.tld', nil, 'other.host.tld']
|
16
|
-
uri.failover_uris.map { |u| u.query }.should == [nil, 'param=value¶m2=value2', nil]
|
14
|
+
uri.failover_uris.should == ['stomp://host.domain.tld', 'stomp+ssl:///?param=value¶m2=value2', 'stomp://user:pass@other.host.tld']
|
17
15
|
uri.to_s.should == "failover:(stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld)?param=blah¶m2=testing"
|
18
16
|
end
|
19
17
|
it "should parse failover://(uri1,uri2...)?failoverParam1=..." do
|
20
18
|
uri = parse_failover_uri 'failover://(stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld)?param=blah¶m2=testing'
|
21
19
|
uri.query.should == 'param=blah¶m2=testing'
|
22
|
-
uri.failover_uris.
|
23
|
-
uri.failover_uris.map { |u| u.host }.should == ['host.domain.tld', nil, 'other.host.tld']
|
24
|
-
uri.failover_uris.map { |u| u.query }.should == [nil, 'param=value¶m2=value2', nil]
|
20
|
+
uri.failover_uris.should == ['stomp://host.domain.tld', 'stomp+ssl:///?param=value¶m2=value2', 'stomp://user:pass@other.host.tld']
|
25
21
|
uri.to_s.should == "failover:(stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld)?param=blah¶m2=testing"
|
26
22
|
end
|
27
23
|
it "should parse failover://uri1,uri2,..." do
|
28
24
|
uri = parse_failover_uri 'failover://stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld'
|
29
25
|
uri.query.should be_nil
|
30
|
-
uri.failover_uris.
|
31
|
-
uri.failover_uris.map { |u| u.host }.should == ['host.domain.tld', nil, 'other.host.tld']
|
32
|
-
uri.failover_uris.map { |u| u.query }.should == [nil, 'param=value¶m2=value2', nil]
|
26
|
+
uri.failover_uris.should == ['stomp://host.domain.tld', 'stomp+ssl:///?param=value¶m2=value2', 'stomp://user:pass@other.host.tld']
|
33
27
|
uri.to_s.should == "failover:(stomp://host.domain.tld,stomp+ssl:///?param=value¶m2=value2,stomp://user:pass@other.host.tld)"
|
34
28
|
end
|
35
|
-
it "should parse an array of failover URIs" do
|
36
|
-
uris = [ "stomp://host.domain.tld",
|
37
|
-
::URI.parse("stomp://user:pass@other.host.tld"),
|
38
|
-
"stomp+ssl:///?param=value¶m2=value2"]
|
39
|
-
uri = parse_failover_uri uris
|
40
|
-
uri.query.should be_nil
|
41
|
-
uri.failover_uris.map { |u| u.scheme }.should == ['stomp', 'stomp', 'stomp+ssl']
|
42
|
-
uri.failover_uris.map { |u| u.host }.should == ['host.domain.tld', 'other.host.tld', nil]
|
43
|
-
uri.failover_uris.map { |u| u.query }.should == [nil, nil, 'param=value¶m2=value2']
|
44
|
-
uri.to_s.should == "failover:(stomp://host.domain.tld,stomp://user:pass@other.host.tld,stomp+ssl:///?param=value¶m2=value2)"
|
45
|
-
end
|
46
29
|
it "should raise an error if it doesn't match the regex and isn't an array" do
|
47
30
|
lambda {
|
48
|
-
|
49
|
-
parse_failover_uri "failover:"
|
31
|
+
parse_failover_uri ["some", "array"]
|
50
32
|
}.should raise_error(OnStomp::Failover::InvalidFailoverURIError)
|
51
33
|
end
|
52
34
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: onstomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ian D. Eccles
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-09 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|