Interface TypePreservingFanOut

All Known Implementing Classes:
Balance, Broadcast

public interface TypePreservingFanOut
Marker 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.Broadcast and scaladsl.Balance.

Note: scaladsl.Partition is intentionally NOT marked with this trait despite having T => T types, because its partitioner function provides user-specified routing semantics that would be lost if the stage were bypassed.

This trait is used by 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 via asInstanceOf would be unsafe for type-transforming strategies where T differs from U.

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