Interface TypePreservingFanIn
-
- All Known Implementing Classes:
Concat,Interleave,Merge,MergePrioritized,MergeSequence
public interface TypePreservingFanInMarker trait for fan-in graph stages whose output element type is the same as their input element type (i.e.,T => T).Built-in stages with this trait:
scaladsl.Merge,scaladsl.Concat,scaladsl.Interleave,scaladsl.MergePrioritized,scaladsl.OrElse, andscaladsl.MergeSequence.Note: some of these stages (Concat, Interleave, MergeSequence) have factory methods that wrap the stage via
withDetachedInputs, which loses this trait. In those cases,Source.combineroutes through the fan-in graph instead of bypassing—functionally correct, just slightly less optimal. The bypass optimization fires for stages whose factory methods return the raw class (e.g.,Merge,MergePrioritized).This trait is used by
scaladsl.Source.combine(and its Java API counterpart) to safely optimize the single-source case. When only one source is provided, the fan-in 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 likeMergeLatest(whereT => List[T]) orZipWithN(whereA => O).This design uses a "safe default": strategies '''without''' this trait will always be routed through the fan-in graph, even for a single source. This ensures correct behavior for unknown or third-party fan-in strategies that may transform the element type.
- Since:
- 1.5.0