aboutsummaryrefslogtreecommitdiff
path: root/roomserver/internal/api.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-03-22 09:21:32 +0100
committerGitHub <noreply@github.com>2023-03-22 09:21:32 +0100
commit5e85a00cb36c3d343cd5b6f6a18435989724a135 (patch)
treeb22c34dd0a6cdc04025b90086843f9084a876412 /roomserver/internal/api.go
parentec6879e5ae2919c903707475ce8d72244b2a6847 (diff)
Remove `BaseDendrite` (#3023)
Removes `BaseDendrite` to, hopefully, make testing and composing of components easier in the future.
Diffstat (limited to 'roomserver/internal/api.go')
-rw-r--r--roomserver/internal/api.go50
1 files changed, 24 insertions, 26 deletions
diff --git a/roomserver/internal/api.go b/roomserver/internal/api.go
index 2e987d68..7ca3675d 100644
--- a/roomserver/internal/api.go
+++ b/roomserver/internal/api.go
@@ -18,7 +18,6 @@ import (
"github.com/matrix-org/dendrite/roomserver/internal/query"
"github.com/matrix-org/dendrite/roomserver/producers"
"github.com/matrix-org/dendrite/roomserver/storage"
- "github.com/matrix-org/dendrite/setup/base"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/setup/jetstream"
"github.com/matrix-org/dendrite/setup/process"
@@ -41,9 +40,8 @@ type RoomserverInternalAPI struct {
*perform.Upgrader
*perform.Admin
ProcessContext *process.ProcessContext
- Base *base.BaseDendrite
DB storage.Database
- Cfg *config.RoomServer
+ Cfg *config.Dendrite
Cache caching.RoomServerCaches
ServerName gomatrixserverlib.ServerName
KeyRing gomatrixserverlib.JSONVerifier
@@ -56,43 +54,44 @@ type RoomserverInternalAPI struct {
InputRoomEventTopic string // JetStream topic for new input room events
OutputProducer *producers.RoomEventProducer
PerspectiveServerNames []gomatrixserverlib.ServerName
+ enableMetrics bool
}
func NewRoomserverAPI(
- base *base.BaseDendrite, roomserverDB storage.Database,
- js nats.JetStreamContext, nc *nats.Conn, caches caching.RoomServerCaches,
+ processContext *process.ProcessContext, dendriteCfg *config.Dendrite, roomserverDB storage.Database,
+ js nats.JetStreamContext, nc *nats.Conn, caches caching.RoomServerCaches, enableMetrics bool,
) *RoomserverInternalAPI {
var perspectiveServerNames []gomatrixserverlib.ServerName
- for _, kp := range base.Cfg.FederationAPI.KeyPerspectives {
+ for _, kp := range dendriteCfg.FederationAPI.KeyPerspectives {
perspectiveServerNames = append(perspectiveServerNames, kp.ServerName)
}
serverACLs := acls.NewServerACLs(roomserverDB)
producer := &producers.RoomEventProducer{
- Topic: string(base.Cfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent)),
+ Topic: string(dendriteCfg.Global.JetStream.Prefixed(jetstream.OutputRoomEvent)),
JetStream: js,
ACLs: serverACLs,
}
a := &RoomserverInternalAPI{
- ProcessContext: base.ProcessContext,
+ ProcessContext: processContext,
DB: roomserverDB,
- Base: base,
- Cfg: &base.Cfg.RoomServer,
+ Cfg: dendriteCfg,
Cache: caches,
- ServerName: base.Cfg.Global.ServerName,
+ ServerName: dendriteCfg.Global.ServerName,
PerspectiveServerNames: perspectiveServerNames,
- InputRoomEventTopic: base.Cfg.Global.JetStream.Prefixed(jetstream.InputRoomEvent),
+ InputRoomEventTopic: dendriteCfg.Global.JetStream.Prefixed(jetstream.InputRoomEvent),
OutputProducer: producer,
JetStream: js,
NATSClient: nc,
- Durable: base.Cfg.Global.JetStream.Durable("RoomserverInputConsumer"),
+ Durable: dendriteCfg.Global.JetStream.Durable("RoomserverInputConsumer"),
ServerACLs: serverACLs,
Queryer: &query.Queryer{
DB: roomserverDB,
Cache: caches,
- IsLocalServerName: base.Cfg.Global.IsLocalServerName,
+ IsLocalServerName: dendriteCfg.Global.IsLocalServerName,
ServerACLs: serverACLs,
},
+ enableMetrics: enableMetrics,
// perform-er structs get initialised when we have a federation sender to use
}
return a
@@ -105,15 +104,14 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
r.fsAPI = fsAPI
r.KeyRing = keyRing
- identity, err := r.Cfg.Matrix.SigningIdentityFor(r.ServerName)
+ identity, err := r.Cfg.Global.SigningIdentityFor(r.ServerName)
if err != nil {
logrus.Panic(err)
}
r.Inputer = &input.Inputer{
- Cfg: &r.Base.Cfg.RoomServer,
- Base: r.Base,
- ProcessContext: r.Base.ProcessContext,
+ Cfg: &r.Cfg.RoomServer,
+ ProcessContext: r.ProcessContext,
DB: r.DB,
InputRoomEventTopic: r.InputRoomEventTopic,
OutputProducer: r.OutputProducer,
@@ -129,12 +127,12 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
}
r.Inviter = &perform.Inviter{
DB: r.DB,
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
FSAPI: r.fsAPI,
Inputer: r.Inputer,
}
r.Joiner = &perform.Joiner{
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
DB: r.DB,
FSAPI: r.fsAPI,
RSAPI: r,
@@ -143,7 +141,7 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
}
r.Peeker = &perform.Peeker{
ServerName: r.ServerName,
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
DB: r.DB,
FSAPI: r.fsAPI,
Inputer: r.Inputer,
@@ -154,12 +152,12 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
}
r.Unpeeker = &perform.Unpeeker{
ServerName: r.ServerName,
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
FSAPI: r.fsAPI,
Inputer: r.Inputer,
}
r.Leaver = &perform.Leaver{
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
DB: r.DB,
FSAPI: r.fsAPI,
Inputer: r.Inputer,
@@ -168,7 +166,7 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
DB: r.DB,
}
r.Backfiller = &perform.Backfiller{
- IsLocalServerName: r.Cfg.Matrix.IsLocalServerName,
+ IsLocalServerName: r.Cfg.Global.IsLocalServerName,
DB: r.DB,
FSAPI: r.fsAPI,
KeyRing: r.KeyRing,
@@ -181,12 +179,12 @@ func (r *RoomserverInternalAPI) SetFederationAPI(fsAPI fsAPI.RoomserverFederatio
DB: r.DB,
}
r.Upgrader = &perform.Upgrader{
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
URSAPI: r,
}
r.Admin = &perform.Admin{
DB: r.DB,
- Cfg: r.Cfg,
+ Cfg: &r.Cfg.RoomServer,
Inputer: r.Inputer,
Queryer: r.Queryer,
Leaver: r.Leaver,