You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the past few days, I have been struggling with this problem. I have a processor function that uses a persist edge. At some point in this function, I must offload some work to a goroutine, and the result of the work should be written to the group table from within this goroutine. However, if I use ctx.SetValue for this, I get this panic: panic: sync: negative WaitGroup counter. I found this issue that explains the cause of this and it suggests the following (among some other solutions below that):
If you want to use a goroutine, then it's better to create a producer and pass the producer and message to the goroutine (but not the goka.Context). It may be also safer cloning the message.
but are there any examples on how to do this? Is a producer basically a standalone emitter that is not bound to the context (that is the solution I have in mind currently for this problem). The other suggested solutions also do not really solve my problem as they involve blocking the process until the goroutine finishes, and that is not an option for me. The purpose of my function is to debounce calls to another API until after a certain time, e.g.:
Consecutive calls to this updateUser function cancel eachother out, until there hasn't been a call for a certain time (h.debounceTime). If I block the updateUser function until this time has passed this construct is not possible.
I only want to write the user to the group table once the call to the remote API has succeeded, so the current context value always contains the user version that has last been successfully sent to the API.
Does anybody have any words of wisdoms or advice on this? :)
The text was updated successfully, but these errors were encountered:
In the past few days, I have been struggling with this problem. I have a processor function that uses a persist edge. At some point in this function, I must offload some work to a goroutine, and the result of the work should be written to the group table from within this goroutine. However, if I use ctx.SetValue for this, I get this panic:
panic: sync: negative WaitGroup counter
. I found this issue that explains the cause of this and it suggests the following (among some other solutions below that):but are there any examples on how to do this? Is a producer basically a standalone emitter that is not bound to the context (that is the solution I have in mind currently for this problem). The other suggested solutions also do not really solve my problem as they involve blocking the process until the goroutine finishes, and that is not an option for me. The purpose of my function is to debounce calls to another API until after a certain time, e.g.:
Consecutive calls to this updateUser function cancel eachother out, until there hasn't been a call for a certain time (
h.debounceTime
). If I block the updateUser function until this time has passed this construct is not possible.I only want to write the user to the group table once the call to the remote API has succeeded, so the current context value always contains the user version that has last been successfully sent to the API.
Does anybody have any words of wisdoms or advice on this? :)
The text was updated successfully, but these errors were encountered: