0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-06-03 04:59:08 +02:00
dendrite/setup/config/config_jetstream.go
Neil Alexander 51d229b025
Configuration tweaks (#2567)
This makes the following changes:

* The various `Defaults` functions are now responsible for setting sane defaults if `generate` is specified, rather than hiding them in `generate-config`
* Some configuration options have been marked as `omitempty` so that they don't appear in generated configs unnecessarily (monolith-specific vs. polylith-specific options)
* A new option `-polylith` has been added to `generate-config` to create a config that makes sense for polylith deployments (i.e. including the internal/external API listeners and per-component database sections)
* A new option `-normalise` has been added to `generate-config` to take an existing file and add any missing options and/or defaults
2022-09-01 14:15:41 +01:00

52 lines
1.6 KiB
Go

package config
import (
"fmt"
)
type JetStream struct {
Matrix *Global `yaml:"-"`
// Persistent directory to store JetStream streams in.
StoragePath Path `yaml:"storage_path"`
// A list of NATS addresses to connect to. If none are specified, an
// internal NATS server will be used when running in monolith mode only.
Addresses []string `yaml:"addresses"`
// The prefix to use for stream names for this homeserver - really only
// useful if running more than one Dendrite on the same NATS deployment.
TopicPrefix string `yaml:"topic_prefix"`
// Keep all storage in memory. This is mostly useful for unit tests.
InMemory bool `yaml:"in_memory"`
// Disable logging. This is mostly useful for unit tests.
NoLog bool `yaml:"-"`
// Disables TLS validation. This should NOT be used in production
DisableTLSValidation bool `yaml:"disable_tls_validation"`
}
func (c *JetStream) Prefixed(name string) string {
return fmt.Sprintf("%s%s", c.TopicPrefix, name)
}
func (c *JetStream) Durable(name string) string {
return c.Prefixed(name)
}
func (c *JetStream) Defaults(opts DefaultOpts) {
c.Addresses = []string{}
c.TopicPrefix = "Dendrite"
if opts.Generate {
c.StoragePath = Path("./")
c.NoLog = true
c.DisableTLSValidation = true
}
}
func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) {
if isMonolith { // polylith required configs below
return
}
// If we are running in a polylith deployment then we need at least
// one NATS JetStream server to talk to.
checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
}