Rehuffle where things are in the internal package (#1122)

renamed:    internal/eventcontent.go -> internal/eventutil/eventcontent.go
	renamed:    internal/events.go -> internal/eventutil/events.go
	renamed:    internal/types.go -> internal/eventutil/types.go
	renamed:    internal/http/http.go -> internal/httputil/http.go
	renamed:    internal/httpapi.go -> internal/httputil/httpapi.go
	renamed:    internal/httpapi_test.go -> internal/httputil/httpapi_test.go
	renamed:    internal/httpapis/paths.go -> internal/httputil/paths.go
	renamed:    internal/routing.go -> internal/httputil/routing.go
	renamed:    internal/basecomponent/base.go -> internal/setup/base.go
	renamed:    internal/basecomponent/flags.go -> internal/setup/flags.go
	renamed:    internal/partition_offset_table.go -> internal/sqlutil/partition_offset_table.go
	renamed:    internal/postgres.go -> internal/sqlutil/postgres.go
	renamed:    internal/postgres_wasm.go -> internal/sqlutil/postgres_wasm.go
	renamed:    internal/sql.go -> internal/sqlutil/sql.go
This commit is contained in:
Kegsay 2020-06-12 14:55:57 +01:00 committed by GitHub
parent 4675e1ddb6
commit ecd7accbad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 784 additions and 693 deletions

View file

@ -7,7 +7,7 @@ import (
fsInputAPI "github.com/matrix-org/dendrite/federationsender/api"
"github.com/matrix-org/dendrite/internal/caching"
internalHTTP "github.com/matrix-org/dendrite/internal/http"
"github.com/matrix-org/dendrite/internal/httputil"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/opentracing/opentracing-go"
)
@ -78,7 +78,7 @@ func (h *httpRoomserverInternalAPI) SetRoomAlias(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverSetRoomAliasPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// GetRoomIDForAlias implements RoomserverAliasAPI
@ -91,7 +91,7 @@ func (h *httpRoomserverInternalAPI) GetRoomIDForAlias(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverGetRoomIDForAliasPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// GetAliasesForRoomID implements RoomserverAliasAPI
@ -104,7 +104,7 @@ func (h *httpRoomserverInternalAPI) GetAliasesForRoomID(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverGetAliasesForRoomIDPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// GetCreatorIDForAlias implements RoomserverAliasAPI
@ -117,7 +117,7 @@ func (h *httpRoomserverInternalAPI) GetCreatorIDForAlias(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverGetCreatorIDForAliasPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// RemoveRoomAlias implements RoomserverAliasAPI
@ -130,7 +130,7 @@ func (h *httpRoomserverInternalAPI) RemoveRoomAlias(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverRemoveRoomAliasPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// InputRoomEvents implements RoomserverInputAPI
@ -143,7 +143,7 @@ func (h *httpRoomserverInternalAPI) InputRoomEvents(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverInputRoomEventsPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
func (h *httpRoomserverInternalAPI) PerformJoin(
@ -155,7 +155,7 @@ func (h *httpRoomserverInternalAPI) PerformJoin(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverPerformJoinPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
func (h *httpRoomserverInternalAPI) PerformLeave(
@ -167,7 +167,7 @@ func (h *httpRoomserverInternalAPI) PerformLeave(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverPerformLeavePath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryLatestEventsAndState implements RoomserverQueryAPI
@ -180,7 +180,7 @@ func (h *httpRoomserverInternalAPI) QueryLatestEventsAndState(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryLatestEventsAndStatePath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryStateAfterEvents implements RoomserverQueryAPI
@ -193,7 +193,7 @@ func (h *httpRoomserverInternalAPI) QueryStateAfterEvents(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryStateAfterEventsPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryEventsByID implements RoomserverQueryAPI
@ -206,7 +206,7 @@ func (h *httpRoomserverInternalAPI) QueryEventsByID(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryEventsByIDPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryMembershipForUser implements RoomserverQueryAPI
@ -219,7 +219,7 @@ func (h *httpRoomserverInternalAPI) QueryMembershipForUser(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryMembershipForUserPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryMembershipsForRoom implements RoomserverQueryAPI
@ -232,7 +232,7 @@ func (h *httpRoomserverInternalAPI) QueryMembershipsForRoom(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryMembershipsForRoomPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryServerAllowedToSeeEvent implements RoomserverQueryAPI
@ -245,7 +245,7 @@ func (h *httpRoomserverInternalAPI) QueryServerAllowedToSeeEvent(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryServerAllowedToSeeEventPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryMissingEvents implements RoomServerQueryAPI
@ -258,7 +258,7 @@ func (h *httpRoomserverInternalAPI) QueryMissingEvents(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryMissingEventsPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryStateAndAuthChain implements RoomserverQueryAPI
@ -271,7 +271,7 @@ func (h *httpRoomserverInternalAPI) QueryStateAndAuthChain(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryStateAndAuthChainPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// PerformBackfill implements RoomServerQueryAPI
@ -284,7 +284,7 @@ func (h *httpRoomserverInternalAPI) PerformBackfill(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverPerformBackfillPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryRoomVersionCapabilities implements RoomServerQueryAPI
@ -297,7 +297,7 @@ func (h *httpRoomserverInternalAPI) QueryRoomVersionCapabilities(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryRoomVersionCapabilitiesPath
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryRoomVersionForRoom implements RoomServerQueryAPI
@ -315,7 +315,7 @@ func (h *httpRoomserverInternalAPI) QueryRoomVersionForRoom(
defer span.Finish()
apiURL := h.roomserverURL + RoomserverQueryRoomVersionForRoomPath
err := internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
if err == nil {
h.cache.StoreRoomVersion(request.RoomID, response.RoomVersion)
}

View file

@ -5,7 +5,7 @@ import (
"net/http"
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/httputil"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/util"
)
@ -14,7 +14,7 @@ import (
// nolint: gocyclo
func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
internalAPIMux.Handle(RoomserverInputRoomEventsPath,
internal.MakeInternalAPI("inputRoomEvents", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("inputRoomEvents", func(req *http.Request) util.JSONResponse {
var request api.InputRoomEventsRequest
var response api.InputRoomEventsResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -27,7 +27,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
}),
)
internalAPIMux.Handle(RoomserverPerformJoinPath,
internal.MakeInternalAPI("performJoin", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("performJoin", func(req *http.Request) util.JSONResponse {
var request api.PerformJoinRequest
var response api.PerformJoinResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -40,7 +40,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
}),
)
internalAPIMux.Handle(RoomserverPerformLeavePath,
internal.MakeInternalAPI("performLeave", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("performLeave", func(req *http.Request) util.JSONResponse {
var request api.PerformLeaveRequest
var response api.PerformLeaveResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -54,7 +54,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryLatestEventsAndStatePath,
internal.MakeInternalAPI("queryLatestEventsAndState", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryLatestEventsAndState", func(req *http.Request) util.JSONResponse {
var request api.QueryLatestEventsAndStateRequest
var response api.QueryLatestEventsAndStateResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -68,7 +68,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryStateAfterEventsPath,
internal.MakeInternalAPI("queryStateAfterEvents", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryStateAfterEvents", func(req *http.Request) util.JSONResponse {
var request api.QueryStateAfterEventsRequest
var response api.QueryStateAfterEventsResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -82,7 +82,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryEventsByIDPath,
internal.MakeInternalAPI("queryEventsByID", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryEventsByID", func(req *http.Request) util.JSONResponse {
var request api.QueryEventsByIDRequest
var response api.QueryEventsByIDResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -96,7 +96,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryMembershipForUserPath,
internal.MakeInternalAPI("QueryMembershipForUser", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("QueryMembershipForUser", func(req *http.Request) util.JSONResponse {
var request api.QueryMembershipForUserRequest
var response api.QueryMembershipForUserResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -110,7 +110,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryMembershipsForRoomPath,
internal.MakeInternalAPI("queryMembershipsForRoom", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryMembershipsForRoom", func(req *http.Request) util.JSONResponse {
var request api.QueryMembershipsForRoomRequest
var response api.QueryMembershipsForRoomResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -124,7 +124,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryServerAllowedToSeeEventPath,
internal.MakeInternalAPI("queryServerAllowedToSeeEvent", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryServerAllowedToSeeEvent", func(req *http.Request) util.JSONResponse {
var request api.QueryServerAllowedToSeeEventRequest
var response api.QueryServerAllowedToSeeEventResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -138,7 +138,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryMissingEventsPath,
internal.MakeInternalAPI("queryMissingEvents", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryMissingEvents", func(req *http.Request) util.JSONResponse {
var request api.QueryMissingEventsRequest
var response api.QueryMissingEventsResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -152,7 +152,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryStateAndAuthChainPath,
internal.MakeInternalAPI("queryStateAndAuthChain", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("queryStateAndAuthChain", func(req *http.Request) util.JSONResponse {
var request api.QueryStateAndAuthChainRequest
var response api.QueryStateAndAuthChainResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -166,7 +166,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverPerformBackfillPath,
internal.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("PerformBackfill", func(req *http.Request) util.JSONResponse {
var request api.PerformBackfillRequest
var response api.PerformBackfillResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -180,7 +180,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryRoomVersionCapabilitiesPath,
internal.MakeInternalAPI("QueryRoomVersionCapabilities", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("QueryRoomVersionCapabilities", func(req *http.Request) util.JSONResponse {
var request api.QueryRoomVersionCapabilitiesRequest
var response api.QueryRoomVersionCapabilitiesResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -194,7 +194,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverQueryRoomVersionForRoomPath,
internal.MakeInternalAPI("QueryRoomVersionForRoom", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("QueryRoomVersionForRoom", func(req *http.Request) util.JSONResponse {
var request api.QueryRoomVersionForRoomRequest
var response api.QueryRoomVersionForRoomResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -208,7 +208,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverSetRoomAliasPath,
internal.MakeInternalAPI("setRoomAlias", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("setRoomAlias", func(req *http.Request) util.JSONResponse {
var request api.SetRoomAliasRequest
var response api.SetRoomAliasResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -222,7 +222,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverGetRoomIDForAliasPath,
internal.MakeInternalAPI("GetRoomIDForAlias", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("GetRoomIDForAlias", func(req *http.Request) util.JSONResponse {
var request api.GetRoomIDForAliasRequest
var response api.GetRoomIDForAliasResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -236,7 +236,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverGetCreatorIDForAliasPath,
internal.MakeInternalAPI("GetCreatorIDForAlias", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("GetCreatorIDForAlias", func(req *http.Request) util.JSONResponse {
var request api.GetCreatorIDForAliasRequest
var response api.GetCreatorIDForAliasResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -250,7 +250,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverGetAliasesForRoomIDPath,
internal.MakeInternalAPI("getAliasesForRoomID", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("getAliasesForRoomID", func(req *http.Request) util.JSONResponse {
var request api.GetAliasesForRoomIDRequest
var response api.GetAliasesForRoomIDResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@ -264,7 +264,7 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
)
internalAPIMux.Handle(
RoomserverRemoveRoomAliasPath,
internal.MakeInternalAPI("removeRoomAlias", func(req *http.Request) util.JSONResponse {
httputil.MakeInternalAPI("removeRoomAlias", func(req *http.Request) util.JSONResponse {
var request api.RemoveRoomAliasRequest
var response api.RemoveRoomAliasResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {