diff options
author | Kegsay <kegan@matrix.org> | 2020-05-13 17:28:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 17:28:42 +0100 |
commit | a25d477cdb8f1ba49b3b5e9d931f808ae45b4853 (patch) | |
tree | 3f61860296096112f6993c68233a4b71673ff4ca /syncapi/storage/tables/interface.go | |
parent | bdddd83753e31c69e99a695b01cf9009ba7cb6c8 (diff) |
Initial syncapi storage refactor to share pq/sqlite code (#1030)
* Initial syncapi storage refactor to share pq/sqlite code
This goes down a different route than https://github.com/matrix-org/dendrite/pull/985
which tried to even reduce the boilerplate of `ExecContext` etc. The previous pattern
fails badly when there are subtle differences in parameters and hence the shared
boilerplate to read from `QueryContext` breaks. Rather than attacking it at that level,
the main place where we want to reuse code is for the `syncserver.go` itself - the
database implementation which has lots of complex logic. So instead, this commit:
- Makes `invites_table.go` an interface.
- Makes `SyncServerDatasource` use that interface
- This means some functions are now identical for pq/sqlite, so factor them out
to a temporary `shared.Database` struct which will grow until it replaces all of
`SyncServerDatasource`.
* Missing files
Diffstat (limited to 'syncapi/storage/tables/interface.go')
-rw-r--r-- | syncapi/storage/tables/interface.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/syncapi/storage/tables/interface.go b/syncapi/storage/tables/interface.go new file mode 100644 index 00000000..1a994052 --- /dev/null +++ b/syncapi/storage/tables/interface.go @@ -0,0 +1,16 @@ +package tables + +import ( + "context" + "database/sql" + + "github.com/matrix-org/dendrite/syncapi/types" + "github.com/matrix-org/gomatrixserverlib" +) + +type Invites interface { + InsertInviteEvent(ctx context.Context, txn *sql.Tx, inviteEvent gomatrixserverlib.HeaderedEvent) (streamPos types.StreamPosition, err error) + DeleteInviteEvent(ctx context.Context, inviteEventID string) error + SelectInviteEventsInRange(ctx context.Context, txn *sql.Tx, targetUserID string, startPos, endPos types.StreamPosition) (map[string]gomatrixserverlib.HeaderedEvent, error) + SelectMaxInviteID(ctx context.Context, txn *sql.Tx) (id int64, err error) +} |