Documentation ¶
Index ¶
- type ServerStatistics
- func (s *ServerStatistics) AssignBackoffNotifier(notifier func())
- func (s *ServerStatistics) BackoffInfo() (*time.Time, bool)
- func (s *ServerStatistics) Blacklisted() bool
- func (s *ServerStatistics) ClearBackoff()
- func (s *ServerStatistics) Failure() (time.Time, bool)
- func (s *ServerStatistics) RemoveBlacklist()
- func (s *ServerStatistics) Success()
- func (s *ServerStatistics) SuccessCount() uint32
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ServerStatistics ¶
type ServerStatistics struct {
// contains filtered or unexported fields
}
ServerStatistics contains information about our interactions with a remote federated host, e.g. how many times we were successful, how many times we failed etc. It also manages the backoff time and black- listing a remote host if it remains uncooperative.
func (*ServerStatistics) AssignBackoffNotifier ¶ added in v0.10.4
func (s *ServerStatistics) AssignBackoffNotifier(notifier func())
AssignBackoffNotifier configures the channel to send to when a backoff completes.
func (*ServerStatistics) BackoffInfo ¶
func (s *ServerStatistics) BackoffInfo() (*time.Time, bool)
BackoffInfo returns information about the current or previous backoff. Returns the last backoffUntil time and whether the server is currently blacklisted or not.
func (*ServerStatistics) Blacklisted ¶
func (s *ServerStatistics) Blacklisted() bool
Blacklisted returns true if the server is blacklisted and false otherwise.
func (*ServerStatistics) ClearBackoff ¶ added in v0.10.4
func (s *ServerStatistics) ClearBackoff()
ClearBackoff stops the backoff timer for this destination if it is running and removes the timer from the backoffTimers map.
func (*ServerStatistics) Failure ¶
func (s *ServerStatistics) Failure() (time.Time, bool)
Failure marks a failure and starts backing off if needed. It will return the time that the current failure will result in backoff waiting until, and a bool signalling whether we have blacklisted and therefore to give up.
func (*ServerStatistics) RemoveBlacklist ¶ added in v0.10.4
func (s *ServerStatistics) RemoveBlacklist()
RemoveBlacklist removes the blacklisted status from the server.
func (*ServerStatistics) Success ¶
func (s *ServerStatistics) Success()
Success updates the server statistics with a new successful attempt, which increases the sent counter and resets the idle and failure counters. If a host was blacklisted at this point then we will unblacklist it.
func (*ServerStatistics) SuccessCount ¶
func (s *ServerStatistics) SuccessCount() uint32
SuccessCount returns the number of successful requests. This is usually useful in constructing transaction IDs.
type Statistics ¶
type Statistics struct { DB storage.Database // How many times should we tolerate consecutive failures before we // just blacklist the host altogether? The backoff is exponential, // so the max time here to attempt is 2**failures seconds. FailuresUntilBlacklist uint32 // contains filtered or unexported fields }
Statistics contains information about all of the remote federated hosts that we have interacted with. It is basically a threadsafe wrapper.
func NewStatistics ¶ added in v0.10.4
func NewStatistics(db storage.Database, failuresUntilBlacklist uint32) Statistics
func (*Statistics) ForServer ¶
func (s *Statistics) ForServer(serverName gomatrixserverlib.ServerName) *ServerStatistics
ForServer returns server statistics for the given server name. If it does not exist, it will create empty statistics and return those.