aboutsummaryrefslogtreecommitdiff
path: root/federationsender
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-12 14:55:57 +0100
committerGitHub <noreply@github.com>2020-06-12 14:55:57 +0100
commitecd7accbad724f26248498a9035a1fbc69e2f08d (patch)
treede2c795b209c4527bc907570dfd1308cfa19be6f /federationsender
parent4675e1ddb6a48fe1425032dc4f3cef56cbde7243 (diff)
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
Diffstat (limited to 'federationsender')
-rw-r--r--federationsender/federationsender.go4
-rw-r--r--federationsender/inthttp/client.go12
-rw-r--r--federationsender/inthttp/server.go12
-rw-r--r--federationsender/storage/postgres/joined_hosts_table.go7
-rw-r--r--federationsender/storage/postgres/room_table.go8
-rw-r--r--federationsender/storage/postgres/storage.go7
-rw-r--r--federationsender/storage/sqlite3/joined_hosts_table.go7
-rw-r--r--federationsender/storage/sqlite3/room_table.go8
-rw-r--r--federationsender/storage/sqlite3/storage.go7
-rw-r--r--federationsender/storage/storage.go4
-rw-r--r--federationsender/storage/storage_wasm.go4
11 files changed, 40 insertions, 40 deletions
diff --git a/federationsender/federationsender.go b/federationsender/federationsender.go
index 621920ef..10ac51c8 100644
--- a/federationsender/federationsender.go
+++ b/federationsender/federationsender.go
@@ -23,7 +23,7 @@ import (
"github.com/matrix-org/dendrite/federationsender/queue"
"github.com/matrix-org/dendrite/federationsender/storage"
"github.com/matrix-org/dendrite/federationsender/types"
- "github.com/matrix-org/dendrite/internal/basecomponent"
+ "github.com/matrix-org/dendrite/internal/setup"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
@@ -38,7 +38,7 @@ func AddInternalRoutes(router *mux.Router, intAPI api.FederationSenderInternalAP
// NewInternalAPI returns a concerete implementation of the internal API. Callers
// can call functions directly on the returned API or via an HTTP interface using AddInternalRoutes.
func NewInternalAPI(
- base *basecomponent.BaseDendrite,
+ base *setup.BaseDendrite,
federation *gomatrixserverlib.FederationClient,
rsAPI roomserverAPI.RoomserverInternalAPI,
keyRing *gomatrixserverlib.KeyRing,
diff --git a/federationsender/inthttp/client.go b/federationsender/inthttp/client.go
index 1e243c60..5da4b35f 100644
--- a/federationsender/inthttp/client.go
+++ b/federationsender/inthttp/client.go
@@ -6,7 +6,7 @@ import (
"net/http"
"github.com/matrix-org/dendrite/federationsender/api"
- internalHTTP "github.com/matrix-org/dendrite/internal/http"
+ "github.com/matrix-org/dendrite/internal/httputil"
"github.com/opentracing/opentracing-go"
)
@@ -44,7 +44,7 @@ func (h *httpFederationSenderInternalAPI) PerformLeave(
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformLeaveRequestPath
- return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
func (h *httpFederationSenderInternalAPI) PerformServersAlive(
@@ -56,7 +56,7 @@ func (h *httpFederationSenderInternalAPI) PerformServersAlive(
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformServersAlivePath
- return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// QueryJoinedHostServerNamesInRoom implements FederationSenderInternalAPI
@@ -69,7 +69,7 @@ func (h *httpFederationSenderInternalAPI) QueryJoinedHostServerNamesInRoom(
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderQueryJoinedHostServerNamesInRoomPath
- return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// Handle an instruction to make_join & send_join with a remote server.
@@ -82,7 +82,7 @@ func (h *httpFederationSenderInternalAPI) PerformJoin(
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformJoinRequestPath
- return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
// Handle an instruction to make_join & send_join with a remote server.
@@ -95,5 +95,5 @@ func (h *httpFederationSenderInternalAPI) PerformDirectoryLookup(
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformDirectoryLookupRequestPath
- return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
+ return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
diff --git a/federationsender/inthttp/server.go b/federationsender/inthttp/server.go
index a9076661..babd3ae1 100644
--- a/federationsender/inthttp/server.go
+++ b/federationsender/inthttp/server.go
@@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/federationsender/api"
- "github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/httputil"
"github.com/matrix-org/util"
)
@@ -14,7 +14,7 @@ import (
func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Router) {
internalAPIMux.Handle(
FederationSenderQueryJoinedHostServerNamesInRoomPath,
- internal.MakeInternalAPI("QueryJoinedHostServerNamesInRoom", func(req *http.Request) util.JSONResponse {
+ httputil.MakeInternalAPI("QueryJoinedHostServerNamesInRoom", func(req *http.Request) util.JSONResponse {
var request api.QueryJoinedHostServerNamesInRoomRequest
var response api.QueryJoinedHostServerNamesInRoomResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@@ -27,7 +27,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
}),
)
internalAPIMux.Handle(FederationSenderPerformJoinRequestPath,
- internal.MakeInternalAPI("PerformJoinRequest", func(req *http.Request) util.JSONResponse {
+ httputil.MakeInternalAPI("PerformJoinRequest", 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(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
}),
)
internalAPIMux.Handle(FederationSenderPerformLeaveRequestPath,
- internal.MakeInternalAPI("PerformLeaveRequest", func(req *http.Request) util.JSONResponse {
+ httputil.MakeInternalAPI("PerformLeaveRequest", func(req *http.Request) util.JSONResponse {
var request api.PerformLeaveRequest
var response api.PerformLeaveResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@@ -53,7 +53,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
}),
)
internalAPIMux.Handle(FederationSenderPerformDirectoryLookupRequestPath,
- internal.MakeInternalAPI("PerformDirectoryLookupRequest", func(req *http.Request) util.JSONResponse {
+ httputil.MakeInternalAPI("PerformDirectoryLookupRequest", func(req *http.Request) util.JSONResponse {
var request api.PerformDirectoryLookupRequest
var response api.PerformDirectoryLookupResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
@@ -66,7 +66,7 @@ func AddRoutes(intAPI api.FederationSenderInternalAPI, internalAPIMux *mux.Route
}),
)
internalAPIMux.Handle(FederationSenderPerformServersAlivePath,
- internal.MakeInternalAPI("PerformServersAliveRequest", func(req *http.Request) util.JSONResponse {
+ httputil.MakeInternalAPI("PerformServersAliveRequest", func(req *http.Request) util.JSONResponse {
var request api.PerformServersAliveRequest
var response api.PerformServersAliveResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
diff --git a/federationsender/storage/postgres/joined_hosts_table.go b/federationsender/storage/postgres/joined_hosts_table.go
index 1b898f48..c0f9a7d5 100644
--- a/federationsender/storage/postgres/joined_hosts_table.go
+++ b/federationsender/storage/postgres/joined_hosts_table.go
@@ -22,6 +22,7 @@ import (
"github.com/lib/pq"
"github.com/matrix-org/dendrite/federationsender/types"
"github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/gomatrixserverlib"
)
@@ -85,7 +86,7 @@ func (s *joinedHostsStatements) insertJoinedHosts(
roomID, eventID string,
serverName gomatrixserverlib.ServerName,
) error {
- stmt := internal.TxStmt(txn, s.insertJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.insertJoinedHostsStmt)
_, err := stmt.ExecContext(ctx, roomID, eventID, serverName)
return err
}
@@ -93,7 +94,7 @@ func (s *joinedHostsStatements) insertJoinedHosts(
func (s *joinedHostsStatements) deleteJoinedHosts(
ctx context.Context, txn *sql.Tx, eventIDs []string,
) error {
- stmt := internal.TxStmt(txn, s.deleteJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.deleteJoinedHostsStmt)
_, err := stmt.ExecContext(ctx, pq.StringArray(eventIDs))
return err
}
@@ -101,7 +102,7 @@ func (s *joinedHostsStatements) deleteJoinedHosts(
func (s *joinedHostsStatements) selectJoinedHostsWithTx(
ctx context.Context, txn *sql.Tx, roomID string,
) ([]types.JoinedHost, error) {
- stmt := internal.TxStmt(txn, s.selectJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.selectJoinedHostsStmt)
return joinedHostsFromStmt(ctx, stmt, roomID)
}
diff --git a/federationsender/storage/postgres/room_table.go b/federationsender/storage/postgres/room_table.go
index c945475b..e5266c63 100644
--- a/federationsender/storage/postgres/room_table.go
+++ b/federationsender/storage/postgres/room_table.go
@@ -19,7 +19,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
)
const roomSchema = `
@@ -71,7 +71,7 @@ func (s *roomStatements) prepare(db *sql.DB) (err error) {
func (s *roomStatements) insertRoom(
ctx context.Context, txn *sql.Tx, roomID string,
) error {
- _, err := internal.TxStmt(txn, s.insertRoomStmt).ExecContext(ctx, roomID)
+ _, err := sqlutil.TxStmt(txn, s.insertRoomStmt).ExecContext(ctx, roomID)
return err
}
@@ -82,7 +82,7 @@ func (s *roomStatements) selectRoomForUpdate(
ctx context.Context, txn *sql.Tx, roomID string,
) (string, error) {
var lastEventID string
- stmt := internal.TxStmt(txn, s.selectRoomForUpdateStmt)
+ stmt := sqlutil.TxStmt(txn, s.selectRoomForUpdateStmt)
err := stmt.QueryRowContext(ctx, roomID).Scan(&lastEventID)
if err != nil {
return "", err
@@ -95,7 +95,7 @@ func (s *roomStatements) selectRoomForUpdate(
func (s *roomStatements) updateRoom(
ctx context.Context, txn *sql.Tx, roomID, lastEventID string,
) error {
- stmt := internal.TxStmt(txn, s.updateRoomStmt)
+ stmt := sqlutil.TxStmt(txn, s.updateRoomStmt)
_, err := stmt.ExecContext(ctx, roomID, lastEventID)
return err
}
diff --git a/federationsender/storage/postgres/storage.go b/federationsender/storage/postgres/storage.go
index a4733a20..8fd4c11a 100644
--- a/federationsender/storage/postgres/storage.go
+++ b/federationsender/storage/postgres/storage.go
@@ -20,7 +20,6 @@ import (
"database/sql"
"github.com/matrix-org/dendrite/federationsender/types"
- "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
)
@@ -28,12 +27,12 @@ import (
type Database struct {
joinedHostsStatements
roomStatements
- internal.PartitionOffsetStatements
+ sqlutil.PartitionOffsetStatements
db *sql.DB
}
// NewDatabase opens a new database
-func NewDatabase(dataSourceName string, dbProperties internal.DbProperties) (*Database, error) {
+func NewDatabase(dataSourceName string, dbProperties sqlutil.DbProperties) (*Database, error) {
var result Database
var err error
if result.db, err = sqlutil.Open("postgres", dataSourceName, dbProperties); err != nil {
@@ -70,7 +69,7 @@ func (d *Database) UpdateRoom(
addHosts []types.JoinedHost,
removeHosts []string,
) (joinedHosts []types.JoinedHost, err error) {
- err = internal.WithTransaction(d.db, func(txn *sql.Tx) error {
+ err = sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error {
err = d.insertRoom(ctx, txn, roomID)
if err != nil {
return err
diff --git a/federationsender/storage/sqlite3/joined_hosts_table.go b/federationsender/storage/sqlite3/joined_hosts_table.go
index 795d3320..d9824658 100644
--- a/federationsender/storage/sqlite3/joined_hosts_table.go
+++ b/federationsender/storage/sqlite3/joined_hosts_table.go
@@ -21,6 +21,7 @@ import (
"github.com/matrix-org/dendrite/federationsender/types"
"github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/gomatrixserverlib"
)
@@ -84,7 +85,7 @@ func (s *joinedHostsStatements) insertJoinedHosts(
roomID, eventID string,
serverName gomatrixserverlib.ServerName,
) error {
- stmt := internal.TxStmt(txn, s.insertJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.insertJoinedHostsStmt)
_, err := stmt.ExecContext(ctx, roomID, eventID, serverName)
return err
}
@@ -93,7 +94,7 @@ func (s *joinedHostsStatements) deleteJoinedHosts(
ctx context.Context, txn *sql.Tx, eventIDs []string,
) error {
for _, eventID := range eventIDs {
- stmt := internal.TxStmt(txn, s.deleteJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.deleteJoinedHostsStmt)
if _, err := stmt.ExecContext(ctx, eventID); err != nil {
return err
}
@@ -104,7 +105,7 @@ func (s *joinedHostsStatements) deleteJoinedHosts(
func (s *joinedHostsStatements) selectJoinedHostsWithTx(
ctx context.Context, txn *sql.Tx, roomID string,
) ([]types.JoinedHost, error) {
- stmt := internal.TxStmt(txn, s.selectJoinedHostsStmt)
+ stmt := sqlutil.TxStmt(txn, s.selectJoinedHostsStmt)
return joinedHostsFromStmt(ctx, stmt, roomID)
}
diff --git a/federationsender/storage/sqlite3/room_table.go b/federationsender/storage/sqlite3/room_table.go
index 4bf9ab81..ca0c4d0b 100644
--- a/federationsender/storage/sqlite3/room_table.go
+++ b/federationsender/storage/sqlite3/room_table.go
@@ -19,7 +19,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
)
const roomSchema = `
@@ -71,7 +71,7 @@ func (s *roomStatements) prepare(db *sql.DB) (err error) {
func (s *roomStatements) insertRoom(
ctx context.Context, txn *sql.Tx, roomID string,
) error {
- _, err := internal.TxStmt(txn, s.insertRoomStmt).ExecContext(ctx, roomID)
+ _, err := sqlutil.TxStmt(txn, s.insertRoomStmt).ExecContext(ctx, roomID)
return err
}
@@ -82,7 +82,7 @@ func (s *roomStatements) selectRoomForUpdate(
ctx context.Context, txn *sql.Tx, roomID string,
) (string, error) {
var lastEventID string
- stmt := internal.TxStmt(txn, s.selectRoomForUpdateStmt)
+ stmt := sqlutil.TxStmt(txn, s.selectRoomForUpdateStmt)
err := stmt.QueryRowContext(ctx, roomID).Scan(&lastEventID)
if err != nil {
return "", err
@@ -95,7 +95,7 @@ func (s *roomStatements) selectRoomForUpdate(
func (s *roomStatements) updateRoom(
ctx context.Context, txn *sql.Tx, roomID, lastEventID string,
) error {
- stmt := internal.TxStmt(txn, s.updateRoomStmt)
+ stmt := sqlutil.TxStmt(txn, s.updateRoomStmt)
_, err := stmt.ExecContext(ctx, roomID, lastEventID)
return err
}
diff --git a/federationsender/storage/sqlite3/storage.go b/federationsender/storage/sqlite3/storage.go
index 8699fc19..ac303f64 100644
--- a/federationsender/storage/sqlite3/storage.go
+++ b/federationsender/storage/sqlite3/storage.go
@@ -22,7 +22,6 @@ import (
_ "github.com/mattn/go-sqlite3"
"github.com/matrix-org/dendrite/federationsender/types"
- "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil"
)
@@ -30,7 +29,7 @@ import (
type Database struct {
joinedHostsStatements
roomStatements
- internal.PartitionOffsetStatements
+ sqlutil.PartitionOffsetStatements
db *sql.DB
}
@@ -42,7 +41,7 @@ func NewDatabase(dataSourceName string) (*Database, error) {
if err != nil {
return nil, err
}
- if result.db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil {
+ if result.db, err = sqlutil.Open(sqlutil.SQLiteDriverName(), cs, nil); err != nil {
return nil, err
}
if err = result.prepare(); err != nil {
@@ -76,7 +75,7 @@ func (d *Database) UpdateRoom(
addHosts []types.JoinedHost,
removeHosts []string,
) (joinedHosts []types.JoinedHost, err error) {
- err = internal.WithTransaction(d.db, func(txn *sql.Tx) error {
+ err = sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error {
err = d.insertRoom(ctx, txn, roomID)
if err != nil {
return err
diff --git a/federationsender/storage/storage.go b/federationsender/storage/storage.go
index df8433eb..d3736005 100644
--- a/federationsender/storage/storage.go
+++ b/federationsender/storage/storage.go
@@ -21,11 +21,11 @@ import (
"github.com/matrix-org/dendrite/federationsender/storage/postgres"
"github.com/matrix-org/dendrite/federationsender/storage/sqlite3"
- "github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
)
// NewDatabase opens a new database
-func NewDatabase(dataSourceName string, dbProperties internal.DbProperties) (Database, error) {
+func NewDatabase(dataSourceName string, dbProperties sqlutil.DbProperties) (Database, error) {
uri, err := url.Parse(dataSourceName)
if err != nil {
return postgres.NewDatabase(dataSourceName, dbProperties)
diff --git a/federationsender/storage/storage_wasm.go b/federationsender/storage/storage_wasm.go
index f593fd44..e5c8f293 100644
--- a/federationsender/storage/storage_wasm.go
+++ b/federationsender/storage/storage_wasm.go
@@ -19,13 +19,13 @@ import (
"net/url"
"github.com/matrix-org/dendrite/federationsender/storage/sqlite3"
- "github.com/matrix-org/dendrite/internal"
+ "github.com/matrix-org/dendrite/internal/sqlutil"
)
// NewDatabase opens a new database
func NewDatabase(
dataSourceName string,
- dbProperties internal.DbProperties, // nolint:unparam
+ dbProperties sqlutil.DbProperties, // nolint:unparam
) (Database, error) {
uri, err := url.Parse(dataSourceName)
if err != nil {