MCPcopy
hub / github.com/grafana/k6 / NewHosts

Function NewHosts

lib/types/hosts.go:98–114  ·  view source on GitHub ↗

NewHosts returns new Hosts from given addresses.

(source map[string]Host)

Source from the content-addressed store, hash-verified

96
97// NewHosts returns new Hosts from given addresses.
98func NewHosts(source map[string]Host) (*Hosts, error) {
99 h := &Hosts{
100 source: toLowerKeys(source),
101 n: &trieNode{
102 children: make(map[rune]*trieNode),
103 },
104 }
105
106 for k := range h.source {
107 err := h.insert(k)
108 if err != nil {
109 return nil, err
110 }
111 }
112
113 return h, nil
114}
115
116func toLowerKeys(source map[string]Host) map[string]Host {
117 result := make(map[string]Host, len(source))

Callers 11

TestRequestAndBatchTLSFunction · 0.92
TestDialerAddrFunction · 0.92
BenchmarkDialerHostsFunction · 0.92
TestDialerResolveAddrFunction · 0.92
TestX509HostnameErrorFunction · 0.92
NewHTTPMultiBinFunction · 0.92
NewNullHostsFunction · 0.85
UnmarshalJSONMethod · 0.85
TestHostsFunction · 0.85

Calls 2

insertMethod · 0.95
toLowerKeysFunction · 0.85

Tested by 8

TestRequestAndBatchTLSFunction · 0.74
TestDialerAddrFunction · 0.74
BenchmarkDialerHostsFunction · 0.74
TestDialerResolveAddrFunction · 0.74
TestX509HostnameErrorFunction · 0.74
TestHostsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…