On Wed, Jul 30, 2014 at 9:03 AM, Evgeniy Ostapenko <[email protected]> wrote:
> > > среда, 30 июля 2014 г., 3:25:00 UTC+4 пользователь √ написал: >> >> Hi Evgeniy, >> >> >> On Tue, Jul 29, 2014 at 4:38 PM, Evgeniy Ostapenko <[email protected]> >> wrote: >> >>> Now akka-streams seems to be oriented on working with finite streams, >>> because: >>> 1) Any exception inside transformer kills all stream. >>> >> >> This is not an issue, if you want to represent processing errors you >> should make them explicit: use Try[T] instead of T for you element types. >> > > Of course, but it will produce a lot of boilerplate (instead .map(_.param) > you will write .map(_.map(_.param)) - for all transformers). > If your domain includes exceptions, having them visible is the least that should be done. onError is reserved for abnormal termination of flow, not for validation. > It is same as saying: "Library has no such behavior, but you can write it > by himself". > Absent behavior with help of which you can remove boilerplate is issue. > So what would you propose? > > 2) In case of finite stream you can get result value and operate with it. >>> In case of infinite you cant doing anything with data without custom >>> decorator. >>> >> >> Could you elaborate? >> > Without decorator you can not take last element of infinite stream for > example. > Aside from "last element of infinite stream" not making sense since you need to make it finite to use words like "last"—you can return the last element before completion easily: .fold(Option.empty[T])((last, current) => Some(current)) > With decorator it would be like: > > class FlowDecorator[T](flow: Flow[T], initial: Option[T] = None)(implicit > materializer: FlowMaterializer) extends Flow[T] with Builder[T] { > private val last = new AtomicReference(initial) > private val producer = flow.map { e => last.set(e); e > }.toProducer(materializer) > > def apply() = last.get() > > override def toFuture(..) = > last.get().map(Future.successful).getOrElse(Flow(producer).toFuture(materializer)) > > override def map[U](f: T => U) = FlowDecorator(Flow(producer).map(f), > last.get().map(f)) > ... a lot of boilerplate for all transformers > } > > Thank you for answer. > >> -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Cheers, √ -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
