aboutsummaryrefslogtreecommitdiff
path: root/clientapi/clientapi.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-09 12:07:33 +0100
committerGitHub <noreply@github.com>2020-06-09 12:07:33 +0100
commit85ac8a3f5ba407ece584843a4d77466c1c4f5565 (patch)
treece98a9501386fd8467196d164eb35a53ad8cb78b /clientapi/clientapi.go
parent4f171c56a832c836b0eb21650ee84d56e451dd6a (diff)
Factor out how monolith routes get added (#1107)
Previously we had 3 monoliths: - dendrite-monolith-server - dendrite-demo-libp2p - dendritejs which all had their own of setting up public routes. Factor this out into a new `setup.Monolith` struct which gets all dependencies set as fields. This is different to `basecomponent.Base` which doesn't provide any way to set configured deps (e.g public rooms db) Part of a larger process to clean up how we initialise Dendrite.
Diffstat (limited to 'clientapi/clientapi.go')
-rw-r--r--clientapi/clientapi.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/clientapi/clientapi.go b/clientapi/clientapi.go
index d00be6eb..987815c2 100644
--- a/clientapi/clientapi.go
+++ b/clientapi/clientapi.go
@@ -15,6 +15,7 @@
package clientapi
import (
+ "github.com/Shopify/sarama"
"github.com/gorilla/mux"
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
@@ -24,7 +25,7 @@ import (
"github.com/matrix-org/dendrite/clientapi/routing"
eduServerAPI "github.com/matrix-org/dendrite/eduserver/api"
federationSenderAPI "github.com/matrix-org/dendrite/federationsender/api"
- "github.com/matrix-org/dendrite/internal/basecomponent"
+ "github.com/matrix-org/dendrite/internal/config"
"github.com/matrix-org/dendrite/internal/transactions"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
@@ -34,7 +35,9 @@ import (
// AddPublicRoutes sets up and registers HTTP handlers for the ClientAPI component.
func AddPublicRoutes(
router *mux.Router,
- base *basecomponent.BaseDendrite,
+ cfg *config.Dendrite,
+ consumer sarama.Consumer,
+ producer sarama.SyncProducer,
deviceDB devices.Database,
accountsDB accounts.Database,
federation *gomatrixserverlib.FederationClient,
@@ -49,24 +52,24 @@ func AddPublicRoutes(
eduProducer := producers.NewEDUServerProducer(eduInputAPI)
userUpdateProducer := &producers.UserUpdateProducer{
- Producer: base.KafkaProducer,
- Topic: string(base.Cfg.Kafka.Topics.UserUpdates),
+ Producer: producer,
+ Topic: string(cfg.Kafka.Topics.UserUpdates),
}
syncProducer := &producers.SyncAPIProducer{
- Producer: base.KafkaProducer,
- Topic: string(base.Cfg.Kafka.Topics.OutputClientData),
+ Producer: producer,
+ Topic: string(cfg.Kafka.Topics.OutputClientData),
}
- consumer := consumers.NewOutputRoomEventConsumer(
- base.Cfg, base.KafkaConsumer, accountsDB, rsAPI,
+ roomEventConsumer := consumers.NewOutputRoomEventConsumer(
+ cfg, consumer, accountsDB, rsAPI,
)
- if err := consumer.Start(); err != nil {
+ if err := roomEventConsumer.Start(); err != nil {
logrus.WithError(err).Panicf("failed to start room server consumer")
}
routing.Setup(
- router, base.Cfg, roomserverProducer, rsAPI, asAPI,
+ router, cfg, roomserverProducer, rsAPI, asAPI,
accountsDB, deviceDB, federation, *keyRing, userUpdateProducer,
syncProducer, eduProducer, transactionsCache, fsAPI,
)