mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-21 11:11:39 +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()
|
defer natsLock.Unlock()
|
||||||
// check if we need an in-process NATS Server
|
// check if we need an in-process NATS Server
|
||||||
if len(cfg.Addresses) != 0 {
|
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 {
|
if s.Server == nil {
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user