mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-27 16:53:10 -06:00
* - Implement Cosmos for the devices_table - Use the ConnectionString in the YAML to include the Tenant - Revert all other non implemented tables back to use SQLLite3 * - Change the Config to use "test.criticicalarc.com" Container - Add generic function GetDocumentOrNil to standardize GetDocument - Add func to return CrossPartition queries for Aggregates - Add func GetNextSequence() as generic seq generator for AutoIncrement - Add cosmosdbutil.ErrNoRows to return (emulate) sql.ErrNoRows - Add a "fake" ExclusiveWriterFake - Add standard "getXX", "setXX" and "queryXX" to all TABLE class files - Add specific Table SEQ for the Events table - Add specific Table SEQ for the Rooms table - Add specific Table SEQ for the StateSnapshot table * - Use CosmosDB for the KeyServer - Replace the ConnString in the YAML to Cosmos - Update the 4 tables to use Cosmos
71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
// Copyright 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 cosmosdb
|
|
|
|
import (
|
|
"github.com/matrix-org/dendrite/internal/cosmosdbapi"
|
|
"github.com/matrix-org/dendrite/internal/cosmosdbutil"
|
|
"github.com/matrix-org/dendrite/keyserver/storage/shared"
|
|
"github.com/matrix-org/dendrite/setup/config"
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
)
|
|
|
|
// A Database is used to store room events and stream offsets.
|
|
type Database struct {
|
|
shared.Database
|
|
connection cosmosdbapi.CosmosConnection
|
|
databaseName string
|
|
cosmosConfig cosmosdbapi.CosmosConfig
|
|
serverName gomatrixserverlib.ServerName
|
|
}
|
|
|
|
func NewDatabase(dbProperties *config.DatabaseOptions) (*shared.Database, error) {
|
|
conn := cosmosdbutil.GetCosmosConnection(&dbProperties.ConnectionString)
|
|
config := cosmosdbutil.GetCosmosConfig(&dbProperties.ConnectionString)
|
|
d := &Database{
|
|
databaseName: "keyserver",
|
|
connection: conn,
|
|
cosmosConfig: config,
|
|
}
|
|
|
|
// db, err := sqlutil.Open(dbProperties)
|
|
// if err != nil {
|
|
// return nil, err
|
|
// }
|
|
otk, err := NewCosmosDBOneTimeKeysTable(d)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
dk, err := NewCosmosDBDeviceKeysTable(d)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kc, err := NewCosmosDBKeyChangesTable(d)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
sdl, err := NewCosmosDBStaleDeviceListsTable(d)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &shared.Database{
|
|
Writer: cosmosdbutil.NewExclusiveWriterFake(),
|
|
OneTimeKeysTable: otk,
|
|
DeviceKeysTable: dk,
|
|
KeyChangesTable: kc,
|
|
StaleDeviceListsTable: sdl,
|
|
}, nil
|
|
}
|