right_support 1.0.7 → 1.0.8

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.
@@ -27,10 +27,6 @@ module RightSupport::Net::Balancing
27
27
  class EndpointsStack
28
28
  DEFAULT_YELLOW_STATES = 4
29
29
  DEFAULT_RESET_TIME = 300
30
-
31
- def endpoints
32
- @endpoints
33
- end
34
30
 
35
31
  def initialize(endpoints, yellow_states=nil, reset_time=nil)
36
32
  @endpoints = Hash.new
@@ -95,16 +91,14 @@ module RightSupport::Net::Balancing
95
91
  class HealthCheck
96
92
 
97
93
  def initialize(endpoints,options = {})
98
- # Modified by Ryan Williamson on 9/27/2011
99
- # Previously if you created an instance of HealthCheck without the required options
100
- # they would get passed as nil and overwrite EndpointsStack's default options causing an ArgumentError
101
94
  yellow_states = options[:yellow_states]
102
95
  reset_time = options[:reset_time]
103
- # End modification
96
+
104
97
  @health_check = options.delete(:health_check)
105
98
 
106
99
  @stack = EndpointsStack.new(endpoints,yellow_states,reset_time)
107
- @counter = rand(0xffff)
100
+ @counter = rand(0xffff) % endpoints.size
101
+ @last_size = endpoints.size
108
102
  end
109
103
 
110
104
  def next
@@ -114,8 +108,10 @@ module RightSupport::Net::Balancing
114
108
  return nil if endpoints.empty?
115
109
 
116
110
  # Selection of the next endpoint using RoundRobin
117
- @counter += 1
118
- i = @counter % endpoints.size
111
+ @counter += 1 unless endpoints.size < @last_size
112
+ @counter = 0 if @counter == endpoints.size
113
+ i = @counter % endpoints.size
114
+ @last_size = endpoints.size
119
115
 
120
116
  # Returns false or true, depending on whether EP is yellow or not
121
117
  [ endpoints[i][0], endpoints[i][1][:n_level] != 0 ]
@@ -112,7 +112,7 @@ module RightSupport::Net
112
112
  raise ArgumentError, ":health_check callback must accept one parameters"
113
113
  end
114
114
 
115
- @endpoints = endpoints.shuffle
115
+ @endpoints = endpoints
116
116
  end
117
117
 
118
118
  # Perform a request.
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
7
7
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
8
8
 
9
9
  s.name = 'right_support'
10
- s.version = '1.0.7'
11
- s.date = '2011-10-13'
10
+ s.version = '1.0.8'
11
+ s.date = '2011-10-14'
12
12
 
13
13
  s.authors = ['Tony Spataro']
14
14
  s.email = 'tony@rightscale.com'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 7
10
- version: 1.0.7
9
+ - 8
10
+ version: 1.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-13 00:00:00 -07:00
18
+ date: 2011-10-14 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency