amqp-failover 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
3
+
4
+ require 'spec_helper'
5
+
6
+ describe 'AMQP::Failover' do
7
+
8
+ before(:each) do
9
+ configs = [
10
+ {:host => 'rabbit0.local'},
11
+ {:host => 'rabbit1.local'},
12
+ {:host => 'rabbit2.local', :port => 5673}
13
+ ]
14
+ @configs = configs.map { |conf| AMQP.settings.merge(conf) }
15
+ @fail = AMQP::Failover.new(@configs)
16
+ end
17
+
18
+ it "should initialize" do
19
+ @fail.configs.should == @configs
20
+ end
21
+
22
+ it "should #add_config" do
23
+ @fail.instance_variable_set("@configs", nil)
24
+ @fail.configs.should == []
25
+ @fail.add_config(@configs[0])
26
+ @fail.configs.should have(1).item
27
+ @fail.configs.should == [@configs[0]]
28
+ @fail.refs.should == {}
29
+ @fail.add_config(@configs[1], :hello)
30
+ @fail.configs.should have(2).items
31
+ @fail.configs.should include(@configs[1])
32
+ @fail.get_by_ref(:hello).should == @configs[1]
33
+ end
34
+
35
+ it "should #get_by_conf" do
36
+ fetched = @fail.get_by_conf(@configs[1])
37
+ fetched.should == @configs[1]
38
+ fetched.class.should == AMQP::Failover::Config
39
+ fetched.last_fail.should be_nil
40
+ end
41
+
42
+ it "should #fail_with" do
43
+ fail = AMQP::Failover.new
44
+ now = Time.now
45
+ fail.failed_with(@configs[0], 0, now)
46
+ fail.latest_failed.should == @configs[0]
47
+ fail.last_fail_of(@configs[0]).should == now
48
+ fail.last_fail_of(0).should == now
49
+ end
50
+
51
+ it "should find #next_config" do
52
+ @fail.failed_with(@configs[1])
53
+ @fail.next_config.should == @configs[2]
54
+ @fail.next_config.should == @configs[2]
55
+ @fail.failed_with(@configs[2])
56
+ @fail.next_config.should == @configs[0]
57
+ @fail.failed_with(@configs[0])
58
+ @fail.next_config.should be_nil
59
+ end
60
+
61
+ it "should #failover_from" do
62
+ now = Time.now
63
+ @fail.failover_from(@configs[0], now).should == @configs[1]
64
+ @fail.latest_failed.should == @configs[0]
65
+ @fail.latest_failed.last_fail.should == now
66
+ end
67
+
68
+ end
69
+
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amqp-failover
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jim Myhrberg
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-01 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: amqp
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 0
34
+ version: 0.7.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 49
46
+ segments:
47
+ - 0
48
+ - 8
49
+ - 7
50
+ version: 0.8.7
51
+ type: :development
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rack-test
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 0
64
+ - 5
65
+ - 6
66
+ version: 0.5.6
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 11
78
+ segments:
79
+ - 2
80
+ - 1
81
+ - 0
82
+ version: 2.1.0
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: yard
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 1
94
+ segments:
95
+ - 0
96
+ - 6
97
+ - 3
98
+ version: 0.6.3
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: json
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 1
112
+ - 5
113
+ - 0
114
+ version: 1.5.0
115
+ type: :development
116
+ version_requirements: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ name: ruby-debug
119
+ prerelease: false
120
+ requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ type: :development
130
+ version_requirements: *id007
131
+ description: Add multi-server failover and fallback to amqp gem.
132
+ email:
133
+ - contact@jimeh.me
134
+ executables: []
135
+
136
+ extensions: []
137
+
138
+ extra_rdoc_files: []
139
+
140
+ files:
141
+ - .document
142
+ - .gitignore
143
+ - .rspec
144
+ - .rvmrc
145
+ - Gemfile
146
+ - LICENSE
147
+ - README.md
148
+ - Rakefile
149
+ - amqp-failover.gemspec
150
+ - lib/amqp/failover.rb
151
+ - lib/amqp/failover/config.rb
152
+ - lib/amqp/failover/configurations.rb
153
+ - lib/amqp/failover/ext/amqp/client.rb
154
+ - lib/amqp/failover/logger.rb
155
+ - lib/amqp/failover/server_discovery.rb
156
+ - lib/amqp/failover/version.rb
157
+ - lib/amqp/failover_client.rb
158
+ - spec/integration/basic_spec.rb
159
+ - spec/integration/failover_spec.rb
160
+ - spec/logger_helper.rb
161
+ - spec/server_helper.rb
162
+ - spec/spec_helper.rb
163
+ - spec/unit/amqp/failover/config_spec.rb
164
+ - spec/unit/amqp/failover/configurations_spec.rb
165
+ - spec/unit/amqp/failover/server_discovery_helper.rb
166
+ - spec/unit/amqp/failover/server_discovery_spec.rb
167
+ - spec/unit/amqp/failover_spec.rb
168
+ has_rdoc: true
169
+ homepage: http://github.com/jimeh/amqp-failover
170
+ licenses: []
171
+
172
+ post_install_message:
173
+ rdoc_options: []
174
+
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: 3
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ hash: 3
192
+ segments:
193
+ - 0
194
+ version: "0"
195
+ requirements: []
196
+
197
+ rubyforge_project: amqp-failover
198
+ rubygems_version: 1.3.7
199
+ signing_key:
200
+ specification_version: 3
201
+ summary: Add multi-server failover and fallback to amqp gem.
202
+ test_files:
203
+ - spec/integration/basic_spec.rb
204
+ - spec/integration/failover_spec.rb
205
+ - spec/logger_helper.rb
206
+ - spec/server_helper.rb
207
+ - spec/spec_helper.rb
208
+ - spec/unit/amqp/failover/config_spec.rb
209
+ - spec/unit/amqp/failover/configurations_spec.rb
210
+ - spec/unit/amqp/failover/server_discovery_helper.rb
211
+ - spec/unit/amqp/failover/server_discovery_spec.rb
212
+ - spec/unit/amqp/failover_spec.rb