Skip to content

Conversation

silvanocerza
Copy link
Contributor

@silvanocerza silvanocerza commented Nov 24, 2021

Most of the quit successful message wasn't sent since the goroutine consuming messages to output wouldn't be fast enough.

Before:

$ ./dummy-discovery
quit

After:

$ ./dummy-discovery                                           
quit
{
  "eventType": "quit",
  "message": "OK"
}

@silvanocerza silvanocerza added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Nov 24, 2021
@silvanocerza silvanocerza requested a review from cmaglie November 24, 2021 16:40
@silvanocerza silvanocerza self-assigned this Nov 24, 2021
@silvanocerza silvanocerza requested a review from umbynos November 24, 2021 16:43
@@ -292,5 +306,8 @@ func (d *Server) outputProcessor(outWriter io.Writer) {
}
fmt.Fprintln(outWriter, string(data))
}
// We finished consuming all messages, now
// we can exit for real
d.outputWaiter.Done()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about dropping the channel + goroutine + waitgroup + d.quit in change of a mutex?

outputMutext.Lock()
output.Write(data)
outputMutex.Unlock()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be mean refactor everything again, I'd prefer to avoid that. 😖

On every push and pull request that affects relevant files, run the project's Go code tests.
@silvanocerza silvanocerza force-pushed the scerza/fix-quit-message branch from 89b039a to 84341ca Compare November 25, 2021 16:35
@silvanocerza silvanocerza force-pushed the scerza/fix-quit-message branch from 84341ca to 91f7240 Compare November 25, 2021 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants