1
0

GODT-2014: bridge quit if gRPC client ends stream (v3)

This commit is contained in:
James Houlahan
2022-11-04 01:18:41 +01:00
parent 8b5cb7729c
commit 8bb60afabd
3 changed files with 50 additions and 15 deletions

View File

@ -96,12 +96,15 @@ func (s *Service) GuiReady(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empt
// Quit implement the Quit gRPC service call.
func (s *Service) Quit(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empty, error) {
s.log.Debug("Quit")
return &emptypb.Empty{}, s.quit()
}
func (s *Service) quit() error {
// Windows is notably slow at Quitting. We do it in a goroutine to speed things up a bit.
go func() {
var err error
if s.eventStreamCh != nil {
if _, err = s.StopEventStream(ctx, empty); err != nil {
if s.isStreamingEvents() {
if err = s.stopEventStream(); err != nil {
s.log.WithError(err).Error("Quit failed.")
}
}
@ -110,7 +113,7 @@ func (s *Service) Quit(ctx context.Context, empty *emptypb.Empty) (*emptypb.Empt
s.grpcServer.GracefulStop()
}()
return &emptypb.Empty{}, nil
return nil
}
// Restart implement the Restart gRPC service call.