He-Pin opened a new issue, #1189:
URL: https://github.com/apache/incubator-pekko/issues/1189

   Motivation:
   In production, I was try to using Reactor-core, but which cause in 
production outage. 
   When Using Pekko-Stream with `unfold`, which is a little heavy with the 
`Optional` and `Pair` in Java dsl.
   
   ```java
           final Source<String, NotUsed> idFlux = 
Source.unfold(NotUsed.notUsed(), state -> {
               try {
                   //这里故意使用同步take,因为flux 只在这个类中用到了。
                   return Optional.of(Pair.create(NotUsed.notUsed(), 
queue.take()));
               } catch (Throwable e) {
                   errLogger.error("failed to take connectId from queue", e);
                   return Optional.of(Pair.create(NotUsed.notUsed(), ""));
               }
           });
   ```
   
   I think we can add something like `generate` for infinity stream and 
`iterate` with a predicate.
   ```scala
   generate[T](f: () => T): Source[T, NotUsed]
   
   iterate[T](seed:T, hasNext: T => Boolean, nextGenerator: T => T): Source[T, 
NotUsed]
   iterate[T](seed:T,nextGenerator: T => T) : Source[T, NotUsed]
   ```
   
   This will be very useful in Javadsl.


-- 
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]

Reply via email to