Skip to content
Snippets Groups Projects
Verified Commit cbcca9ed authored by Malte Bauch's avatar Malte Bauch
Browse files

Do not create different clients if already created

parent e1ae9d60
No related branches found
No related tags found
1 merge request!1074Resolve "Too many open files"
Pipeline #227935 failed
......@@ -20,6 +20,8 @@ import (
tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
)
var gnmiClients = make(map[string]gpb.GNMIClient, 0)
// Gnmi implements the Transport interface and provides an SBI with the
// possibility to access a gNMI endpoint.
type Gnmi struct {
......@@ -64,9 +66,14 @@ func newGnmiTransport(opts *tpb.TransportOption, model shared.DeviceModel) (*Gnm
}
}
c, err := gnmi.Dial(gnmiConfig)
if err != nil {
return nil, err
var err error
c, ok := gnmiClients[opts.GetAddress()]
if !ok {
c, err = gnmi.Dial(gnmiConfig)
if err != nil {
return nil, err
}
gnmiClients[opts.GetAddress()] = c
}
log.WithFields(log.Fields{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment