Two way streams for upcoming locking enhancements (#19796)

This commit is contained in:
Klaus Post
2024-06-07 08:51:52 -07:00
committed by GitHub
parent c5141d65ac
commit f00187033d
8 changed files with 573 additions and 104 deletions

View File

@@ -89,12 +89,26 @@ func (s *Stream) Results(next func(b []byte) error) (err error) {
return nil
}
if resp.Err != nil {
s.cancel(resp.Err)
return resp.Err
}
err = next(resp.Msg)
if err != nil {
s.cancel(err)
return err
}
}
}
}
// Done will return a channel that will be closed when the stream is done.
// This mirrors context.Done().
func (s *Stream) Done() <-chan struct{} {
return s.ctx.Done()
}
// Err will return the error that caused the stream to end.
// This mirrors context.Err().
func (s *Stream) Err() error {
return s.ctx.Err()
}