aboutsummaryrefslogtreecommitdiff
path: root/federationsender/federationsender.go
diff options
context:
space:
mode:
authorAlex Chen <Cnly@users.noreply.github.com>2019-08-24 01:25:10 +0800
committerGitHub <noreply@github.com>2019-08-24 01:25:10 +0800
commit5e25f6ba22d8bda6e03347c3f5e1df13164719b6 (patch)
tree7f609c8368434f64587d91140322fbaa503b5365 /federationsender/federationsender.go
parent43308d2f3f8fcf9bdb3ec55d4e679b576cc19488 (diff)
Set up queryAPI in federationsender (#791)
Diffstat (limited to 'federationsender/federationsender.go')
-rw-r--r--federationsender/federationsender.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/federationsender/federationsender.go b/federationsender/federationsender.go
index 9b732b38..a318d209 100644
--- a/federationsender/federationsender.go
+++ b/federationsender/federationsender.go
@@ -15,11 +15,15 @@
package federationsender
import (
+ "net/http"
+
"github.com/matrix-org/dendrite/common/basecomponent"
+ "github.com/matrix-org/dendrite/federationsender/api"
"github.com/matrix-org/dendrite/federationsender/consumers"
+ "github.com/matrix-org/dendrite/federationsender/query"
"github.com/matrix-org/dendrite/federationsender/queue"
"github.com/matrix-org/dendrite/federationsender/storage"
- "github.com/matrix-org/dendrite/roomserver/api"
+ roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus"
)
@@ -29,8 +33,8 @@ import (
func SetupFederationSenderComponent(
base *basecomponent.BaseDendrite,
federation *gomatrixserverlib.FederationClient,
- queryAPI api.RoomserverQueryAPI,
-) {
+ rsQueryAPI roomserverAPI.RoomserverQueryAPI,
+) api.FederationSenderQueryAPI {
federationSenderDB, err := storage.NewDatabase(string(base.Cfg.Database.FederationSender))
if err != nil {
logrus.WithError(err).Panic("failed to connect to federation sender db")
@@ -40,7 +44,7 @@ func SetupFederationSenderComponent(
rsConsumer := consumers.NewOutputRoomEventConsumer(
base.Cfg, base.KafkaConsumer, queues,
- federationSenderDB, queryAPI,
+ federationSenderDB, rsQueryAPI,
)
if err = rsConsumer.Start(); err != nil {
logrus.WithError(err).Panic("failed to start room server consumer")
@@ -52,4 +56,11 @@ func SetupFederationSenderComponent(
if err := tsConsumer.Start(); err != nil {
logrus.WithError(err).Panic("failed to start typing server consumer")
}
+
+ queryAPI := query.FederationSenderQueryAPI{
+ DB: federationSenderDB,
+ }
+ queryAPI.SetupHTTP(http.DefaultServeMux)
+
+ return &queryAPI
}