1
votes

There is a project with genstage.

Producer A, producer-consumer B, and consumer C.

B requests events one at A (min_demand: 0, max_demand: 1).

{:producer_consumer, nil, subscribe_to: [{Grub.Producer, max_demand: 1, min_demand: 0}]}

C requests several events from B (min_demand: 25, max_demand: 50).

workers = for id <- 1..count do
  {:"Elixir.Grub.Worker#{id}", max_demand: 50, min_demand: 25}
end
{:consumer, {in_process_queue, errors_queue}, subscribe_to: workers}

But in fact, C receives and processes data one at a time (I see this from the application log).

How to make C process data in batches?

1

1 Answers

1
votes

GenStage do not cache data on it's own. So what you need to do is to cache data in producer-consumer like it is documented.