mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
Initial Store & Forward Implementation (#2917)
This adds store & forward relays into dendrite for p2p. A few things have changed: - new relay api serves new http endpoints for s&f federation - updated outbound federation queueing which will attempt to forward using s&f if appropriate - database entries to track s&f relays for other nodes
This commit is contained in:
parent
48fa869fa3
commit
5b73592f5a
77 changed files with 7646 additions and 1373 deletions
|
@ -109,13 +109,14 @@ func NewFederationInternalAPI(
|
|||
|
||||
func (a *FederationInternalAPI) isBlacklistedOrBackingOff(s gomatrixserverlib.ServerName) (*statistics.ServerStatistics, error) {
|
||||
stats := a.statistics.ForServer(s)
|
||||
until, blacklisted := stats.BackoffInfo()
|
||||
if blacklisted {
|
||||
if stats.Blacklisted() {
|
||||
return stats, &api.FederationClientError{
|
||||
Blacklisted: true,
|
||||
}
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
until := stats.BackoffInfo()
|
||||
if until != nil && now.Before(*until) {
|
||||
return stats, &api.FederationClientError{
|
||||
RetryAfter: time.Until(*until),
|
||||
|
@ -163,7 +164,7 @@ func (a *FederationInternalAPI) doRequestIfNotBackingOffOrBlacklisted(
|
|||
RetryAfter: retryAfter,
|
||||
}
|
||||
}
|
||||
stats.Success()
|
||||
stats.Success(statistics.SendDirect)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,7 @@ func (a *FederationInternalAPI) doRequestIfNotBlacklisted(
|
|||
s gomatrixserverlib.ServerName, request func() (interface{}, error),
|
||||
) (interface{}, error) {
|
||||
stats := a.statistics.ForServer(s)
|
||||
if _, blacklisted := stats.BackoffInfo(); blacklisted {
|
||||
if blacklisted := stats.Blacklisted(); blacklisted {
|
||||
return stats, &api.FederationClientError{
|
||||
Err: fmt.Sprintf("server %q is blacklisted", s),
|
||||
Blacklisted: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue