Class: Gitlab::Database::LoadBalancing::SrvResolver

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/database/load_balancing/srv_resolver.rb

Overview

Hostnames returned in SRV records cannot sometimes be resolved by a local resolver, however, there’s a possibility that their A/AAAA records are returned as part of the SRV query in the additional section, so we try to extract the IPs from there first, failing back to querying the hostnames A/AAAA records one by one, using the same resolver that queried the SRV record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resolver, additional) ⇒ SrvResolver

Returns a new instance of SrvResolver.



19
20
21
22
# File 'lib/gitlab/database/load_balancing/srv_resolver.rb', line 19

def initialize(resolver, additional)
  @resolver = resolver
  @additional = additional
end

Instance Attribute Details

#additionalObject (readonly)

Returns the value of attribute additional.



17
18
19
# File 'lib/gitlab/database/load_balancing/srv_resolver.rb', line 17

def additional
  @additional
end

#resolverObject (readonly)

Returns the value of attribute resolver.



17
18
19
# File 'lib/gitlab/database/load_balancing/srv_resolver.rb', line 17

def resolver
  @resolver
end

Instance Method Details

#address_for(host) ⇒ Object



24
25
26
# File 'lib/gitlab/database/load_balancing/srv_resolver.rb', line 24

def address_for(host)
  addresses_from_additional[host] || resolve_host(host)
end