mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-10 15:14:36 +00:00
Reuse existing NATS connection (#3345)
If using external NATS, we opened unnecessary connections. This now re-uses existing connections. [skip ci]
This commit is contained in:
parent
79072c3dcd
commit
81f73c9f8d
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue