-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve processor stopped state management #449
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @jalaziz, sorry for the delay!
😄 the deadlock is removed, but the test reports a data-race. |
* Introduce a new `Stopped` state for processors. Since a processor cannot be restarted after it has been run, this state better indicates that the processor has reached its final state. * Expose a new `Done()` method on the processor to allow waiting on a processor to complete. This avoids the need to apply additional "done" channels on top of the processor when processors in go routines.
44bd60b
to
5de45a0
Compare
@frairon So actually, there is a data race. The data race happens because the channel will be closed before the error is returned from I could fix the test by introducing an extra done channel for the text. However, another way to fix this is to have the What do you think? |
True that, there is a data race, but the data race is in the test only. If we add a synchronizing channel or a mutex it's fixed. But of course, that's not optimal. On the other hand, returning the error through the done-channel also doesn't work, because only the first consumer might get the error. As soon as multiple clients wait for the processor it becomes inconsistent. We could create a new errors-channel each time the method is called and copy the error, which is even uglier. So what if we instead provide an What do you think about that? |
@frairon I have implement what you suggested. Let me know what you think. I'm a bit torn on whether all the tests should be updated to use |
@jalaziz thanks for this, really! Since we have the |
@frairon Updated the tests, but I added two tests to make sure the tests still covered the returned error. |
Looks good, thanks! @norbertklawikowski what do you think? |
LGTM, just a tiny comment :) |
6b87a50
to
63d09bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks a lot!
Stopped
state for processors. Since a processor cannot be restarted after it has been run, this state better indicates that the processor has reached its final state.Done()
method on the processor to allow waiting on a processor to complete. This avoids the need to apply additional "done" channels on top of the processor when processors in go routines.