(protocolPool []Protocol, fetchFunc edgediscovery.PercentageFetcher, switchThreshold int32)
| 179 | } |
| 180 | |
| 181 | func 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 |
| 198 | type defaultProtocolSelector struct { |
no test coverage detected