Closed maennchen closed 9 months ago
I think this still has a race, it is just less likely. Instead, you most likely want to do this on init:
{:producer, state, demand: :accumulate}
And then once all process subscribe, you call GenStage.demand(producer, :forward)
. :)
@josevalim I've updated to the new solution. This is also way more elegant than subscribing asynchronously.
In my use case, I now have a little job that runs at the end of the containing Supervisor
s children, which calls all producing stages to change the demand
.
:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart:
Follow up to dicussion via Slack with @josevalim
I'm not sure if that explanation is good. I think it could be more concise.