mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-03 14:42:47 +00:00
Add a new component: currentstateserver (#1171)
* Add a new component: currentstateserver - Add a skeleton for it, with databases and a single query method. - Add integration tests for it. - Add listen/address fields in the config (breaking as this will force people to specify this to validate) Not currently hooked up to anything yet. * Unbreak config tests * Add current_state to sample config * comments
This commit is contained in:
parent
3a18b7fc78
commit
ca5bbffd8d
19 changed files with 1293 additions and 3 deletions
39
currentstateserver/storage/sqlite3/storage.go
Normal file
39
currentstateserver/storage/sqlite3/storage.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/currentstateserver/storage/shared"
|
||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
shared.Database
|
||||
db *sql.DB
|
||||
sqlutil.PartitionOffsetStatements
|
||||
}
|
||||
|
||||
// NewDatabase creates a new sync server database
|
||||
// nolint: gocyclo
|
||||
func NewDatabase(dataSourceName string) (*Database, error) {
|
||||
var d Database
|
||||
cs, err := sqlutil.ParseFileURI(dataSourceName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if d.db, err = sqlutil.Open(sqlutil.SQLiteDriverName(), cs, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = d.PartitionOffsetStatements.Prepare(d.db, "currentstate"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
currRoomState, err := NewSqliteCurrentRoomStateTable(d.db)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.Database = shared.Database{
|
||||
DB: d.db,
|
||||
CurrentRoomState: currRoomState,
|
||||
}
|
||||
return &d, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue