You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sebastian Bazley <se...@apache.org> on 2016/02/04 12:43:12 UTC
[whimsy.git] [1/1] Commit b2a1f05: Prepare for possible retry handling
Commit b2a1f0577011d6d54e96eb0449d484d4bb994397:
Prepare for possible retry handling
Branch: refs/heads/master
Author: Sebb <se...@apache.org>
Committer: Sebb <se...@apache.org>
Pusher: sebb <se...@apache.org>
------------------------------------------------------------
lib/whimsy/asf/ldap.rb | ++++++++++++ --
------------------------------------------------------------
14 changes: 12 additions, 2 deletions.
------------------------------------------------------------
diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 5f42113..1851150 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -72,7 +72,8 @@ def self.puppet_ldapservers
# connect to LDAP
def self.connect
- hosts.shuffle.each do |host|
+ loop do
+ host = next_host
Wunderbar.info "Connecting to LDAP server: #{host}"
begin
@@ -533,6 +534,7 @@ def self.http_auth(string, &block)
# determine what LDAP hosts are available
def self.hosts
+ return @hosts if @hosts # cache the hosts list
# try whimsy config
hosts = Array(ASF::Config.get(:ldap))
@@ -552,7 +554,15 @@ def self.hosts
Wunderbar.debug "Using default host list" if hosts.empty?
hosts = ASF::LDAP::HOSTS if hosts.empty?
- hosts
+ hosts.shuffle!
+ #Wunderbar.debug "Hosts:\n#{hosts.join(' ')}"
+ @hosts = hosts
+ end
+
+ # Ensure we only use each host once
+ def self.next_host
+ @he ||= hosts.to_enum
+ @he.next
end
# select LDAP host