Various other refactoring

This commit is contained in:
Neil Alexander 2021-07-14 14:06:14 +01:00
parent 8f40e8fd5e
commit 48322bc2b2
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
12 changed files with 25 additions and 16 deletions

View file

@ -27,7 +27,7 @@ func SetupConsumerProducer(cfg *config.JetStream) (sarama.Consumer, sarama.SyncP
ServerName: "monolith",
DontListen: true,
JetStream: true,
StoreDir: string(cfg.Matrix.ServerName),
StoreDir: string(cfg.Matrix.JetStream.StoragePath),
})
if err != nil {
panic(err)
@ -76,6 +76,12 @@ func setupNATS(cfg *config.JetStream, nc *natsclient.Conn) (sarama.Consumer, sar
stream.Name = cfg.TopicFor(stream.Name)
stream.Subjects = []string{stream.Name}
// If we're trying to keep everything in memory (e.g. unit tests)
// then overwrite the storage policy.
if cfg.InMemory {
stream.Storage = nats.MemoryStorage
}
if _, err = s.AddStream(stream); err != nil {
logrus.WithError(err).WithField("stream", stream.Name).Fatal("Unable to add stream")
}