mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-12-26 17:36:20 +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
|
@ -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