I just wrote a GenStage Producer that I use with Flow in order to stream entries from an Ecto query.
I’m learning GenStage and would like some feedback regarding my code (especially the send_after which I’d like to avoid … but gives me no process: the process is not alive or there's no process currently associated with the given name errors when removed
I haven’t looked at the the code in depth, but from handle_demand you can return {:stop, reason, new_state} (https://hexdocs.pm/gen_stage/GenStage.html#c:handle_demand/2). Are you saying that this is what was giving you the error when you tried it?
Good idea! but unfortunately under the hood GenStage.async_info is just sending (GenServer.cast) a message. Which gives me the same error (unless I wait for 5 or 10ms before)
By the way the error is only happening when the producer has 0 to very few events to produce. No error for larger streams …
But the cast itself isn’t the issue: it works and the server terminates properly, but then some consumer tries to send messages to the producer and stumbles on the error.