diff options
author | Kegsay <kegan@matrix.org> | 2020-06-09 12:07:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 12:07:33 +0100 |
commit | 85ac8a3f5ba407ece584843a4d77466c1c4f5565 (patch) | |
tree | ce98a9501386fd8467196d164eb35a53ad8cb78b /cmd/dendritejs | |
parent | 4f171c56a832c836b0eb21650ee84d56e451dd6a (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 'cmd/dendritejs')
-rw-r--r-- | cmd/dendritejs/main.go | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/cmd/dendritejs/main.go b/cmd/dendritejs/main.go index 9c6c7c03..9901c6e5 100644 --- a/cmd/dendritejs/main.go +++ b/cmd/dendritejs/main.go @@ -23,21 +23,16 @@ import ( "syscall/js" "github.com/matrix-org/dendrite/appservice" - "github.com/matrix-org/dendrite/clientapi" "github.com/matrix-org/dendrite/clientapi/producers" "github.com/matrix-org/dendrite/eduserver" "github.com/matrix-org/dendrite/eduserver/cache" - "github.com/matrix-org/dendrite/federationapi" "github.com/matrix-org/dendrite/federationsender" "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal/basecomponent" "github.com/matrix-org/dendrite/internal/config" - "github.com/matrix-org/dendrite/internal/transactions" - "github.com/matrix-org/dendrite/mediaapi" - "github.com/matrix-org/dendrite/publicroomsapi" + "github.com/matrix-org/dendrite/internal/setup" "github.com/matrix-org/dendrite/publicroomsapi/storage" "github.com/matrix-org/dendrite/roomserver" - "github.com/matrix-org/dendrite/syncapi" go_http_js_libp2p "github.com/matrix-org/go-http-js-libp2p" "github.com/matrix-org/gomatrixserverlib" @@ -215,20 +210,32 @@ func main() { rsAPI.SetFederationSenderAPI(fedSenderAPI) p2pPublicRoomProvider := NewLibP2PPublicRoomsProvider(node, fedSenderAPI) - clientapi.AddPublicRoutes( - base.PublicAPIMux, base, deviceDB, accountDB, - federation, &keyRing, rsAPI, - eduInputAPI, asQuery, transactions.New(), fedSenderAPI, - ) eduProducer := producers.NewEDUServerProducer(eduInputAPI) - federationapi.AddPublicRoutes(base.PublicAPIMux, base.Cfg, accountDB, deviceDB, federation, &keyRing, rsAPI, asQuery, fedSenderAPI, eduProducer) - mediaapi.AddPublicRoutes(base.PublicAPIMux, base.Cfg, deviceDB) publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), cfg.Matrix.ServerName) if err != nil { logrus.WithError(err).Panicf("failed to connect to public rooms db") } - publicroomsapi.AddPublicRoutes(base.PublicAPIMux, base, deviceDB, publicRoomsDB, rsAPI, federation, p2pPublicRoomProvider) - syncapi.AddPublicRoutes(base.PublicAPIMux, base, deviceDB, accountDB, rsAPI, federation, cfg) + + monolith := setup.Monolith{ + Config: base.Cfg, + AccountDB: accountDB, + DeviceDB: deviceDB, + FedClient: federation, + KeyRing: &keyRing, + KafkaConsumer: base.KafkaConsumer, + KafkaProducer: base.KafkaProducer, + + AppserviceAPI: asQuery, + EDUInternalAPI: eduInputAPI, + EDUProducer: eduProducer, + FederationSenderAPI: fedSenderAPI, + RoomserverAPI: rsAPI, + //ServerKeyAPI: serverKeyAPI, + + PublicRoomsDB: publicRoomsDB, + ExtPublicRoomsProvider: p2pPublicRoomProvider, + } + monolith.AddAllPublicRoutes(base.PublicAPIMux) internal.SetupHTTPAPI( http.DefaultServeMux, |