He-Pin opened a new issue, #3131: URL: https://github.com/apache/pekko/issues/3131
### Motivation Currently, pekko provides `Sink.lazyInit` for lazily creating a sink based on the first element, and `Source.lazySource`/`Source.lazyFutureSource` for lazy source creation. However, there is no equivalent operator for `Flow` — the ability to lazily create a flow based on the first element that passes through it. This is useful when: - The flow's behavior depends on properties of the first element (e.g., detecting format/encoding from the first message) - Expensive resources should only be initialized when data actually starts flowing - The flow factory is asynchronous (e.g., needs to query a service before deciding how to process elements) ### Proposed Enhancement Add a `Flow.lazyInitAsync` operator that: 1. Accepts a factory function `(firstElement: T) => Future[Flow[T, U, M]]` 2. On the first element, invokes the factory asynchronously 3. Materializes the returned flow and feeds all elements (including the first) through it 4. Returns the materialized value of the lazily created flow ### References This operator was implemented in the Akka.NET project: https://github.com/akkadotnet/akka.net/issues/5476 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
