Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Inspect the data passed between GenStages.
defmodule StageInspector do
alias Experimental.{GenStage}
use GenStage
def init(type) when type in [:consumer, :producer_consumer] do
{type, type}
end
def handle_events(events, _from, state = :consumer) do
Enum.each events, &inspect_event/1
{:noreply, [], state}
end
def handle_events(events, _from, state = :producer_consumer) do
Enum.each events, &inspect_event/1
{:noreply, events, state}
end
defp inspect_event(event) when is_binary(event), do: IO.puts(event)
defp inspect_event(event), do: IO.inspect(event)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.