aboutsummaryrefslogtreecommitdiff
path: root/setup/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'setup/config/config.go')
-rw-r--r--setup/config/config.go112
1 files changed, 13 insertions, 99 deletions
diff --git a/setup/config/config.go b/setup/config/config.go
index 2b38cd51..84876616 100644
--- a/setup/config/config.go
+++ b/setup/config/config.go
@@ -79,8 +79,6 @@ type Dendrite struct {
// Any information derived from the configuration options for later use.
Derived Derived `yaml:"-"`
-
- IsMonolith bool `yaml:"-"`
}
// TODO: Kill Derived
@@ -114,15 +112,6 @@ type Derived struct {
// servers from creating RoomIDs in exclusive application service namespaces
}
-type InternalAPIOptions struct {
- Listen HTTPAddress `yaml:"listen"`
- Connect HTTPAddress `yaml:"connect"`
-}
-
-type ExternalAPIOptions struct {
- Listen HTTPAddress `yaml:"listen"`
-}
-
// A Path on the filesystem.
type Path string
@@ -191,7 +180,7 @@ type ConfigErrors []string
// Load a yaml config file for a server run as multiple processes or as a monolith.
// Checks the config to ensure that it is valid.
-func Load(configPath string, monolith bool) (*Dendrite, error) {
+func Load(configPath string) (*Dendrite, error) {
configData, err := os.ReadFile(configPath)
if err != nil {
return nil, err
@@ -202,28 +191,26 @@ func Load(configPath string, monolith bool) (*Dendrite, error) {
}
// Pass the current working directory and os.ReadFile so that they can
// be mocked in the tests
- return loadConfig(basePath, configData, os.ReadFile, monolith)
+ return loadConfig(basePath, configData, os.ReadFile)
}
func loadConfig(
basePath string,
configData []byte,
readFile func(string) ([]byte, error),
- monolithic bool,
) (*Dendrite, error) {
var c Dendrite
c.Defaults(DefaultOpts{
- Generate: false,
- Monolithic: monolithic,
+ Generate: false,
+ SingleDatabase: true,
})
- c.IsMonolith = monolithic
var err error
if err = yaml.Unmarshal(configData, &c); err != nil {
return nil, err
}
- if err = c.check(monolithic); err != nil {
+ if err = c.check(); err != nil {
return nil, err
}
@@ -333,8 +320,8 @@ func (config *Dendrite) Derive() error {
}
type DefaultOpts struct {
- Generate bool
- Monolithic bool
+ Generate bool
+ SingleDatabase bool
}
// SetDefaults sets default config values if they are not explicitly set.
@@ -355,9 +342,9 @@ func (c *Dendrite) Defaults(opts DefaultOpts) {
c.Wiring()
}
-func (c *Dendrite) Verify(configErrs *ConfigErrors, isMonolith bool) {
+func (c *Dendrite) Verify(configErrs *ConfigErrors) {
type verifiable interface {
- Verify(configErrs *ConfigErrors, isMonolith bool)
+ Verify(configErrs *ConfigErrors)
}
for _, c := range []verifiable{
&c.Global, &c.ClientAPI, &c.FederationAPI,
@@ -365,7 +352,7 @@ func (c *Dendrite) Verify(configErrs *ConfigErrors, isMonolith bool) {
&c.SyncAPI, &c.UserAPI,
&c.AppServiceAPI, &c.RelayAPI, &c.MSCs,
} {
- c.Verify(configErrs, isMonolith)
+ c.Verify(configErrs)
}
}
@@ -415,14 +402,6 @@ func checkNotEmpty(configErrs *ConfigErrors, key, value string) {
}
}
-// checkNotZero verifies the given value is not zero in the configuration.
-// If it is, adds an error to the list.
-func checkNotZero(configErrs *ConfigErrors, key string, value int64) {
- if value == 0 {
- configErrs.Add(fmt.Sprintf("missing config key %q", key))
- }
-}
-
// checkPositive verifies the given value is positive (zero included)
// in the configuration. If it is not, adds an error to the list.
func checkPositive(configErrs *ConfigErrors, key string, value int64) {
@@ -431,26 +410,6 @@ func checkPositive(configErrs *ConfigErrors, key string, value int64) {
}
}
-// checkURL verifies that the parameter is a valid URL
-func checkURL(configErrs *ConfigErrors, key, value string) {
- if value == "" {
- configErrs.Add(fmt.Sprintf("missing config key %q", key))
- return
- }
- url, err := url.Parse(value)
- if err != nil {
- configErrs.Add(fmt.Sprintf("config key %q contains invalid URL (%s)", key, err.Error()))
- return
- }
- switch url.Scheme {
- case "http":
- case "https":
- default:
- configErrs.Add(fmt.Sprintf("config key %q URL should be http:// or https://", key))
- return
- }
-}
-
// checkLogging verifies the parameters logging.* are valid.
func (config *Dendrite) checkLogging(configErrs *ConfigErrors) {
for _, logrusHook := range config.Logging {
@@ -461,7 +420,7 @@ func (config *Dendrite) checkLogging(configErrs *ConfigErrors) {
// check returns an error type containing all errors found within the config
// file.
-func (config *Dendrite) check(_ bool) error { // monolithic
+func (config *Dendrite) check() error { // monolithic
var configErrs ConfigErrors
if config.Version != Version {
@@ -528,58 +487,13 @@ func readKeyPEM(path string, data []byte, enforceKeyIDFormat bool) (gomatrixserv
}
}
-// AppServiceURL returns a HTTP URL for where the appservice component is listening.
-func (config *Dendrite) AppServiceURL() string {
- // Hard code the appservice server to talk HTTP for now.
- // If we support HTTPS we need to think of a practical way to do certificate validation.
- // People setting up servers shouldn't need to get a certificate valid for the public
- // internet for an internal API.
- return string(config.AppServiceAPI.InternalAPI.Connect)
-}
-
-// FederationAPIURL returns an HTTP URL for where the federation API is listening.
-func (config *Dendrite) FederationAPIURL() string {
- // Hard code the federationapi to talk HTTP for now.
- // If we support HTTPS we need to think of a practical way to do certificate validation.
- // People setting up servers shouldn't need to get a certificate valid for the public
- // internet for an internal API.
- return string(config.FederationAPI.InternalAPI.Connect)
-}
-
-// RoomServerURL returns an HTTP URL for where the roomserver is listening.
-func (config *Dendrite) RoomServerURL() string {
- // Hard code the roomserver to talk HTTP for now.
- // If we support HTTPS we need to think of a practical way to do certificate validation.
- // People setting up servers shouldn't need to get a certificate valid for the public
- // internet for an internal API.
- return string(config.RoomServer.InternalAPI.Connect)
-}
-
-// UserAPIURL returns an HTTP URL for where the userapi is listening.
-func (config *Dendrite) UserAPIURL() string {
- // Hard code the userapi to talk HTTP for now.
- // If we support HTTPS we need to think of a practical way to do certificate validation.
- // People setting up servers shouldn't need to get a certificate valid for the public
- // internet for an internal API.
- return string(config.UserAPI.InternalAPI.Connect)
-}
-
-// KeyServerURL returns an HTTP URL for where the key server is listening.
-func (config *Dendrite) KeyServerURL() string {
- // Hard code the key server to talk HTTP for now.
- // If we support HTTPS we need to think of a practical way to do certificate validation.
- // People setting up servers shouldn't need to get a certificate valid for the public
- // internet for an internal API.
- return string(config.KeyServer.InternalAPI.Connect)
-}
-
// SetupTracing configures the opentracing using the supplied configuration.
-func (config *Dendrite) SetupTracing(serviceName string) (closer io.Closer, err error) {
+func (config *Dendrite) SetupTracing() (closer io.Closer, err error) {
if !config.Tracing.Enabled {
return io.NopCloser(bytes.NewReader([]byte{})), nil
}
return config.Tracing.Jaeger.InitGlobalTracer(
- serviceName,
+ "Dendrite",
jaegerconfig.Logger(logrusLogger{logrus.StandardLogger()}),
jaegerconfig.Metrics(jaegermetrics.NullFactory),
)