GenStage eye for the Akka Streams guy?

I’m coming from a Scala and Akka Streams background. Elixir GenStage and Flow seem familiar and attractive. What I seem to be missing is the GenStage ecosystem and some off the shelf sources.

For example, I’d like to write a streaming socket duplicator. Take a TCP producer and broadcast binaries to multiple consumer pipelines.

Where is the high-quality TCP/UDP GenStage Producer (I see File IO support, but not network)?

Is there an explicit implementation of a “buffer” stage that supports various overflow strategies similar to (http://doc.akka.io/docs/akka/2.5.3/scala/stream/stream-rate.html#buffers-in-akka-streams)?

Is there a connector ecosystem similar to http://developer.lightbend.com/docs/alpakka/current/?

Thanks for any help/tips/pointers.

I don’t believe such a thing has kicked off, no. While there are more libraries using GenStage and Flow over time, a coordinated collection of useful GenStage modules does not exist, at least afaik.

It would be awesome to start it though! :slight_smile:

Bummer that more foundational stages don’t exist yet. An Elixir provided TCP producer stage seems like something that ought to be standard with this concept.

I’d be willing to contribute to a coordinated collection or an umbrella project that seeks to unify quality stage implementations, high-level flow API as well as eventually a graph API. But I don’t have the time to lead such an effort. Is that something the Elixir guys could coordinate?

The community has been amazing thus far. It even seems that the Witchcraft folks are working on a graph DSL, albeit not for GenStages explicitly. I’ve no doubt that the community can collect some amazing building blocks if they were coordinated.

You’ll need a:

  • Site dedicated to “Reactive Elixir” or whatever buzzword you want.
  • Codebase for developers to submit PRs against.
  • Collection of foundational stages.
  • Higher level stage abstractions, like Flow and Graph. (include the ability to delegate the constructing of physical stages from Flow/Graph descriptions – this will allow for optimizations such as stage fusion where a single stage handles a process chain, avoiding message passing overhead)
  • Tutorials showing many examples and cookbooks for solving common problems.

Elixir has already borrowed concepts from Reactive Streams and the Akka community. Borrow this too. It will take proper stream-based programming on Elixir to the next level. It may even drive language adoption. Since there would be a clear path for those looking to move from the JVM to BEAM using familiar methodologies.

2 Likes

I think it is equal parts “GenStage is relatively new” and that the Elixir community tends to, at least currently, have a purpose-specific-module-centric view for development and collaboration. Nothing that can’t be improved though :slight_smile:

Flow already exists that does some of this. IMHO it would make sense to make use of that, and continue to extend it in the areas it is still lacking.

The rest I agree with … let’s see …

Looping back on this…

A major limitation of Flow as I see it today is the inability to structure flows as a graph of arbitrary GenStages. Flow provides a DSL for certain things today. But outside of this box, there doesn’t appear to be an easy way to get an ecosystem of 3rd party GenStages to work together.

A via(flow, producer_consumer_stage) function would go a long way I think. At least for linear flows. Fanout/fanin would still need to be addressed.

Is construction of arbitrary GenStage flow graphs something Flow is wanting to support?

Well that sounds like you should make or PR it! ^.^

I’m sort of thinking along those lines. However, I’m still an Elixir noob. So if the Elixir team is going to incorporate this into Flow for me, I’ll focus on useful GenStages and stay out of the framework core for now. If the Flow maintainers don’t think this is a fit for Flow, then I won’t go to the effort of trying to come up with a PR.

But yea…I’d like something like this. And I think that others would too. I see things like Raxx, StructureIO, and possibly others begging to participate in a well thought out streaming ecosystem.

Let’s see what the feedback is like. That’ll determine next steps.

I can be brutal but I would say that you don’t find anything more mature in any language than Java Reactive Streams implementations http://www.reactive-streams.org/
like RxJava2, Akka Streams … and what is great that RxJava2 can talk to Akka Streams as they both implements reactive streams.

1 Like

I agree with that. I’ve been on the JVM for a long time. But for my next project, the JVM is going to be too heavyweight. So I’m looking at BEAM. OTP and Erlang inspired so much within Scala and Akka that I’m hoping to feel at home here. So far, so good, and the community is amazing.

Elixir has been inspired by the reactive-streams processing model. GenStages seem to be a decent analog to RS Publisher/Subscriber. What Elixir is missing are the higher-level toolkits akin to RxJava2, Akka Streams, etc. Flow exists but isn’t as mature as Akka Streams.

The question is how to mature reactive streams within the Elixir community? Do we attempt to mature Flow? Have a few companies/projects roll their own abstractions on top of GenStage? Anything would be better than nothing. I’m just trying to decide where to focus my energies.

On the JVM, a leading web framework has been leveraging Akka Streams as its base processing architecture for a while and has recently transitioned to Akka HTTP for request handling. Whether you pick Akka Streams or a different reactive-streams compliant library you end up with a solid processing model and interoperability between libs built on top of the RS SPI. Elixir could have that too.

4 Likes