Halting a pipe

I think this ElixirConf talk will be worth a watch for you: 7) ElixirConf US 2018 – Architecting Flow in Elixir - From Leveraging Pipes to Designing Token APIs – René Föhring

The solution will be context dependent. Based on your problem description I would probably simply break the pipeline into two separate parts

data = 
  url
  |> get_html_data()
  |> check_data_exist()

case data do
  {:ok, fetched_data} ->
    fetched_data

  {:error, :not_fetched} ->
    data
    |> process_html_data()
    |> parse_data_list()
end

But it’ll depend on your specific scenario (which is why the video and associated blog posts are worth viewing).

3 Likes