Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions lib/broadway/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ defmodule Broadway.Process do
Process.set_label(label)
end

def labels_supported?, do: true
# We don't use just "true" because callers would likely get type warnings,
# so we trick the compiler into this being dynamic.
def labels_supported?, do: :rand.uniform() >= 0.0
else
def set_label(_label) do
:ok
end

def labels_supported?, do: false
# We don't use just "true" because callers would likely get type warnings,
# so we trick the compiler into this being dynamic.
def labels_supported?, do: :rand.uniform() > 1.1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good but maybe we just bump to a more recent OTP version?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're on Elixir 1.7 here (😄) so I didn't wanna touch that but yeah I'd be ok to do that (in a follow-up PR?).

end
end
5 changes: 1 addition & 4 deletions lib/broadway/topology/producer_stage.ex
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ defmodule Broadway.Topology.ProducerStage do

defp maybe_rate_limit_and_buffer_messages(state, messages) do
if state.rate_limiting && messages != [] do
state = update_in(state.rate_limiting.message_buffer, &enqueue_batch(&1, messages))
state = update_in(state.rate_limiting.message_buffer, &:queue.in(messages, &1))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer to remove the helper function altogether since this is the only call site and the direct call is pretty straightforward. We check that the messages are not empty right on the line above this one, so the compiler was right obviously.

rate_limit_and_buffer_messages(state)
else
{state, messages}
Expand Down Expand Up @@ -372,9 +372,6 @@ defmodule Broadway.Topology.ProducerStage do
end
end

defp enqueue_batch(queue, _list = []), do: queue
defp enqueue_batch(queue, list), do: :queue.in(list, queue)

defp enqueue_batch_r(queue, _list = []), do: queue
defp enqueue_batch_r(queue, list), do: :queue.in_r(list, queue)

Expand Down
7 changes: 5 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ defmodule Broadway.MixProject do
deps: deps(),
docs: docs(),
package: package(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [docs: :docs]
test_coverage: [tool: ExCoveralls]
]
end

Expand All @@ -40,6 +39,10 @@ defmodule Broadway.MixProject do
]
end

def cli do
[preferred_envs: [docs: :docs]]
end

defp docs do
[
main: "introduction",
Expand Down
1 change: 0 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ExUnit.start(capture_log: true, assert_receive_timeout: 2000)
Logger.remove_backend(:console)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this doesn't change any test output when running on later Elixir versions, so I think we should be okay with just getting rid of this.

Loading