From d8f3f525d5363d9a54c0ada9de1e7df6e1e4920e Mon Sep 17 00:00:00 2001 From: Ziinc Date: Thu, 11 Jan 2024 03:10:15 +0700 Subject: [PATCH] chore: simplify batch creation (#50) --- lib/pipeline.ex | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pipeline.ex b/lib/pipeline.ex index a78e9ad..5f85767 100644 --- a/lib/pipeline.ex +++ b/lib/pipeline.ex @@ -17,11 +17,9 @@ defmodule Loadfest.Pipeline do end def handle_demand(demand, state) when demand > 0 do - messages = - for batch_size <- Loadfest.Worker.stream_batch_sizes() |> Enum.take(demand), - events = Loadfest.Worker.stream_batch() |> Enum.take(batch_size) do - %Broadway.Message{data: events, acknowledger: {__MODULE__, :ack, 3}} - end + messages = for _i <- 1..demand do + %Broadway.Message{data: Loadfest.Worker.make_batch(), acknowledger: {__MODULE__, :ack, 3}} + end {:noreply, messages, state} end