0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-06-14 02:18:34 +02:00

Reuse existing NATS connection

This commit is contained in:
Till Faelligen 2024-03-22 21:39:26 +01:00
parent b9abbf7b20
commit 3e1445176a
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -38,7 +38,12 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
defer natsLock.Unlock()
// check if we need an in-process NATS Server
if len(cfg.Addresses) != 0 {
return setupNATS(process, cfg, nil)
// reuse existing connections
if s.nc != nil {
return s.js, s.nc
}
s.js, s.nc = setupNATS(process, cfg, nil)
return s.js, s.nc
}
if s.Server == nil {
var err error