Skip to content

Instantly share code, notes, and snippets.



Created Jul 25, 2017
What would you like to do?
func (p *XImpl) Listen(_ *empty.Empty, rec services.X_ListenServer) error {
c := make(chan *services.X, 16)
defer p.remove(c)
ctx := rec.Context()
for {
select {
case v := <-c:
if err := rec.Send(v); err != nil {
return err
case <-ctx.Done():
return nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment