Attributes on fromGraph(stage) should be treated as on stage #22911, #22523

This commit is contained in:
Johan Andrén 2017-11-23 10:26:00 +01:00 committed by GitHub
parent cb6a660cf4
commit 1751292580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 741 additions and 101 deletions

View file

@ -7,6 +7,11 @@ import akka.stream.impl.{ GraphStageTag, IslandTag, TraversalBuilder }
import scala.annotation.unchecked.uncheckedVariance
/**
* Not intended to be directly extended by user classes
*
* @see [[akka.stream.stage.GraphStage]]
*/
trait Graph[+S <: Shape, +M] {
/**
* Type-level accessor for the shape parameter of this graph.
@ -32,5 +37,33 @@ trait Graph[+S <: Shape, +M] {
*/
def async: Graph[S, M] = addAttributes(Attributes.asyncBoundary)
/**
* Put an asynchronous boundary around this `Graph`
*
* @param dispatcher Run the graph on this dispatcher
*/
def async(dispatcher: String) =
addAttributes(
Attributes.asyncBoundary and ActorAttributes.dispatcher(dispatcher)
)
/**
* Put an asynchronous boundary around this `Graph`
*
* @param dispatcher Run the graph on this dispatcher
* @param inputBufferSize Set the input buffer to this size for the graph
*/
def async(dispatcher: String, inputBufferSize: Int) =
addAttributes(
Attributes.asyncBoundary and ActorAttributes.dispatcher(dispatcher)
and Attributes.inputBuffer(inputBufferSize, inputBufferSize)
)
/**
* Add the given attributes to this [[Graph]]. If the specific attribute was already present
* on this graph this means the added attribute will be more specific than the existing one.
* If this Source is a composite of multiple graphs, new attributes on the composite will be
* less specific than attributes set directly on the individual graphs of the composite.
*/
def addAttributes(attr: Attributes): Graph[S, M] = withAttributes(traversalBuilder.attributes and attr)
}