forked from TrueCloudLab/frostfs-node
[#1244] nats: Split client creation into 2 stages
Create and connect to an endpoint using separate functions. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
2b0460c532
commit
414ba6e0a2
4 changed files with 47 additions and 36 deletions
|
@ -115,9 +115,7 @@ func initNotifications(c *cfg) {
|
|||
topic = pubKey
|
||||
}
|
||||
|
||||
natsSvc, err := nats.New(
|
||||
c.ctx,
|
||||
nodeconfig.Notification(c.appCfg).Endpoint(),
|
||||
natsSvc := nats.New(
|
||||
nats.WithConnectionName("NeoFS Storage Node: "+pubKey), // connection name is used in the server side logs
|
||||
nats.WithTimeout(nodeconfig.Notification(c.appCfg).Timeout()),
|
||||
nats.WithClientCert(
|
||||
|
@ -127,9 +125,6 @@ func initNotifications(c *cfg) {
|
|||
nats.WithRootCA(nodeconfig.Notification(c.appCfg).CAPath()),
|
||||
nats.WithLogger(c.log),
|
||||
)
|
||||
if err != nil {
|
||||
panic("could not created object notificator: " + err.Error())
|
||||
}
|
||||
|
||||
c.cfgNotifications = cfgNotifications{
|
||||
enabled: true,
|
||||
|
@ -158,3 +153,15 @@ func initNotifications(c *cfg) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func connectNats(c *cfg) {
|
||||
if !c.cfgNotifications.enabled {
|
||||
return
|
||||
}
|
||||
|
||||
endpoint := nodeconfig.Notification(c.appCfg).Endpoint()
|
||||
err := c.cfgNotifications.nw.w.Connect(c.ctx, endpoint)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("could not connect to a nats endpoint %s: %v", endpoint, err))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue