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.
This commit is contained in:
Kegsay 2020-06-09 12:07:33 +01:00 committed by GitHub
parent 4f171c56a8
commit 85ac8a3f5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 170 additions and 76 deletions

View file

@ -15,9 +15,10 @@
package publicroomsapi
import (
"github.com/Shopify/sarama"
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
"github.com/matrix-org/dendrite/internal/basecomponent"
"github.com/matrix-org/dendrite/internal/config"
"github.com/matrix-org/dendrite/publicroomsapi/consumers"
"github.com/matrix-org/dendrite/publicroomsapi/routing"
"github.com/matrix-org/dendrite/publicroomsapi/storage"
@ -31,7 +32,8 @@ import (
// component.
func AddPublicRoutes(
router *mux.Router,
base *basecomponent.BaseDendrite,
cfg *config.Dendrite,
consumer sarama.Consumer,
deviceDB devices.Database,
publicRoomsDB storage.Database,
rsAPI roomserverAPI.RoomserverInternalAPI,
@ -39,7 +41,7 @@ func AddPublicRoutes(
extRoomsProvider types.ExternalPublicRoomsProvider,
) {
rsConsumer := consumers.NewOutputRoomEventConsumer(
base.Cfg, base.KafkaConsumer, publicRoomsDB, rsAPI,
cfg, consumer, publicRoomsDB, rsAPI,
)
if err := rsConsumer.Start(); err != nil {
logrus.WithError(err).Panic("failed to start public rooms server consumer")