Skip to content

Commit

Permalink
chore: simplify batch creation (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc authored Jan 10, 2024
1 parent ae95e46 commit d8f3f52
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/pipeline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8f3f52

Please sign in to comment.