mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
rename FSAPI's PerformPeek as PerformOutboundPeek
This commit is contained in:
parent
8f203febc1
commit
3caae7913b
|
|
@ -33,7 +33,7 @@ func Peek(
|
||||||
roomID, peekID string,
|
roomID, peekID string,
|
||||||
remoteVersions []gomatrixserverlib.RoomVersion,
|
remoteVersions []gomatrixserverlib.RoomVersion,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
// TODO: check if we're just refreshing an existing peek. Somehow.
|
// TODO: check if we're just refreshing an existing peek by querying the federationsender
|
||||||
|
|
||||||
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
|
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
|
||||||
verRes := api.QueryRoomVersionForRoomResponse{}
|
verRes := api.QueryRoomVersionForRoomResponse{}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ type FederationSenderInternalAPI interface {
|
||||||
response *PerformJoinResponse,
|
response *PerformJoinResponse,
|
||||||
)
|
)
|
||||||
// Handle an instruction to peek a room on a remote server.
|
// Handle an instruction to peek a room on a remote server.
|
||||||
PerformPeek(
|
PerformOutboundPeek(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *PerformPeekRequest,
|
request *PerformOutboundPeekRequest,
|
||||||
response *PerformPeekResponse,
|
response *PerformOutboundPeekResponse,
|
||||||
) error
|
) error
|
||||||
// Handle an instruction to make_leave & send_leave with a remote server.
|
// Handle an instruction to make_leave & send_leave with a remote server.
|
||||||
PerformLeave(
|
PerformLeave(
|
||||||
|
|
@ -111,13 +111,13 @@ type PerformJoinResponse struct {
|
||||||
LastError *gomatrix.HTTPError
|
LastError *gomatrix.HTTPError
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformPeekRequest struct {
|
type PerformOutboundPeekRequest struct {
|
||||||
RoomID string `json:"room_id"`
|
RoomID string `json:"room_id"`
|
||||||
// The sorted list of servers to try. Servers will be tried sequentially, after de-duplication.
|
// The sorted list of servers to try. Servers will be tried sequentially, after de-duplication.
|
||||||
ServerNames types.ServerNames `json:"server_names"`
|
ServerNames types.ServerNames `json:"server_names"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformPeekResponse struct {
|
type PerformOutboundPeekResponse struct {
|
||||||
LastError *gomatrix.HTTPError
|
LastError *gomatrix.HTTPError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,11 +208,11 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PerformPeekRequest implements api.FederationSenderInternalAPI
|
// PerformOutboundPeekRequest implements api.FederationSenderInternalAPI
|
||||||
func (r *FederationSenderInternalAPI) PerformPeek(
|
func (r *FederationSenderInternalAPI) PerformOutboundPeek(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *api.PerformPeekRequest,
|
request *api.PerformOutboundPeekRequest,
|
||||||
response *api.PerformPeekResponse,
|
response *api.PerformOutboundPeekResponse,
|
||||||
) error {
|
) error {
|
||||||
// Look up the supported room versions.
|
// Look up the supported room versions.
|
||||||
var supportedVersions []gomatrixserverlib.RoomVersion
|
var supportedVersions []gomatrixserverlib.RoomVersion
|
||||||
|
|
@ -238,7 +238,7 @@ func (r *FederationSenderInternalAPI) PerformPeek(
|
||||||
// successfully completes the peek
|
// successfully completes the peek
|
||||||
var lastErr error
|
var lastErr error
|
||||||
for _, serverName := range request.ServerNames {
|
for _, serverName := range request.ServerNames {
|
||||||
if err := r.performPeekUsingServer(
|
if err := r.performOutboundPeekUsingServer(
|
||||||
ctx,
|
ctx,
|
||||||
request.RoomID,
|
request.RoomID,
|
||||||
serverName,
|
serverName,
|
||||||
|
|
@ -279,7 +279,7 @@ func (r *FederationSenderInternalAPI) PerformPeek(
|
||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *FederationSenderInternalAPI) performPeekUsingServer(
|
func (r *FederationSenderInternalAPI) performOutboundPeekUsingServer(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID string,
|
roomID string,
|
||||||
serverName gomatrixserverlib.ServerName,
|
serverName gomatrixserverlib.ServerName,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ const (
|
||||||
FederationSenderPerformJoinRequestPath = "/federationsender/performJoinRequest"
|
FederationSenderPerformJoinRequestPath = "/federationsender/performJoinRequest"
|
||||||
FederationSenderPerformLeaveRequestPath = "/federationsender/performLeaveRequest"
|
FederationSenderPerformLeaveRequestPath = "/federationsender/performLeaveRequest"
|
||||||
FederationSenderPerformInviteRequestPath = "/federationsender/performInviteRequest"
|
FederationSenderPerformInviteRequestPath = "/federationsender/performInviteRequest"
|
||||||
FederationSenderPerformPeekRequestPath = "/federationsender/performPeekRequest"
|
FederationSenderPerformOutboundPeekRequestPath = "/federationsender/performOutboundPeekRequest"
|
||||||
FederationSenderPerformServersAlivePath = "/federationsender/performServersAlive"
|
FederationSenderPerformServersAlivePath = "/federationsender/performServersAlive"
|
||||||
FederationSenderPerformBroadcastEDUPath = "/federationsender/performBroadcastEDU"
|
FederationSenderPerformBroadcastEDUPath = "/federationsender/performBroadcastEDU"
|
||||||
|
|
||||||
|
|
@ -74,15 +74,15 @@ func (h *httpFederationSenderInternalAPI) PerformInvite(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle starting a peek on a remote server.
|
// Handle starting a peek on a remote server.
|
||||||
func (h *httpFederationSenderInternalAPI) PerformPeek(
|
func (h *httpFederationSenderInternalAPI) PerformOutboundPeek(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *api.PerformPeekRequest,
|
request *api.PerformOutboundPeekRequest,
|
||||||
response *api.PerformPeekResponse,
|
response *api.PerformOutboundPeekResponse,
|
||||||
) error {
|
) error {
|
||||||
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformPeekRequest")
|
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformOutboundPeekRequest")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
apiURL := h.federationSenderURL + FederationSenderPerformPeekRequestPath
|
apiURL := h.federationSenderURL + FederationSenderPerformOutboundPeekRequestPath
|
||||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,5 +1,7 @@
|
||||||
module github.com/matrix-org/dendrite
|
module github.com/matrix-org/dendrite
|
||||||
|
|
||||||
|
replace github.com/matrix-org/gomatrixserverlib => ../gomatrixserverlib
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Shopify/sarama v1.27.0
|
github.com/Shopify/sarama v1.27.0
|
||||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
|
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ const (
|
||||||
OutputTypeNewPeek OutputType = "new_peek"
|
OutputTypeNewPeek OutputType = "new_peek"
|
||||||
|
|
||||||
// OutputTypeNewInboundPeek indicates that the kafka event is an OutputNewInboundPeek
|
// OutputTypeNewInboundPeek indicates that the kafka event is an OutputNewInboundPeek
|
||||||
OutputTypeNewInboundPeek OutputType = "new_remote_peek"
|
OutputTypeNewInboundPeek OutputType = "new_inbound_peek"
|
||||||
)
|
)
|
||||||
|
|
||||||
// An OutputEvent is an entry in the roomserver output kafka log.
|
// An OutputEvent is an entry in the roomserver output kafka log.
|
||||||
|
|
@ -70,7 +70,7 @@ type OutputEvent struct {
|
||||||
// The content of event with type OutputTypeNewPeek
|
// The content of event with type OutputTypeNewPeek
|
||||||
NewPeek *OutputNewPeek `json:"new_peek,omitempty"`
|
NewPeek *OutputNewPeek `json:"new_peek,omitempty"`
|
||||||
// The content of event with type OutputTypeNewInboundPeek
|
// The content of event with type OutputTypeNewInboundPeek
|
||||||
NewInboundPeek *OutputNewInboundPeek `json:"new_remote_peek,omitempty"`
|
NewInboundPeek *OutputNewInboundPeek `json:"new_inbound_peek,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// An OutputNewRoomEvent is written when the roomserver receives a new event.
|
// An OutputNewRoomEvent is written when the roomserver receives a new event.
|
||||||
|
|
|
||||||
|
|
@ -159,12 +159,12 @@ func (r *Peeker) performPeekRoomByID(
|
||||||
req.ServerNames = append(req.ServerNames, domain)
|
req.ServerNames = append(req.ServerNames, domain)
|
||||||
|
|
||||||
// Try peeking by all of the supplied server names.
|
// Try peeking by all of the supplied server names.
|
||||||
fedReq := fsAPI.PerformPeekRequest{
|
fedReq := fsAPI.PerformOutboundPeekRequest{
|
||||||
RoomID: req.RoomIDOrAlias, // the room ID to try and peek
|
RoomID: req.RoomIDOrAlias, // the room ID to try and peek
|
||||||
ServerNames: req.ServerNames, // the servers to try peeking via
|
ServerNames: req.ServerNames, // the servers to try peeking via
|
||||||
}
|
}
|
||||||
fedRes := fsAPI.PerformPeekResponse{}
|
fedRes := fsAPI.PerformOutboundPeekResponse{}
|
||||||
r.FSAPI.PerformPeek(ctx, &fedReq, &fedRes)
|
r.FSAPI.PerformOutboundPeek(ctx, &fedReq, &fedRes)
|
||||||
if fedRes.LastError != nil {
|
if fedRes.LastError != nil {
|
||||||
return "", &api.PerformError{
|
return "", &api.PerformError{
|
||||||
Code: api.PerformErrRemote,
|
Code: api.PerformErrRemote,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue