mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 04:52:46 +00:00
Add FederationClient interface to federationsender (#1284)
* Add FederationClient interface to federationsender - Use a shim struct in HTTP mode to keep the same API as `FederationClient`. - Use `federationsender` instead of `FederationClient` in `keyserver`. * Pointers not values * Review comments * Fix unit tests * Rejig backoff * Unbreak test * Remove debug logs * Review comments and linting
This commit is contained in:
parent
068a3d3c9f
commit
6d6bb75137
11 changed files with 326 additions and 27 deletions
|
@ -126,8 +126,19 @@ func (s *ServerStatistics) Failure() (time.Time, bool) {
|
|||
return until, false
|
||||
}
|
||||
|
||||
// BackoffInfo returns information about the current or previous backoff.
|
||||
// Returns the last backoffUntil time and whether the server is currently blacklisted or not.
|
||||
func (s *ServerStatistics) BackoffInfo() (*time.Time, bool) {
|
||||
until, ok := s.backoffUntil.Load().(time.Time)
|
||||
if ok {
|
||||
return &until, s.blacklisted.Load()
|
||||
}
|
||||
return nil, s.blacklisted.Load()
|
||||
}
|
||||
|
||||
// BackoffIfRequired will block for as long as the current
|
||||
// backoff requires, if needed. Otherwise it will do nothing.
|
||||
// Returns the amount of time to backoff for and whether to give up or not.
|
||||
func (s *ServerStatistics) BackoffIfRequired(backingOff atomic.Bool, interrupt <-chan bool) (time.Duration, bool) {
|
||||
if started := s.backoffStarted.Load(); !started {
|
||||
return 0, false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue