Documentation ¶
Index ¶
- type SendMethod
- type ServerStatistics
- func (s *ServerStatistics) AddRelayServers(relayServers []spec.ServerName)
- func (s *ServerStatistics) AssignBackoffNotifier(notifier func())
- func (s *ServerStatistics) AssumedOffline() bool
- func (s *ServerStatistics) BackoffInfo() *time.Time
- func (s *ServerStatistics) Blacklisted() bool
- func (s *ServerStatistics) ClearBackoff()
- func (s *ServerStatistics) Failure() (time.Time, bool)
- func (s *ServerStatistics) KnownRelayServers() []spec.ServerName
- func (s *ServerStatistics) MarkServerAlive() bool
- func (s *ServerStatistics) Success(method SendMethod)
- func (s *ServerStatistics) SuccessCount() uint32
- type Statistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SendMethod ¶ added in v0.11.1
type SendMethod uint8
const ( SendDirect SendMethod = iota SendViaRelay )
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) AddRelayServers ¶ added in v0.11.1
func (s *ServerStatistics) AddRelayServers(relayServers []spec.ServerName)
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) AssumedOffline ¶ added in v0.11.1
func (s *ServerStatistics) AssumedOffline() bool
AssumedOffline returns true if the server is assumed offline and false otherwise.
func (*ServerStatistics) BackoffInfo ¶
func (s *ServerStatistics) BackoffInfo() *time.Time
BackoffInfo returns information about the current or previous backoff. Returns the last backoffUntil time.
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) KnownRelayServers ¶ added in v0.11.1
func (s *ServerStatistics) KnownRelayServers() []spec.ServerName
KnownRelayServers returns the list of relay servers associated with this server.
func (*ServerStatistics) MarkServerAlive ¶ added in v0.11.1
func (s *ServerStatistics) MarkServerAlive() bool
MarkServerAlive removes the assumed offline and blacklisted statuses from this server. Returns whether the server was blacklisted before this point.
func (*ServerStatistics) Success ¶
func (s *ServerStatistics) Success(method SendMethod)
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. `relay` specifies whether the success was to the actual destination or one of their relay servers.
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 // How many times should we tolerate consecutive failures before we // mark the destination as offline. At this point we should attempt // to send messages to the user's async relay servers if we know them. FailuresUntilAssumedOffline 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, failuresUntilAssumedOffline uint32, ) Statistics
func (*Statistics) ForServer ¶
func (s *Statistics) ForServer(serverName spec.ServerName) *ServerStatistics
ForServer returns server statistics for the given server name. If it does not exist, it will create empty statistics and return those.