()
| 155 | } |
| 156 | |
| 157 | func (s *remoteProtocolSelector) Current() Protocol { |
| 158 | s.lock.Lock() |
| 159 | defer s.lock.Unlock() |
| 160 | if time.Now().Before(s.refreshAfter) { |
| 161 | return s.current |
| 162 | } |
| 163 | |
| 164 | protocol, err := getProtocol(s.protocolPool, s.fetchFunc, s.switchThreshold) |
| 165 | if err != nil { |
| 166 | s.log.Err(err).Msg("Failed to refresh protocol") |
| 167 | return s.current |
| 168 | } |
| 169 | s.current = protocol |
| 170 | |
| 171 | s.refreshAfter = time.Now().Add(s.ttl) |
| 172 | return s.current |
| 173 | } |
| 174 | |
| 175 | func (s *remoteProtocolSelector) Fallback() (Protocol, bool) { |
| 176 | s.lock.RLock() |
nothing calls this directly
no test coverage detected