aboutsummaryrefslogtreecommitdiff
path: root/roomserver/state
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-04-24 10:38:58 +0100
committerGitHub <noreply@github.com>2020-04-24 10:38:58 +0100
commita202d88fe527c83179d2ebf57ac0d146c3173f9d (patch)
tree493aea75e95b20b93f7212779f2cca7ebac7279e /roomserver/state
parentc30b12b5a1deea21e54d4718ca11a3b6366c443d (diff)
Use a single storage.Database interface (#978)
Diffstat (limited to 'roomserver/state')
-rw-r--r--roomserver/state/database/database.go67
-rw-r--r--roomserver/state/shared/shared.go1
-rw-r--r--roomserver/state/state.go6
3 files changed, 3 insertions, 71 deletions
diff --git a/roomserver/state/database/database.go b/roomserver/state/database/database.go
deleted file mode 100644
index 80f1b14f..00000000
--- a/roomserver/state/database/database.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2017 Vector Creations Ltd
-// Copyright 2018 New Vector Ltd
-// Copyright 2019-2020 The Matrix.org Foundation C.I.C.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package database
-
-import (
- "context"
-
- "github.com/matrix-org/dendrite/roomserver/types"
- "github.com/matrix-org/gomatrixserverlib"
-)
-
-// A RoomStateDatabase has the storage APIs needed to load state from the database
-type RoomStateDatabase interface {
- // Store the room state at an event in the database
- AddState(
- ctx context.Context,
- roomNID types.RoomNID,
- stateBlockNIDs []types.StateBlockNID,
- state []types.StateEntry,
- ) (types.StateSnapshotNID, error)
- // Look up the state of a room at each event for a list of string event IDs.
- // Returns an error if there is an error talking to the database
- // Returns a types.MissingEventError if the room state for the event IDs aren't in the database
- StateAtEventIDs(ctx context.Context, eventIDs []string) ([]types.StateAtEvent, error)
- // Look up the numeric IDs for a list of string event types.
- // Returns a map from string event type to numeric ID for the event type.
- EventTypeNIDs(ctx context.Context, eventTypes []string) (map[string]types.EventTypeNID, error)
- // Look up the numeric IDs for a list of string event state keys.
- // Returns a map from string state key to numeric ID for the state key.
- EventStateKeyNIDs(ctx context.Context, eventStateKeys []string) (map[string]types.EventStateKeyNID, error)
- // Look up the numeric state data IDs for each numeric state snapshot ID
- // The returned slice is sorted by numeric state snapshot ID.
- StateBlockNIDs(ctx context.Context, stateNIDs []types.StateSnapshotNID) ([]types.StateBlockNIDList, error)
- // Look up the state data for each numeric state data ID
- // The returned slice is sorted by numeric state data ID.
- StateEntries(ctx context.Context, stateBlockNIDs []types.StateBlockNID) ([]types.StateEntryList, error)
- // Look up the state data for the state key tuples for each numeric state block ID
- // This is used to fetch a subset of the room state at a snapshot.
- // If a block doesn't contain any of the requested tuples then it can be discarded from the result.
- // The returned slice is sorted by numeric state block ID.
- StateEntriesForTuples(
- ctx context.Context,
- stateBlockNIDs []types.StateBlockNID,
- stateKeyTuples []types.StateKeyTuple,
- ) ([]types.StateEntryList, error)
- // Look up the Events for a list of numeric event IDs.
- // Returns a sorted list of events.
- Events(ctx context.Context, eventNIDs []types.EventNID) ([]types.Event, error)
- // Look up snapshot NID for an event ID string
- SnapshotNIDFromEventID(ctx context.Context, eventID string) (types.StateSnapshotNID, error)
- // Look up a room version from the room NID.
- GetRoomVersionForRoomNID(ctx context.Context, roomNID types.RoomNID) (gomatrixserverlib.RoomVersion, error)
-}
diff --git a/roomserver/state/shared/shared.go b/roomserver/state/shared/shared.go
deleted file mode 100644
index a29b5e40..00000000
--- a/roomserver/state/shared/shared.go
+++ /dev/null
@@ -1 +0,0 @@
-package shared
diff --git a/roomserver/state/state.go b/roomserver/state/state.go
index 3f68e074..389c9440 100644
--- a/roomserver/state/state.go
+++ b/roomserver/state/state.go
@@ -22,7 +22,7 @@ import (
"sort"
"time"
- "github.com/matrix-org/dendrite/roomserver/state/database"
+ "github.com/matrix-org/dendrite/roomserver/storage"
"github.com/matrix-org/util"
"github.com/prometheus/client_golang/prometheus"
@@ -31,10 +31,10 @@ import (
)
type StateResolution struct {
- db database.RoomStateDatabase
+ db storage.Database
}
-func NewStateResolution(db database.RoomStateDatabase) StateResolution {
+func NewStateResolution(db storage.Database) StateResolution {
return StateResolution{
db: db,
}