mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Replace common timeout in fed client with const
This commit is contained in:
parent
c21d59441e
commit
be37c70d46
|
|
@ -9,13 +9,15 @@ import (
|
|||
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||
)
|
||||
|
||||
const defaultTimeout = time.Second * 30
|
||||
|
||||
// Functions here are "proxying" calls to the gomatrixserverlib federation
|
||||
// client.
|
||||
|
||||
func (a *FederationInternalAPI) MakeJoin(
|
||||
ctx context.Context, origin, s spec.ServerName, roomID, userID string,
|
||||
) (res gomatrixserverlib.MakeJoinResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.MakeJoin(ctx, origin, s, roomID, userID)
|
||||
|
|
@ -30,7 +32,7 @@ func (a *FederationInternalAPI) MakeJoin(
|
|||
func (a *FederationInternalAPI) SendJoin(
|
||||
ctx context.Context, origin, s spec.ServerName, event *gomatrixserverlib.Event,
|
||||
) (res gomatrixserverlib.SendJoinResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.SendJoin(ctx, origin, s, event)
|
||||
|
|
@ -46,7 +48,7 @@ func (a *FederationInternalAPI) GetEventAuth(
|
|||
ctx context.Context, origin, s spec.ServerName,
|
||||
roomVersion gomatrixserverlib.RoomVersion, roomID, eventID string,
|
||||
) (res fclient.RespEventAuth, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.GetEventAuth(ctx, origin, s, roomVersion, roomID, eventID)
|
||||
|
|
@ -60,7 +62,7 @@ func (a *FederationInternalAPI) GetEventAuth(
|
|||
func (a *FederationInternalAPI) GetUserDevices(
|
||||
ctx context.Context, origin, s spec.ServerName, userID string,
|
||||
) (fclient.RespUserDevices, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.GetUserDevices(ctx, origin, s, userID)
|
||||
|
|
@ -74,7 +76,7 @@ func (a *FederationInternalAPI) GetUserDevices(
|
|||
func (a *FederationInternalAPI) ClaimKeys(
|
||||
ctx context.Context, origin, s spec.ServerName, oneTimeKeys map[string]map[string]string,
|
||||
) (fclient.RespClaimKeys, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.ClaimKeys(ctx, origin, s, oneTimeKeys)
|
||||
|
|
@ -100,7 +102,7 @@ func (a *FederationInternalAPI) QueryKeys(
|
|||
func (a *FederationInternalAPI) Backfill(
|
||||
ctx context.Context, origin, s spec.ServerName, roomID string, limit int, eventIDs []string,
|
||||
) (res gomatrixserverlib.Transaction, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.Backfill(ctx, origin, s, roomID, limit, eventIDs)
|
||||
|
|
@ -114,7 +116,7 @@ func (a *FederationInternalAPI) Backfill(
|
|||
func (a *FederationInternalAPI) LookupState(
|
||||
ctx context.Context, origin, s spec.ServerName, roomID, eventID string, roomVersion gomatrixserverlib.RoomVersion,
|
||||
) (res gomatrixserverlib.StateResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.LookupState(ctx, origin, s, roomID, eventID, roomVersion)
|
||||
|
|
@ -129,7 +131,7 @@ func (a *FederationInternalAPI) LookupState(
|
|||
func (a *FederationInternalAPI) LookupStateIDs(
|
||||
ctx context.Context, origin, s spec.ServerName, roomID, eventID string,
|
||||
) (res gomatrixserverlib.StateIDResponse, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.LookupStateIDs(ctx, origin, s, roomID, eventID)
|
||||
|
|
@ -144,7 +146,7 @@ func (a *FederationInternalAPI) LookupMissingEvents(
|
|||
ctx context.Context, origin, s spec.ServerName, roomID string,
|
||||
missing fclient.MissingEvents, roomVersion gomatrixserverlib.RoomVersion,
|
||||
) (res fclient.RespMissingEvents, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.LookupMissingEvents(ctx, origin, s, roomID, missing, roomVersion)
|
||||
|
|
@ -158,7 +160,7 @@ func (a *FederationInternalAPI) LookupMissingEvents(
|
|||
func (a *FederationInternalAPI) GetEvent(
|
||||
ctx context.Context, origin, s spec.ServerName, eventID string,
|
||||
) (res gomatrixserverlib.Transaction, err error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
ires, err := a.doRequestIfNotBlacklisted(s, func() (interface{}, error) {
|
||||
return a.federation.GetEvent(ctx, origin, s, eventID)
|
||||
|
|
|
|||
Loading…
Reference in a new issue