From 507f63d0fc8158f200f3e29fd36e5f09c83e62db Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 6 May 2022 13:51:48 +0100 Subject: [PATCH] Add `PolylithMode` base config option (#2428) * Add `PolylithMode` base config option * Polylith mode always uses HTTP APIs --- cmd/dendrite-polylith-multi/main.go | 4 ++-- setup/base/base.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/dendrite-polylith-multi/main.go b/cmd/dendrite-polylith-multi/main.go index 4fccaa92..e4845f64 100644 --- a/cmd/dendrite-polylith-multi/main.go +++ b/cmd/dendrite-polylith-multi/main.go @@ -71,8 +71,8 @@ func main() { logrus.Infof("Starting %q component", component) - base := base.NewBaseDendrite(cfg, component) // TODO - defer base.Close() // nolint: errcheck + base := base.NewBaseDendrite(cfg, component, base.PolylithMode) // TODO + defer base.Close() // nolint: errcheck go start(base, cfg) base.WaitForShutdown() diff --git a/setup/base/base.go b/setup/base/base.go index d7d5119f..ef449cc3 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -96,6 +96,7 @@ type BaseDendriteOptions int const ( NoCacheMetrics BaseDendriteOptions = iota UseHTTPAPIs + PolylithMode ) // NewBaseDendrite creates a new instance to be used by a component. @@ -105,17 +106,20 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base platformSanityChecks() useHTTPAPIs := false cacheMetrics := true + isMonolith := true for _, opt := range options { switch opt { case NoCacheMetrics: cacheMetrics = false case UseHTTPAPIs: useHTTPAPIs = true + case PolylithMode: + isMonolith = false + useHTTPAPIs = true } } configErrors := &config.ConfigErrors{} - isMonolith := componentName == "Monolith" // TODO: better way? cfg.Verify(configErrors, isMonolith) if len(*configErrors) > 0 { for _, err := range *configErrors {