mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 13:52:46 +00:00
* Fix #897 and shuffle directory around * Update find-lint * goimports Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
parent
3fdb045116
commit
24d8df664c
260 changed files with 901 additions and 901 deletions
|
@ -20,8 +20,8 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/lib/pq"
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/federationsender/types"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
)
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (s *joinedHostsStatements) insertJoinedHosts(
|
|||
roomID, eventID string,
|
||||
serverName gomatrixserverlib.ServerName,
|
||||
) error {
|
||||
stmt := common.TxStmt(txn, s.insertJoinedHostsStmt)
|
||||
stmt := internal.TxStmt(txn, s.insertJoinedHostsStmt)
|
||||
_, err := stmt.ExecContext(ctx, roomID, eventID, serverName)
|
||||
return err
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func (s *joinedHostsStatements) insertJoinedHosts(
|
|||
func (s *joinedHostsStatements) deleteJoinedHosts(
|
||||
ctx context.Context, txn *sql.Tx, eventIDs []string,
|
||||
) error {
|
||||
stmt := common.TxStmt(txn, s.deleteJoinedHostsStmt)
|
||||
stmt := internal.TxStmt(txn, s.deleteJoinedHostsStmt)
|
||||
_, err := stmt.ExecContext(ctx, pq.StringArray(eventIDs))
|
||||
return err
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func (s *joinedHostsStatements) deleteJoinedHosts(
|
|||
func (s *joinedHostsStatements) selectJoinedHostsWithTx(
|
||||
ctx context.Context, txn *sql.Tx, roomID string,
|
||||
) ([]types.JoinedHost, error) {
|
||||
stmt := common.TxStmt(txn, s.selectJoinedHostsStmt)
|
||||
stmt := internal.TxStmt(txn, s.selectJoinedHostsStmt)
|
||||
return joinedHostsFromStmt(ctx, stmt, roomID)
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ func joinedHostsFromStmt(
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer common.CloseAndLogIfError(ctx, rows, "joinedHostsFromStmt: rows.close() failed")
|
||||
defer internal.CloseAndLogIfError(ctx, rows, "joinedHostsFromStmt: rows.close() failed")
|
||||
|
||||
var result []types.JoinedHost
|
||||
for rows.Next() {
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
)
|
||||
|
||||
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 := common.TxStmt(txn, s.insertRoomStmt).ExecContext(ctx, roomID)
|
||||
_, err := internal.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 := common.TxStmt(txn, s.selectRoomForUpdateStmt)
|
||||
stmt := internal.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 := common.TxStmt(txn, s.updateRoomStmt)
|
||||
stmt := internal.TxStmt(txn, s.updateRoomStmt)
|
||||
_, err := stmt.ExecContext(ctx, roomID, lastEventID)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/common"
|
||||
"github.com/matrix-org/dendrite/federationsender/types"
|
||||
"github.com/matrix-org/dendrite/internal"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
)
|
||||
|
||||
|
@ -28,12 +28,12 @@ import (
|
|||
type Database struct {
|
||||
joinedHostsStatements
|
||||
roomStatements
|
||||
common.PartitionOffsetStatements
|
||||
internal.PartitionOffsetStatements
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
// NewDatabase opens a new database
|
||||
func NewDatabase(dataSourceName string, dbProperties common.DbProperties) (*Database, error) {
|
||||
func NewDatabase(dataSourceName string, dbProperties internal.DbProperties) (*Database, error) {
|
||||
var result Database
|
||||
var err error
|
||||
if result.db, err = sqlutil.Open("postgres", dataSourceName, dbProperties); err != nil {
|
||||
|
@ -70,7 +70,7 @@ func (d *Database) UpdateRoom(
|
|||
addHosts []types.JoinedHost,
|
||||
removeHosts []string,
|
||||
) (joinedHosts []types.JoinedHost, err error) {
|
||||
err = common.WithTransaction(d.db, func(txn *sql.Tx) error {
|
||||
err = internal.WithTransaction(d.db, func(txn *sql.Tx) error {
|
||||
err = d.insertRoom(ctx, txn, roomID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue