Class: Faraday::HappyEyeballs::DualStackResolver
- Inherits:
-
Object
- Object
- Faraday::HappyEyeballs::DualStackResolver
- Defined in:
- lib/faraday/happy_eyeballs/dual_stack_resolver.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DualStackResolver
constructor
A new instance of DualStackResolver.
- #resolve_dual_stack(hostname) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DualStackResolver
Returns a new instance of DualStackResolver.
8 9 10 11 |
# File 'lib/faraday/happy_eyeballs/dual_stack_resolver.rb', line 8 def initialize( = {}) @options = @resolution_cache = {} @cache_mutex = Mutex.new end |
Instance Method Details
#resolve_dual_stack(hostname) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/faraday/happy_eyeballs/dual_stack_resolver.rb', line 13 def resolve_dual_stack(hostname) if @options.fetch(:enable_cache, true) cached = cached_addresses(hostname) return cached if cached end addresses = perform_dual_stack_resolution(hostname) addresses = direct_resolution(hostname) if addresses.empty? if @options.fetch(:enable_cache, true) && !addresses.empty? cache_addresses(hostname, addresses) end addresses end |