dendrite/setup/config/config_jetstream.go

41 lines
1.2 KiB
Go
Raw Normal View History

2021-07-14 07:34:42 -05:00
package config
import (
"fmt"
)
2021-07-14 07:34:42 -05:00
type JetStream struct {
Matrix *Global `yaml:"-"`
2021-07-14 08:06:14 -05:00
// Persistent directory to store JetStream streams in.
StoragePath Path `yaml:"storage_path"`
2021-07-14 07:34:42 -05:00
// 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"`
2021-07-14 08:06:14 -05:00
// Keep all storage in memory. This is mostly useful for unit tests.
2021-07-14 09:25:15 -05:00
InMemory bool `yaml:"in_memory"`
2021-07-14 07:34:42 -05:00
}
2021-07-14 08:06:14 -05:00
func (c *JetStream) TopicFor(name string) string {
return fmt.Sprintf("%s%s", c.TopicPrefix, name)
2021-07-14 07:34:42 -05:00
}
2021-11-24 06:04:32 -06:00
func (c *JetStream) Defaults(generate bool) {
2021-07-14 07:34:42 -05:00
c.Addresses = []string{}
c.TopicPrefix = "Dendrite"
2021-11-24 06:04:32 -06:00
if generate {
c.StoragePath = Path("./")
}
2021-07-14 07:34:42 -05:00
}
func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) {
// If we are running in a polylith deployment then we need at least
// one NATS JetStream server to talk to.
if !isMonolith {
checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
}
}