akka / akka-stream-contrib

Add-ons to Akka Stream
Other
172 stars 77 forks source link

Shared valve switch #186

Open harpocrates opened 3 years ago

harpocrates commented 3 years ago

Short description

Add a new shared valve, from which it would be possible to create any number of flows (with different types) all controlled by a shared switch.

Details

In Akka streams, there is a distinction between a shared and unique killswitch. A shared valve would be to a shared killswitch as a valve is to a unique killswitch. The API would lean into that analogy:

final class SharedValveSwitch private[stream] (val name: String) extends ValveSwitch {
  def flow[T]: Graph[FlowShape[T, T], SharedValveSwitch] = ...
}

object Valve {
  def shared(name: String): SharedValveSwitch = ...
  // ... and existing members
}
ennru commented 3 years ago

Yes, a more general variant of Valve may be useful.

Having that said, we haven't seen much demand for Valve and have no plans to promote it into the Akka Streams API.

That shouldn't stop you from proposing a solution to the shared valve support in this repo.