Methods
Public Class
Public Instance
Public Class methods
new(resolver_type, options)
[show source]
# File lib/httpx/resolver/multi.rb 10 def initialize(resolver_type, options) 11 @current_selector = @current_session = nil 12 @options = options 13 @resolver_options = @options.resolver_options 14 15 ip_families = options.ip_families || Resolver.supported_ip_families 16 17 @resolvers = ip_families.map do |ip_family| 18 resolver = resolver_type.new(ip_family, options) 19 resolver.multi = self 20 resolver 21 end 22 end
Public Instance methods
closed?()
[show source]
# File lib/httpx/resolver/multi.rb 42 def closed? 43 @resolvers.all?(&:closed?) 44 end
current_selector=(s)
[show source]
# File lib/httpx/resolver/multi.rb 28 def current_selector=(s) 29 @current_selector = s 30 @resolvers.each { |r| r.current_selector = s } 31 end
current_session=(s)
[show source]
# File lib/httpx/resolver/multi.rb 33 def current_session=(s) 34 @current_session = s 35 @resolvers.each { |r| r.current_session = s } 36 end
early_resolve(connection)
[show source]
# File lib/httpx/resolver/multi.rb 46 def early_resolve(connection) 47 hostname = connection.peer.host 48 addresses = @resolver_options[:cache] && (connection.addresses || nolookup_resolve(hostname, connection.options)) 49 return false unless addresses 50 51 ip_families = connection.options.ip_families 52 53 resolved = false 54 addresses.group_by(&:family).sort { |(f1, _), (f2, _)| f2 <=> f1 }.each do |family, addrs| 55 next unless ip_families.nil? || ip_families.include?(family) 56 57 # try to match the resolver by family. However, there are cases where that's not possible, as when 58 # the system does not have IPv6 connectivity, but it does support IPv6 via loopback/link-local. 59 resolver = @resolvers.find { |r| r.family == family } || @resolvers.first 60 61 next unless resolver # this should ever happen 62 63 # it does not matter which resolver it is, as early-resolve code is shared. 64 resolver.emit_addresses(connection, family, addrs, true) 65 66 resolved = true 67 end 68 69 resolved 70 end
lazy_resolve(connection)
[show source]
# File lib/httpx/resolver/multi.rb 72 def lazy_resolve(connection) 73 @resolvers.each do |resolver| 74 conn_to_resolve = @current_session.try_clone_connection(connection, @current_selector, resolver.family) 75 resolver << conn_to_resolve 76 77 next if resolver.empty? 78 79 # both the resolver and the connection it's resolving must be pineed to the session 80 @current_session.pin(conn_to_resolve, @current_selector) 81 @current_session.select_resolver(resolver, @current_selector) 82 end 83 end
log(*args, **kwargs, &blk)
[show source]
# File lib/httpx/resolver/multi.rb 38 def log(*args, **kwargs, &blk) 39 @resolvers.each { |r| r.log(*args, **kwargs, &blk) } 40 end
state()
[show source]
# File lib/httpx/resolver/multi.rb 24 def state 25 @resolvers.map(&:state).uniq.join(",") 26 end