[#1170] pkg/morph: Add inactive mode callback

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-03-31 14:17:01 +03:00 committed by Alex Vanin
parent 424cc6d495
commit 2427593da6
2 changed files with 25 additions and 3 deletions

View file

@ -543,10 +543,16 @@ func (c *Client) NotificationChannel() <-chan client.Notification {
// inactiveMode switches Client to an inactive mode:
// - notification channel is closed;
// - all the new RPC request would return ErrConnectionLost.
//
// Note: must be called only with held write switchLock.
// - all the new RPC request would return ErrConnectionLost;
// - inactiveModeCb is called if not nil.
func (c *Client) inactiveMode() {
c.switchLock.Lock()
defer c.switchLock.Unlock()
close(c.notifications)
c.inactive = true
if c.cfg.inactiveModeCb != nil {
c.cfg.inactiveModeCb()
}
}