Skip to content

Commit

Permalink
only wait on err chan
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Nov 9, 2024
1 parent f868ae9 commit f6f5320
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -721,15 +721,15 @@ func executeStreamCallAndGetReceivedServiceLogLines(
case <-time.Tick(testTimeOut):
return nil, stacktrace.NewError("Receiving stream logs in the test has reached the '%v' time out", testTimeOut)
case streamErr, isChanOpen := <-errChan:
if !isChanOpen {
if len(userServiceLogsByUuidChan) == 0 {
shouldReceiveStream = false
}
if !isChanOpen && len(userServiceLogsByUuidChan) == 0 {
shouldReceiveStream = false
break
}
return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.")
if isChanOpen && streamErr != nil {
return nil, stacktrace.Propagate(streamErr, "Receiving streaming error.")
}
case userServiceLogsByUuid, isChanOpen := <-userServiceLogsByUuidChan:
if !isChanOpen && len(userServiceLogsByUuidChan) == 0 {
if !isChanOpen {
shouldReceiveStream = false
break
}
Expand Down
9 changes: 3 additions & 6 deletions engine/server/engine/server/engine_connect_server_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c
//stream case
case serviceLogsByServiceUuid, isChanOpen := <-serviceLogsByServiceUuidChan:
// If the channel is closed means that the logs database client won't continue sending streams
// but keep reading from it until the channel is empty
if !isChanOpen && len(serviceLogsByServiceUuidChan) == 0 {
if !isChanOpen {
logrus.Debug("Exiting the stream loop after receiving a close signal from the service logs by service UUID channel")
return nil
}
Expand All @@ -359,10 +358,8 @@ func (service *EngineConnectServerService) GetServiceLogs(ctx context.Context, c
}
//client cancel ctx case
case <-contextWithCancel.Done():
if len(serviceLogsByServiceUuidChan) == 0 {
logrus.Debug("The user service logs stream has done")
return nil
}
logrus.Debug("The user service logs stream is done.")
return nil
//error from logs database case
case err, isChanOpen := <-errChan:
if isChanOpen {
Expand Down

0 comments on commit f6f5320

Please sign in to comment.