Skip to content

Commit 047060c

Browse files
committed
set pool value if it is nil
1 parent 45454a7 commit 047060c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

pkg/environment/environment.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,16 @@ func GetSubstrate() (substrate.Manager, error) {
292292
if !slices.Equal(subURLs, env.SubstrateURL) {
293293
// before attempting to update the manager check if pool variable maintain a healthy connection
294294
// pool.Row() checks the health of the connection and if all the urls used in pool are down, then it will return error
295-
cl, _, err := pool.Raw()
296-
// if the old manager is broken, then we should update the manager
297-
if err != nil {
295+
if pool != nil {
296+
cl, _, err := pool.Raw()
297+
if err == nil {
298+
cl.Client.Close()
299+
return pool, nil
300+
}
298301
log.Debug().Strs("substrate_urls", env.SubstrateURL).Msg("updating to sub manager with url")
299-
subURLs = env.SubstrateURL
300-
pool = substrate.NewManager(env.SubstrateURL...)
301302
}
302-
cl.Client.Close()
303+
subURLs = env.SubstrateURL
304+
pool = substrate.NewManager(env.SubstrateURL...)
303305
}
304306

305307
// poolOnce.Do(func() {

0 commit comments

Comments
 (0)