Skip to content

Commit

Permalink
resource-directory: allow drop event when buffer of subscription is e…
Browse files Browse the repository at this point in the history
…xhausted
  • Loading branch information
jkralik committed Oct 8, 2021
1 parent 0f6a280 commit d2e8c3b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resource-directory/service/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (s *subscriptions) SubscribeForEvents(resourceProjection *Projection, srv p
}
}()

sendChan := make(chan pb.Event, 16)
sendChan := make(chan pb.Event, 1024)
go func() {
defer wg.Done()
for {
Expand All @@ -705,9 +705,11 @@ func (s *subscriptions) SubscribeForEvents(resourceProjection *Projection, srv p
case sendChan <- e:
return nil
case <-ctx.Done():
return fmt.Errorf("cannot send event: stream context returns error: %v", ctx.Err())
return fmt.Errorf("cannot send event (%+v) for subscription(%v): stream context returns error: %v", e.GetType(), e.GetSubscriptionId(), ctx.Err())
case <-senderCtx.Done():
return fmt.Errorf("cannot send event: sender context returns error: %v", ctx.Err())
return fmt.Errorf("cannot send event (%+v) for subscription(%v): sender context returns error: %v", e.GetType(), e.GetSubscriptionId(), ctx.Err())
default:
return fmt.Errorf("cannot send event (%+v) for subscription(%v): buffer it exhausted", e.GetType(), e.GetSubscriptionId())
}
}

Expand Down

0 comments on commit d2e8c3b

Please sign in to comment.