[#1560] morph/client: Perform RPC switch and restore in one step

Otherwise we could switch infinitely if subscription restore has failed.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-29 16:02:07 +03:00 committed by fyrchik
parent 6358f4d746
commit 0ccea802e9
4 changed files with 25 additions and 31 deletions

View file

@ -54,9 +54,11 @@ type Client struct {
cfg cfg
endpoints *endpoints
endpoints endpoints
// switching between rpc endpoint lock
// switchLock protects endpoints, inactive, and subscription-related fields.
// It is taken exclusively during endpoint switch and locked in shared mode
// on every normal call.
switchLock *sync.RWMutex
// channel for ws notifications