wordnik 4.09 → 4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/wordnik/load_balancer.rb +8 -0
- data/lib/wordnik/request.rb +3 -3
- data/lib/wordnik/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -23,6 +23,7 @@ module Wordnik
|
|
23
23
|
@hosts = @all_hosts.clone
|
24
24
|
@failed_hosts_table = {}
|
25
25
|
@current_host = nil
|
26
|
+
Wordnik.logger.info "LoadBalancer: Creating a load balancer using the following hosts: #{@hosts.join(', ')}"
|
26
27
|
end
|
27
28
|
|
28
29
|
def host
|
@@ -43,6 +44,11 @@ module Wordnik
|
|
43
44
|
#Wordnik.logger.debug "Informed failure about #{@current_host}. table now: #{@failed_hosts_table.inspect}"
|
44
45
|
@hosts.delete(@current_host)
|
45
46
|
@hosts = [@current_host] if @hosts.size == 0 # got to have something!
|
47
|
+
if @hosts == [@current_host]
|
48
|
+
Wordnik.logger.warn "LoadBalancer: host #{@current_host} failed, but it is the only remaining host. Not removing."
|
49
|
+
else
|
50
|
+
Wordnik.logger.info "LoadBalancer: host #{@current_host} failed. Removed from active hosts, which are now: #{@hosts.join(', ')}"
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
# success here means just that a successful connection was made
|
@@ -50,6 +56,7 @@ module Wordnik
|
|
50
56
|
def inform_success
|
51
57
|
@failed_hosts_table.delete(@current_host)
|
52
58
|
@hosts << @current_host unless @hosts.include? @current_host
|
59
|
+
Wordnik.logger.info "LoadBalancer: host #{@current_host} is working again, and has been added to active hosts, which are now: #{@hosts.join(', ')}"
|
53
60
|
@hosts
|
54
61
|
end
|
55
62
|
|
@@ -62,6 +69,7 @@ module Wordnik
|
|
62
69
|
# exponential backoff, but try every hour...
|
63
70
|
if (seconds_since_last_failure > [3600, 2**(failures-1)].min)
|
64
71
|
@hosts << host # give it a chance to succeed ...
|
72
|
+
Wordnik.logger.info "LoadBalancer: timeout for host #{host} failure exceeded; returning to active hosts, which are now: #{@hosts.join(', ')}"
|
65
73
|
update_failed_time(host, n)
|
66
74
|
end
|
67
75
|
end
|
data/lib/wordnik/request.rb
CHANGED
@@ -166,14 +166,14 @@ module Wordnik
|
|
166
166
|
|
167
167
|
if Wordnik.configuration.load_balancer
|
168
168
|
if (resp.timed_out? || resp.code == 0)
|
169
|
-
|
169
|
+
Wordnik.logger.info "Wordnik: informing load balancer about failure"
|
170
170
|
Wordnik.configuration.load_balancer.inform_failure
|
171
171
|
if (attempt <= 3)
|
172
|
-
|
172
|
+
Wordnik.logger.info "Trying again after failing #{attempt} times..."
|
173
173
|
return make(attempt + 1) if attempt <= 3 # try three times to get a result...
|
174
174
|
end
|
175
175
|
else
|
176
|
-
|
176
|
+
Wordnik.logger.debug "informing load balancer about success"
|
177
177
|
Wordnik.configuration.load_balancer.inform_success
|
178
178
|
end
|
179
179
|
end
|
data/lib/wordnik/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordnik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '4.
|
4
|
+
version: '4.10'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: typhoeus
|
@@ -310,7 +310,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
310
310
|
version: '0'
|
311
311
|
segments:
|
312
312
|
- 0
|
313
|
-
hash:
|
313
|
+
hash: 3048713973000593912
|
314
314
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
315
315
|
none: false
|
316
316
|
requirements:
|
@@ -319,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
319
|
version: '0'
|
320
320
|
segments:
|
321
321
|
- 0
|
322
|
-
hash:
|
322
|
+
hash: 3048713973000593912
|
323
323
|
requirements: []
|
324
324
|
rubyforge_project: wordnik
|
325
325
|
rubygems_version: 1.8.24
|