statistics

package
Version: v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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) 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) Failure

func (s *ServerStatistics) Failure() (time.Time, bool)

Failure marks a failure and starts backing off if needed. The next call to BackoffIfRequired will do the right thing after this. 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) 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 (*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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to