Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixes about StikyPolicy for ReposeDownloader refactoring #28

Merged
merged 3 commits into from about 2 years ago

2 participants

Sergey Tony Spataro
Sergey
Collaborator

No description provided.

Tony Spataro xeger merged commit 3a00399 into from March 20, 2012
Tony Spataro xeger closed this March 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  lib/right_support/net/balancing/sticky_policy.rb
@@ -51,7 +51,7 @@ def set_endpoints(endpoints)
51 51
     end
52 52
 
53 53
     def next
54  
-      [ @endpoints[@counter % @endpoints.size], true ] unless @endpoints.empty?
  54
+      [ @endpoints[@counter % @endpoints.size], false ] unless @endpoints.empty?
55 55
     end
56 56
 
57 57
     def good(endpoint, t0, t1)
10  lib/right_support/net/request_balancer.rb
@@ -160,8 +160,10 @@ def initialize(endpoints, options={})
160 160
     # Return the first non-nil value provided by the block.
161 161
     def request
162 162
       raise ArgumentError, "Must call this method with a block" unless block_given?
163  
-
164  
-      @policy.set_endpoints(self.resolve(@endpoints)) if self.expired?
  163
+      if self.expired?
  164
+        @ips = self.resolve(@endpoints)
  165
+        @policy.set_endpoints(@ips)
  166
+      end
165 167
 
166 168
       exceptions = []
167 169
       result     = nil
@@ -173,7 +175,7 @@ def request
173 175
           break
174 176
         else
175 177
           do_retry = @options[:retry] || DEFAULT_RETRY_PROC
176  
-          do_retry = do_retry.call(@endpoints, n) if do_retry.respond_to?(:call)
  178
+          do_retry = do_retry.call(@ips || @endpoints, n) if do_retry.respond_to?(:call)
177 179
           break if (do_retry.is_a?(Integer) && n >= do_retry) || [nil, false].include?(do_retry)
178 180
         end
179 181
 
@@ -217,7 +219,7 @@ def request
217 219
       return result if complete
218 220
 
219 221
       exceptions = exceptions.map { |e| e.class.name }.uniq.join(', ')
220  
-      msg = "No available endpoints from #{@endpoints.inspect}! Exceptions: #{exceptions}"
  222
+      msg = "No available endpoints from #{(@ips || @endpoints).inspect}! Exceptions: #{exceptions}"
221 223
       logger.error "RequestBalancer: #{msg}"
222 224
       raise NoResult, msg
223 225
     end
8  lib/right_support/net/ssl.rb
@@ -15,17 +15,17 @@ module SSL
15 15
     module_function
16 16
 
17 17
     def expected_hostname
18  
-      @expected_hostname
  18
+      Thread.current[:right_support_net_ssl_expected_hostname]
19 19
     end
20 20
 
21 21
     def with_expected_hostname(hostname, &block)
22  
-      @expected_hostname = hostname
  22
+      Thread.current[:right_support_net_ssl_expected_hostname] = hostname
23 23
       block.call
24 24
     rescue Exception => e
25  
-      @expected_hostname = nil
  25
+      Thread.current[:right_support_net_ssl_expected_hostname] = nil
26 26
       raise e
27 27
     ensure
28  
-      @expected_hostname = nil
  28
+      Thread.current[:right_support_net_ssl_expected_hostname] = nil
29 29
     end
30 30
   end
31 31
 end
6  spec/net/balancing/sticky_policy_spec.rb
@@ -39,7 +39,7 @@
39 39
         seen = find_empirical_distribution(@trials,@endpoints) do
40 40
           @policy.next
41 41
         end
42  
-        seen[[@ep1,true]].should eql(@trials)
  42
+        seen[[@ep1,false]].should eql(@trials)
43 43
 
44 44
         @policy.bad(@chosen,0,0)
45 45
         @ep2 = @policy.next.first
@@ -47,8 +47,8 @@
47 47
         seen = find_empirical_distribution(@trials,@endpoints) do
48 48
           @policy.next
49 49
         end
50  
-        seen[[@ep1,true]].should be_nil
51  
-        seen[[@ep2,true]].should eql(@trials)
  50
+        seen[[@ep1,false]].should be_nil
  51
+        seen[[@ep2,false]].should eql(@trials)
52 52
       end
53 53
     end
54 54
   end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.