2022-01-05 11:44:49 -06:00
|
|
|
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"`
|
2022-08-02 06:58:08 -05:00
|
|
|
// 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"`
|
2024-09-10 14:28:04 -05:00
|
|
|
// A credentials file to be used for authentication, example:
|
|
|
|
// https://docs.nats.io/using-nats/developer/connecting/creds
|
|
|
|
Credentials Path `yaml:"credentials_path"`
|
2022-01-05 11:44:49 -06:00
|
|
|
}
|
|
|
|
|
2022-03-23 05:20:18 -05:00
|
|
|
func (c *JetStream) Prefixed(name string) string {
|
2022-01-05 11:44:49 -06:00
|
|
|
return fmt.Sprintf("%s%s", c.TopicPrefix, name)
|
|
|
|
}
|
|
|
|
|
2022-02-02 07:32:48 -06:00
|
|
|
func (c *JetStream) Durable(name string) string {
|
2022-03-23 05:20:18 -05:00
|
|
|
return c.Prefixed(name)
|
2022-01-07 11:31:57 -06:00
|
|
|
}
|
|
|
|
|
2022-09-01 08:15:41 -05:00
|
|
|
func (c *JetStream) Defaults(opts DefaultOpts) {
|
2022-01-05 11:44:49 -06:00
|
|
|
c.Addresses = []string{}
|
|
|
|
c.TopicPrefix = "Dendrite"
|
2022-09-01 08:15:41 -05:00
|
|
|
if opts.Generate {
|
2022-01-05 11:44:49 -06:00
|
|
|
c.StoragePath = Path("./")
|
2022-08-02 06:58:08 -05:00
|
|
|
c.NoLog = true
|
|
|
|
c.DisableTLSValidation = true
|
2024-09-10 14:28:04 -05:00
|
|
|
c.Credentials = Path("")
|
2022-01-05 11:44:49 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-14 05:47:47 -06:00
|
|
|
func (c *JetStream) Verify(configErrs *ConfigErrors) {}
|