GenStage no more demand

Simple question. What happens when a consumer has asked for more demand than the producer can supply? Currently in my app, the producer just sits there with demand for the consumer, but there is no more to send.

Is there a way for the producer to force the demand to the consumer? I guess padding is an option, but seems rather inefficient.

Is this because you’re using some bounded set of data to produce from?

Can you expand why this is an issue? If the producer will never be able to fulfill the demand why have the pipeline still running? If the demand can eventually be fulfilled then you can keep the demand „open“ until that happens.

In my understanding a producer can emit less items than the demand (correct me of I’m wrong). So you don’t have to wait if there is nothing more to produce at that moment in time. Maybe that’s where OP is stuck? If there is nothing more to produce, then yes, the producer should be shut down.

Good point. A producer doesn‘t need to fulfill demand at once. If there‘s demand for 10 events a producer may emit 5 it has queued and fulfill the other 5 whenever they become available.

One job of a producer is to manage how much demand it still has left to fulfill if it cannot always fulfill it immediatelly.

It was totally my lame brain…I had a cond statement prior to returning from the handle_demand/2.

It looked something like:

  cond do
    foo ->
   bar ->
  stuff_for_consumer = [] ->

Ooops…case made for not working late