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 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
                   
     | 
| 
      
 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 ]
         
     | 
    
        data/right_support.gemspec
    CHANGED
    
    | 
         @@ -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. 
     | 
| 
       11 
     | 
    
         
            -
              s.date    = '2011-10- 
     | 
| 
      
 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:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 7
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 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- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-10-14 00:00:00 -07:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |