GenState.stream API feedback

43 views
Skip to first unread message

er...@scouten.com

unread,
Oct 25, 2016, 11:03:27 PM10/25/16
to elixir-lang-core
While I understand the desire to make a stream out of multiple GenStages, I find myself writing this snippet of code frequently …

  defp gen_stage_to_stream(pid) when is_pid(pid) do
   
GenStage.stream([pid])
 
end

… so I can then use the stream in a pipe chain.

This seems a bit cumbersome. Any hope for a version of GenStage.stream that accepts a single pid outside of a list?

I'm open to writing a PR if the team is amenable to this.

-Eric

José Valim

unread,
Oct 26, 2016, 6:07:41 AM10/26/16
to elixir-l...@googlegroups.com
Your code is perfect as is. Small private functions are really helpful so keep doing it. We don't plan to change GenStage. :)



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/899f7862-b5dd-445e-9bff-265fb0587511%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

er...@scouten.com

unread,
Oct 26, 2016, 1:27:12 PM10/26/16
to elixir-lang-core, jose....@plataformatec.com.br
Much as I love to hear my code described as "perfect" :-), I'm going to push back. The pipe chain looks pretty funky to me and I think there's an easy, backward-compatible change that could be made to satisfy all involved:

def stream(subscription, options) when is_pid(subscription) do
 
GenStage.stream([subscription], options)
end

… and accompanying documentation updates. If that's appealing, I'm happy to write the PR.

-Eric


On Wednesday, October 26, 2016 at 3:07:41 AM UTC-7, José Valim wrote:
Your code is perfect as is. Small private functions are really helpful so keep doing it. We don't plan to change GenStage. :)



José Valim
Skype: jv.ptec
Founder and Director of R&D

On Wed, Oct 26, 2016 at 5:03 AM, <er...@scouten.com> wrote:
While I understand the desire to make a stream out of multiple GenStages, I find myself writing this snippet of code frequently …

  defp gen_stage_to_stream(pid) when is_pid(pid) do
   
GenStage.stream([pid])
 
end

… so I can then use the stream in a pipe chain.

This seems a bit cumbersome. Any hope for a version of GenStage.stream that accepts a single pid outside of a list?

I'm open to writing a PR if the team is amenable to this.

-Eric

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages