mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Pointers not values
This commit is contained in:
parent
42f0b4cddf
commit
5f96a859e1
|
|
@ -27,7 +27,7 @@ type FederationClientError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *FederationClientError) Error() string {
|
func (e *FederationClientError) Error() string {
|
||||||
return fmt.Sprintf("%s - (retry_after=%d, blacklisted=%v", e.Err, e.RetryAfter, e.Blacklisted)
|
return fmt.Sprintf("%s - (retry_after=%d, blacklisted=%v)", e.Err, e.RetryAfter, e.Blacklisted)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FederationSenderInternalAPI is used to query information from the federation sender.
|
// FederationSenderInternalAPI is used to query information from the federation sender.
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/matrix-org/dendrite/federationsender/storage"
|
"github.com/matrix-org/dendrite/federationsender/storage"
|
||||||
"github.com/matrix-org/dendrite/internal/config"
|
"github.com/matrix-org/dendrite/internal/config"
|
||||||
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
"github.com/matrix-org/gomatrix"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
)
|
)
|
||||||
|
|
@ -67,6 +68,21 @@ func (a *FederationSenderInternalAPI) isBlacklistedOrBackingOff(s gomatrixserver
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func failBlacklistableError(err error, stats *statistics.ServerStatistics) {
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mxerr, ok := err.(gomatrix.HTTPError)
|
||||||
|
if !ok {
|
||||||
|
stats.Failure()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if mxerr.Code == 500 {
|
||||||
|
stats.Failure()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *FederationSenderInternalAPI) GetUserDevices(
|
func (a *FederationSenderInternalAPI) GetUserDevices(
|
||||||
ctx context.Context, s gomatrixserverlib.ServerName, userID string,
|
ctx context.Context, s gomatrixserverlib.ServerName, userID string,
|
||||||
) (gomatrixserverlib.RespUserDevices, error) {
|
) (gomatrixserverlib.RespUserDevices, error) {
|
||||||
|
|
@ -77,7 +93,7 @@ func (a *FederationSenderInternalAPI) GetUserDevices(
|
||||||
}
|
}
|
||||||
res, err = a.federation.GetUserDevices(ctx, s, userID)
|
res, err = a.federation.GetUserDevices(ctx, s, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.Failure()
|
failBlacklistableError(err, stats)
|
||||||
return res, &api.FederationClientError{
|
return res, &api.FederationClientError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +112,7 @@ func (a *FederationSenderInternalAPI) ClaimKeys(
|
||||||
}
|
}
|
||||||
res, err = a.federation.ClaimKeys(ctx, s, oneTimeKeys)
|
res, err = a.federation.ClaimKeys(ctx, s, oneTimeKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.Failure()
|
failBlacklistableError(err, stats)
|
||||||
return res, &api.FederationClientError{
|
return res, &api.FederationClientError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +131,7 @@ func (a *FederationSenderInternalAPI) QueryKeys(
|
||||||
}
|
}
|
||||||
res, err = a.federation.QueryKeys(ctx, s, keys)
|
res, err = a.federation.QueryKeys(ctx, s, keys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.Failure()
|
failBlacklistableError(err, stats)
|
||||||
return res, &api.FederationClientError{
|
return res, &api.FederationClientError{
|
||||||
Err: err.Error(),
|
Err: err.Error(),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ func (h *httpFederationSenderInternalAPI) GetUserDevices(
|
||||||
}
|
}
|
||||||
var response getUserDevices
|
var response getUserDevices
|
||||||
apiURL := h.federationSenderURL + FederationSenderGetUserDevicesPath
|
apiURL := h.federationSenderURL + FederationSenderGetUserDevicesPath
|
||||||
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
@ -189,7 +189,7 @@ func (h *httpFederationSenderInternalAPI) ClaimKeys(
|
||||||
}
|
}
|
||||||
var response claimKeys
|
var response claimKeys
|
||||||
apiURL := h.federationSenderURL + FederationSenderClaimKeysPath
|
apiURL := h.federationSenderURL + FederationSenderClaimKeysPath
|
||||||
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +219,7 @@ func (h *httpFederationSenderInternalAPI) QueryKeys(
|
||||||
}
|
}
|
||||||
var response queryKeys
|
var response queryKeys
|
||||||
apiURL := h.federationSenderURL + FederationSenderQueryKeysPath
|
apiURL := h.federationSenderURL + FederationSenderQueryKeysPath
|
||||||
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue