-
Notifications
You must be signed in to change notification settings - Fork 11
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
MF-29 - goroutine in some cases never process channel messages #30
MF-29 - goroutine in some cases never process channel messages #30
Conversation
…er goroutine Signed-off-by: PricelessRabbit <PricelessRabbit@gmail.com>
@pricelessrabbit can you point me where exactly you put the |
@mteodor but the so then when the loop in the main goroutine continues, it updates r fields with the next route data. But the worker has a pointer to r and not a copy, so all the r fields are updated also in the worker goroutine (also the channel However, seems (but i'm not shure of that) that if the channel is already filled when the |
i think that change should be like
|
this morning i evaluate and try also in that way. It works, but multiple workers goroutines gets the same route reference, and share the state. This is not a good thing imho because if the route struct change in some manner, all the workers will be affected and this can lead to unexpected behaviours. |
that is the idea, there should be only one instance of each route, and it should not change during the runtime, workers should only process messages and read the route info to know where to send |
yep it is for that very reason that i think that provide every worker with an immutable value-copy of the route is the most solid solution to avoid possible accidentally modification of data, but if you are ok with the shared state i refactor the fix in that way and update the PR |
@pricelessrabbit yes, please do so, and I'll rethink this what you pointed out |
Signed-off-by: PricelessRabbit <PricelessRabbit@gmail.com>
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.
LGTM
Fixed #29 :
reference type cause the route struct channel to be overwritten by the goroutine that subscribe the routes.
The
for := range
channel reference is changed if not already used and consumer got stuckChanged the Consume func receiver to value receiver. In this way each worker has owns a copy of route data
Signed-off-by: PricelessRabbit PricelessRabbit@gmail.com