Interface TypePreservingFanOut
-
public interface TypePreservingFanOutMarker trait for fan-out graph stages whose output element type is the same as their input element type (i.e.,T => T).Examples include
scaladsl.Broadcastandscaladsl.Balance.Note:
scaladsl.Partitionis intentionally NOT marked with this trait despite havingT => Ttypes, because itspartitionerfunction provides user-specified routing semantics that would be lost if the stage were bypassed.This trait is used by
scaladsl.Sink.combine(and its Java API counterpart) to safely optimize the single-sink case. When only one sink is provided, the fan-out strategy can be bypassed with a direct pass-through if and only if the strategy is type-preserving (output type equals input type). Without this marker, a bypass viaasInstanceOfwould be unsafe for type-transforming strategies whereTdiffers fromU.This design uses a "safe default": strategies '''without''' this trait will always be routed through the fan-out graph, even for a single sink. This ensures correct behavior for unknown or third-party fan-out strategies that may transform the element type.
- Since:
- 1.5.0