Method: NATS#process_info
- Defined in:
- lib/nats/client.rb
permalink #process_info(info_line) ⇒ Object
:nodoc:
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
# File 'lib/nats/client.rb', line 982 def process_info(info_line) #:nodoc: info = JSON.parse(info_line, :symbolize_keys => true, :symbolize_names => true, :symbol_keys => true) # Detect any announced server that we might not be aware of... connect_urls = info[:connect_urls] if connect_urls srvs = [] connect_urls.each do |url| u = URI.parse("nats://#{url}") present = server_pool.detect do |srv| srv[:uri].host == u.host && srv[:uri].port == u.port end if not present # Let explicit user and pass options set the credentials. u.user = [:user] if [:user] u.password = [:pass] if [:pass] # Use creds from the current server if not set explicitly. if @uri and !@uri.user.nil? and !@uri.user.empty? u.user ||= @uri.user u.password ||= @uri.password end srvs << { :uri => u, :reconnect_attempts => 0, :discovered => true } end end srvs.shuffle! unless @options[:dont_randomize_servers] # Include in server pool but keep current one as the first one. server_pool.push(*srvs) end info end |