Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more clarity on the length of list in c:prepare_messages/2 #333

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/broadway.ex
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,15 @@ defmodule Broadway do
by `c:handle_message/3`. For example, if you need to query the database,
instead of doing it once per message, you can do it on this callback.

The length of the list of messages received by this callback is based on
the `min_demand`/`max_demand` configuration in the processor. This callback
must always return all messages it receives, as `c:handle_message/3` is still
called individually for each message afterwards.
The length of the list of messages received by this callback is often based
on the `min_demand`/`max_demand` configuration in the processor but ultimately
it depends on the producer and the frequency data arrives. A pipeline that
receives one message per minute will most likely emit single element lists.
Producers which are push-based, rather than pull-based, such as
`BroadwayRabbitMQ.Producer`, are more likely to send messages as they appear.

This callback must always return all messages it receives, as
`c:handle_message/3` is still called individually for each message afterwards.
"""
@callback prepare_messages(messages :: [Message.t()], context :: term) :: [Message.t()]

Expand Down
Loading