forked from TrueCloudLab/frostfs-node
[#72] Close subscription channel if RPC was terminated
RPC node closes websocket notification channel if it was terminated or something wrong happened. Subscriber has to check this condition and alert about this in upper context by closing it's own channel. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
d3d8f00757
commit
ca006245d2
1 changed files with 8 additions and 1 deletions
|
@ -104,7 +104,14 @@ func (s *subscriber) routeNotifications(ctx context.Context) {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case notification := <-s.client.Notifications:
|
case notification, ok := <-s.client.Notifications:
|
||||||
|
if !ok {
|
||||||
|
s.log.Warn("remote channel has been closed")
|
||||||
|
close(s.notify)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
switch notification.Type {
|
switch notification.Type {
|
||||||
case response.NotificationEventID:
|
case response.NotificationEventID:
|
||||||
notification, ok := notification.Value.(*result.NotificationEvent)
|
notification, ok := notification.Value.(*result.NotificationEvent)
|
||||||
|
|
Loading…
Reference in a new issue