forked from TrueCloudLab/frostfs-node
[#746] morph: Implement and use multi-client
There is a need to work with a set of Neo RPC nodes in order not to depend on the failure of some nodes while others are active. Support "multi-client" mode of morph `Client` entity. If instance is not "multi-client", it works as before. Constructor `New` creates multi-client, and each method performs iterating over the fixed set of endpoints until success. Opened client connections are cached (without eviction for now). Storage (as earlier) and IR (from now) nodes can be configured with multiple Neo endpoints. As above, `New` creates multi-client instance, so we don't need initialization changes on app-side. `Wait` and `GetDesignateHash` methods of `Client` return an error from now to detect connection errors. `NotaryEnabled` method is removed as unused. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f9218bf84f
commit
ad7ad12a0c
7 changed files with 345 additions and 89 deletions
|
@ -866,13 +866,20 @@ func createListener(ctx context.Context, p *chainParams) (event.Listener, error)
|
|||
}
|
||||
|
||||
func createClient(ctx context.Context, p *chainParams) (*client.Client, error) {
|
||||
// config name left unchanged for compatibility, may be its better to rename it to "endpoints" or "clients"
|
||||
endpoints := p.cfg.GetStringSlice(p.name + ".endpoint.client")
|
||||
if len(endpoints) == 0 {
|
||||
return nil, fmt.Errorf("%s chain client endpoints not provided", p.name)
|
||||
}
|
||||
|
||||
return client.New(
|
||||
p.key,
|
||||
p.cfg.GetString(p.name+".endpoint.client"),
|
||||
endpoints[0],
|
||||
client.WithContext(ctx),
|
||||
client.WithLogger(p.log),
|
||||
client.WithDialTimeout(p.cfg.GetDuration(p.name+".dial_timeout")),
|
||||
client.WithSigner(p.sgn),
|
||||
client.WithExtraEndpoints(endpoints[1:]),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue