mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 10:53:09 -06:00
Replace QueryPreviousEvents with QueryBackfill
This commit is contained in:
parent
5891a0d078
commit
77366c2bab
|
|
@ -31,7 +31,7 @@ func Backfill(
|
||||||
query api.RoomserverQueryAPI,
|
query api.RoomserverQueryAPI,
|
||||||
roomID string,
|
roomID string,
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
var res api.QueryPreviousEventsResponse
|
var res api.QueryBackfillResponse
|
||||||
var eIDs []string
|
var eIDs []string
|
||||||
var limit string
|
var limit string
|
||||||
var exists bool
|
var exists bool
|
||||||
|
|
@ -62,7 +62,7 @@ func Backfill(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the request.
|
// Populate the request.
|
||||||
req := api.QueryPreviousEventsRequest{
|
req := api.QueryBackfillRequest{
|
||||||
EarliestEventsIDs: eIDs,
|
EarliestEventsIDs: eIDs,
|
||||||
ServerName: request.Origin(),
|
ServerName: request.Origin(),
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ func Backfill(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query the roomserver.
|
// Query the roomserver.
|
||||||
if err = query.QueryPreviousEvents(httpReq.Context(), &req, &res); err != nil {
|
if err = query.QueryBackfill(httpReq.Context(), &req, &res); err != nil {
|
||||||
return httputil.LogThenError(httpReq, err)
|
return httputil.LogThenError(httpReq, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -214,8 +214,8 @@ type QueryStateAndAuthChainResponse struct {
|
||||||
AuthChainEvents []gomatrixserverlib.Event `json:"auth_chain_events"`
|
AuthChainEvents []gomatrixserverlib.Event `json:"auth_chain_events"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryPreviousEventsRequest is a request to QueryPreviousEvents.
|
// QueryBackfillRequest is a request to QueryBackfill.
|
||||||
type QueryPreviousEventsRequest struct {
|
type QueryBackfillRequest struct {
|
||||||
// Events to start paginating from.
|
// Events to start paginating from.
|
||||||
EarliestEventsIDs []string `json:"earliest_event_ids"`
|
EarliestEventsIDs []string `json:"earliest_event_ids"`
|
||||||
// The maximum number of events to retrieve.
|
// The maximum number of events to retrieve.
|
||||||
|
|
@ -224,8 +224,8 @@ type QueryPreviousEventsRequest struct {
|
||||||
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryPreviousEventsResponse is a response to QueryPreviousEvents.
|
// QueryBackfillResponse is a response to QueryBackfill.
|
||||||
type QueryPreviousEventsResponse struct {
|
type QueryBackfillResponse struct {
|
||||||
// Missing events, arbritrary order.
|
// Missing events, arbritrary order.
|
||||||
Events []gomatrixserverlib.Event `json:"events"`
|
Events []gomatrixserverlib.Event `json:"events"`
|
||||||
}
|
}
|
||||||
|
|
@ -298,10 +298,10 @@ type RoomserverQueryAPI interface {
|
||||||
) error
|
) error
|
||||||
|
|
||||||
// Query a given amount (or less) of events prior to a given set of events.
|
// Query a given amount (or less) of events prior to a given set of events.
|
||||||
QueryPreviousEvents(
|
QueryBackfill(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *QueryPreviousEventsRequest,
|
request *QueryBackfillRequest,
|
||||||
response *QueryPreviousEventsResponse,
|
response *QueryBackfillResponse,
|
||||||
) error
|
) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,8 +332,8 @@ const RoomserverQueryMissingEventsPath = "/api/roomserver/queryMissingEvents"
|
||||||
// RoomserverQueryStateAndAuthChainPath is the HTTP path for the QueryStateAndAuthChain API
|
// RoomserverQueryStateAndAuthChainPath is the HTTP path for the QueryStateAndAuthChain API
|
||||||
const RoomserverQueryStateAndAuthChainPath = "/api/roomserver/queryStateAndAuthChain"
|
const RoomserverQueryStateAndAuthChainPath = "/api/roomserver/queryStateAndAuthChain"
|
||||||
|
|
||||||
// RoomserverQueryPreviousEventsPath is the HTTP path for the QueryMissingEvents API
|
// RoomserverQueryBackfillPath is the HTTP path for the QueryMissingEvents API
|
||||||
const RoomserverQueryPreviousEventsPath = "/api/roomserver/queryPreviousEvents"
|
const RoomserverQueryBackfillPath = "/api/roomserver/QueryBackfill"
|
||||||
|
|
||||||
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
||||||
// If httpClient is nil then it uses the http.DefaultClient
|
// If httpClient is nil then it uses the http.DefaultClient
|
||||||
|
|
@ -466,13 +466,13 @@ func (h *httpRoomserverQueryAPI) QueryStateAndAuthChain(
|
||||||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryPreviousEvents implements RoomServerQueryAPI
|
// QueryBackfill implements RoomServerQueryAPI
|
||||||
func (h *httpRoomserverQueryAPI) QueryPreviousEvents(
|
func (h *httpRoomserverQueryAPI) QueryBackfill(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *QueryPreviousEventsRequest,
|
request *QueryBackfillRequest,
|
||||||
response *QueryPreviousEventsResponse,
|
response *QueryBackfillResponse,
|
||||||
) error {
|
) error {
|
||||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryPreviousEvents")
|
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryBackfill")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
apiURL := h.roomserverURL + RoomserverQueryMissingEventsPath
|
apiURL := h.roomserverURL + RoomserverQueryMissingEventsPath
|
||||||
|
|
|
||||||
|
|
@ -458,11 +458,11 @@ func (r *RoomserverQueryAPI) QueryMissingEvents(
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryPreviousEvents implements api.RoomServerQueryAPI
|
// QueryBackfill implements api.RoomServerQueryAPI
|
||||||
func (r *RoomserverQueryAPI) QueryPreviousEvents(
|
func (r *RoomserverQueryAPI) QueryBackfill(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
request *api.QueryPreviousEventsRequest,
|
request *api.QueryBackfillRequest,
|
||||||
response *api.QueryPreviousEventsResponse,
|
response *api.QueryBackfillResponse,
|
||||||
) error {
|
) error {
|
||||||
var err error
|
var err error
|
||||||
var front []string
|
var front []string
|
||||||
|
|
@ -773,14 +773,14 @@ func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
servMux.Handle(
|
servMux.Handle(
|
||||||
api.RoomserverQueryPreviousEventsPath,
|
api.RoomserverQueryBackfillPath,
|
||||||
common.MakeInternalAPI("queryPreviousEvents", func(req *http.Request) util.JSONResponse {
|
common.MakeInternalAPI("QueryBackfill", func(req *http.Request) util.JSONResponse {
|
||||||
var request api.QueryPreviousEventsRequest
|
var request api.QueryBackfillRequest
|
||||||
var response api.QueryPreviousEventsResponse
|
var response api.QueryBackfillResponse
|
||||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
if err := r.QueryPreviousEvents(req.Context(), &request, &response); err != nil {
|
if err := r.QueryBackfill(req.Context(), &request, &response); err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
}
|
}
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue