MCPcopy
hub / github.com/cloudflare/cloudflared / getProtocol

Function getProtocol

connection/protocol.go:181–195  ·  view source on GitHub ↗
(protocolPool []Protocol, fetchFunc edgediscovery.PercentageFetcher, switchThreshold int32)

Source from the content-addressed store, hash-verified

179}
180
181func getProtocol(protocolPool []Protocol, fetchFunc edgediscovery.PercentageFetcher, switchThreshold int32) (Protocol, error) {
182 protocolPercentages, err := fetchFunc()
183 if err != nil {
184 return 0, err
185 }
186 for _, protocol := range protocolPool {
187 protocolPercentage := protocolPercentages.GetPercentage(protocol.String())
188 if protocolPercentage > switchThreshold {
189 return protocol, nil
190 }
191 }
192
193 // Default to first index in protocolPool list
194 return protocolPool[0], nil
195}
196
197// defaultProtocolSelector will allow for a protocol to have a fallback
198type defaultProtocolSelector struct {

Callers 2

CurrentMethod · 0.85
NewProtocolSelectorFunction · 0.85

Calls 2

GetPercentageMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected