mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 04:00:05 +00:00
Propagate Cancellation To Beacon Node Server (#8512)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
6ee290a9af
commit
08b938982b
@ -57,7 +57,12 @@ func (s *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*pb.VersionRe
|
||||
|
||||
// StreamBeaconLogs from the beacon node via a gRPC server-side stream.
|
||||
func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeaconLogsServer) error {
|
||||
client, err := s.beaconNodeHealthClient.StreamBeaconLogs(s.ctx, req)
|
||||
// Wrap service context with a cancel in order to propagate the exiting of
|
||||
// this method properly to the beacon node server.
|
||||
ctx, cancel := context.WithCancel(s.ctx)
|
||||
defer cancel()
|
||||
|
||||
client, err := s.beaconNodeHealthClient.StreamBeaconLogs(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -67,6 +72,8 @@ func (s *Server) StreamBeaconLogs(req *ptypes.Empty, stream pb.Health_StreamBeac
|
||||
return status.Error(codes.Canceled, "Context canceled")
|
||||
case <-stream.Context().Done():
|
||||
return status.Error(codes.Canceled, "Context canceled")
|
||||
case <-client.Context().Done():
|
||||
return status.Error(codes.Canceled, "Context canceled")
|
||||
default:
|
||||
resp, err := client.Recv()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user