From 9e95d599bca4518bd8f9d4bfb3bd820a1ce68f12 Mon Sep 17 00:00:00 2001 From: Adit Sachde <23707194+aditsachde@users.noreply.github.com> Date: Sun, 22 Sep 2019 14:03:38 -0400 Subject: [PATCH] patch dendrite microservices with bind config Adds bind block to the dendrite config. microservices bind to address in this block, and talk to other microservices via the address in the listen block --- cmd/dendrite-appservice-server/main.go | 2 +- cmd/dendrite-client-api-server/main.go | 2 +- cmd/dendrite-federation-api-server/main.go | 2 +- cmd/dendrite-federation-sender-server/main.go | 2 +- cmd/dendrite-media-api-server/main.go | 2 +- cmd/dendrite-public-rooms-api-server/main.go | 2 +- cmd/dendrite-room-server/main.go | 2 +- cmd/dendrite-sync-api-server/main.go | 2 +- cmd/dendrite-typing-server/main.go | 2 +- common/config/config.go | 17 +++++++++++++++-- 10 files changed, 24 insertions(+), 11 deletions(-) diff --git a/cmd/dendrite-appservice-server/main.go b/cmd/dendrite-appservice-server/main.go index dcaea5138..c3e34a190 100644 --- a/cmd/dendrite-appservice-server/main.go +++ b/cmd/dendrite-appservice-server/main.go @@ -35,5 +35,5 @@ func main() { base, accountDB, deviceDB, federation, alias, query, cache, ) - base.SetupAndServeHTTP(string(base.Cfg.Listen.FederationSender)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationSender)) } diff --git a/cmd/dendrite-client-api-server/main.go b/cmd/dendrite-client-api-server/main.go index dd0656441..ebbd6572f 100644 --- a/cmd/dendrite-client-api-server/main.go +++ b/cmd/dendrite-client-api-server/main.go @@ -44,5 +44,5 @@ func main() { alias, input, query, typingInputAPI, asQuery, transactions.New(), ) - base.SetupAndServeHTTP(string(base.Cfg.Listen.ClientAPI)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.ClientAPI)) } diff --git a/cmd/dendrite-federation-api-server/main.go b/cmd/dendrite-federation-api-server/main.go index 014ed3343..e83907cab 100644 --- a/cmd/dendrite-federation-api-server/main.go +++ b/cmd/dendrite-federation-api-server/main.go @@ -39,5 +39,5 @@ func main() { alias, input, query, asQuery, ) - base.SetupAndServeHTTP(string(base.Cfg.Listen.FederationAPI)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationAPI)) } diff --git a/cmd/dendrite-federation-sender-server/main.go b/cmd/dendrite-federation-sender-server/main.go index 59b98e5bb..b3d59912d 100644 --- a/cmd/dendrite-federation-sender-server/main.go +++ b/cmd/dendrite-federation-sender-server/main.go @@ -32,5 +32,5 @@ func main() { base, federation, query, ) - base.SetupAndServeHTTP(string(base.Cfg.Listen.FederationSender)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.FederationSender)) } diff --git a/cmd/dendrite-media-api-server/main.go b/cmd/dendrite-media-api-server/main.go index 718bb6f1b..0c49d0814 100644 --- a/cmd/dendrite-media-api-server/main.go +++ b/cmd/dendrite-media-api-server/main.go @@ -28,5 +28,5 @@ func main() { mediaapi.SetupMediaAPIComponent(base, deviceDB) - base.SetupAndServeHTTP(string(base.Cfg.Listen.MediaAPI)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.MediaAPI)) } diff --git a/cmd/dendrite-public-rooms-api-server/main.go b/cmd/dendrite-public-rooms-api-server/main.go index 63e1f40b5..e6cd0e638 100644 --- a/cmd/dendrite-public-rooms-api-server/main.go +++ b/cmd/dendrite-public-rooms-api-server/main.go @@ -28,5 +28,5 @@ func main() { publicroomsapi.SetupPublicRoomsAPIComponent(base, deviceDB) - base.SetupAndServeHTTP(string(base.Cfg.Listen.PublicRoomsAPI)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.PublicRoomsAPI)) } diff --git a/cmd/dendrite-room-server/main.go b/cmd/dendrite-room-server/main.go index a5942544d..8846510ed 100644 --- a/cmd/dendrite-room-server/main.go +++ b/cmd/dendrite-room-server/main.go @@ -28,5 +28,5 @@ func main() { roomserver.SetupRoomServerComponent(base) - base.SetupAndServeHTTP(string(base.Cfg.Listen.RoomServer)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.RoomServer)) } diff --git a/cmd/dendrite-sync-api-server/main.go b/cmd/dendrite-sync-api-server/main.go index 343d3567d..f7f8107a3 100644 --- a/cmd/dendrite-sync-api-server/main.go +++ b/cmd/dendrite-sync-api-server/main.go @@ -31,5 +31,5 @@ func main() { syncapi.SetupSyncAPIComponent(base, deviceDB, accountDB, query) - base.SetupAndServeHTTP(string(base.Cfg.Listen.SyncAPI)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.SyncAPI)) } diff --git a/cmd/dendrite-typing-server/main.go b/cmd/dendrite-typing-server/main.go index 4eb0823a9..a2fdb3096 100644 --- a/cmd/dendrite-typing-server/main.go +++ b/cmd/dendrite-typing-server/main.go @@ -32,5 +32,5 @@ func main() { typingserver.SetupTypingServerComponent(base, cache.NewTypingCache()) - base.SetupAndServeHTTP(string(base.Cfg.Listen.TypingServer)) + base.SetupAndServeHTTP(string(base.Cfg.Bind.TypingServer)) } diff --git a/common/config/config.go b/common/config/config.go index 40232fb03..18b976830 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -194,8 +194,7 @@ type Dendrite struct { Password string `yaml:"turn_password"` } `yaml:"turn"` - // The internal addresses the components will listen on. - // These should not be exposed externally as they expose metrics and debugging APIs. + // The addresses for talking to other microservices. Listen struct { MediaAPI Address `yaml:"media_api"` ClientAPI Address `yaml:"client_api"` @@ -208,6 +207,20 @@ type Dendrite struct { TypingServer Address `yaml:"typing_server"` } `yaml:"listen"` + // The internal addresses the components will listen on. + // These should not be exposed externally as they expose metrics and debugging APIs. + Bind struct { + MediaAPI Address `yaml:"media_api"` + ClientAPI Address `yaml:"client_api"` + FederationAPI Address `yaml:"federation_api"` + AppServiceAPI Address `yaml:"appservice_api"` + SyncAPI Address `yaml:"sync_api"` + RoomServer Address `yaml:"room_server"` + FederationSender Address `yaml:"federation_sender"` + PublicRoomsAPI Address `yaml:"public_rooms_api"` + TypingServer Address `yaml:"typing_server"` + } `yaml:"bind"` + // The config for tracing the dendrite servers. Tracing struct { // The config for the jaeger opentracing reporter.