Skip to content

stream/3 hangs #191

@kevinbader

Description

@kevinbader

Hi all,

I'm not sure whether I don't understand how stream/3 is supposed to work, or it's buggy:

defmodule KafkaTest do
  @moduledoc false
  @topic "elixirtest"
  @partition 0

  # this works
  def uses_stream_immediately_takes_two do
    KafkaEx.stream(@topic, @partition, offset: 0)
    |> Stream.map(& "the value: " <> &1.value)
    |> Enum.take(2)
  end

  # using to_list instead of take causes the method to never return:
  def uses_stream_immediately_takes_all do
    KafkaEx.stream(@topic, @partition, offset: 0)
    |> Stream.map(& "the value: " <> &1.value)
    |> Enum.to_list
  end

  # not using the stream immediately causes the method to never return, too:
  def waits_before_using_the_stream_takes_two do
    theStream = KafkaEx.stream(@topic, @partition, offset: 0)
    :timer.sleep(1000)  # waiting a bit..
    theStream
    |> Stream.map(& "the value: " <> &1.value)
    |> Enum.take(2)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions