amqp-failover 0.0.2 → 0.0.3
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/lib/amqp/failover/config.rb
CHANGED
@@ -29,13 +29,13 @@ module AMQP
|
|
29
29
|
# - :selection, not yet implimented.
|
30
30
|
#
|
31
31
|
def connect_with_failover(opts = nil)
|
32
|
-
opts =
|
32
|
+
opts = parse_amqp_url_or_opts_with_failover(opts)
|
33
33
|
connect_without_failover(opts)
|
34
34
|
end
|
35
35
|
alias :connect_without_failover :connect
|
36
36
|
alias :connect :connect_with_failover
|
37
37
|
|
38
|
-
def
|
38
|
+
def parse_amqp_url_or_opts_with_failover(opts = nil)
|
39
39
|
if opts.is_a?(String) && opts.index(',').nil?
|
40
40
|
opts = init_failover(opts.split(','))
|
41
41
|
elsif opts.is_a?(Array)
|
@@ -56,12 +56,19 @@ module AMQP
|
|
56
56
|
|
57
57
|
end # << self
|
58
58
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
59
|
+
def initialize_with_failover(opts = {})
|
60
|
+
@failover = opts.delete(:failover) if opts.has_key?(:failover)
|
61
|
+
initialize_without_failover(opts)
|
62
62
|
end
|
63
|
-
alias :
|
64
|
-
alias :
|
63
|
+
alias :initialize_without_failover :initialize
|
64
|
+
alias :initialize :initialize_with_failover
|
65
|
+
|
66
|
+
def unbind_with_failover
|
67
|
+
@on_disconnect = method(:failover_switch) if @failover
|
68
|
+
unbind_without_failover
|
69
|
+
end
|
70
|
+
alias :unbind_without_failover :unbind
|
71
|
+
alias :unbind :unbind_with_failover
|
65
72
|
|
66
73
|
end # Client
|
67
74
|
end # AMQP
|
data/lib/amqp/failover_client.rb
CHANGED
@@ -10,12 +10,6 @@ module AMQP
|
|
10
10
|
attr_accessor :settings
|
11
11
|
attr_accessor :on_disconnect
|
12
12
|
|
13
|
-
def self.extended(base)
|
14
|
-
if (base.failover = base.settings.delete(:failover))
|
15
|
-
base.on_disconnect = base.method(:disconnected)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
13
|
def failover_switch
|
20
14
|
if (new_settings = @failover.from(@settings))
|
21
15
|
log_message = "Could not connect to or lost connection to server #{@settings[:host]}:#{@settings[:port]}. " +
|
@@ -26,7 +20,7 @@ module AMQP
|
|
26
20
|
if @failover.options[:fallback] && @failover.primary == @settings
|
27
21
|
fallback(@failover.primary, @failover.fallback_interval)
|
28
22
|
end
|
29
|
-
@settings = new_settings
|
23
|
+
@settings = new_settings.merge({:failover => @failover})
|
30
24
|
reconnect
|
31
25
|
else
|
32
26
|
raise Error, "Could not connect to server #{@settings[:host]}:#{@settings[:port]}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp-failover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Myhrberg
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-22 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|