forked from TrueCloudLab/frostfs-node
[#1648] morph: Init endpoints before first client creation
Sort the endpoint by their priority before the first WS client creation to start the morph client with the highest priority endpoint. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
1c1b5043fc
commit
2467be0117
1 changed files with 3 additions and 2 deletions
|
@ -107,6 +107,8 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) {
|
||||||
closeChan: make(chan struct{}),
|
closeChan: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cli.endpoints.init(cfg.endpoints)
|
||||||
|
|
||||||
if cfg.singleCli != nil {
|
if cfg.singleCli != nil {
|
||||||
// return client in single RPC node mode that uses
|
// return client in single RPC node mode that uses
|
||||||
// predefined WS client
|
// predefined WS client
|
||||||
|
@ -117,7 +119,7 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) {
|
||||||
// inactive mode will be enabled
|
// inactive mode will be enabled
|
||||||
cli.client = cfg.singleCli
|
cli.client = cfg.singleCli
|
||||||
} else {
|
} else {
|
||||||
ws, err := newWSClient(*cfg, cfg.endpoints[0].Address)
|
ws, err := newWSClient(*cfg, cli.endpoints.list[0].Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not create morph client: %w", err)
|
return nil, fmt.Errorf("could not create morph client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +131,6 @@ func New(key *keys.PrivateKey, opts ...Option) (*Client, error) {
|
||||||
|
|
||||||
cli.client = ws
|
cli.client = ws
|
||||||
}
|
}
|
||||||
cli.endpoints.init(cfg.endpoints)
|
|
||||||
|
|
||||||
go cli.notificationLoop()
|
go cli.notificationLoop()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue