Hi Cole,
On Fri, Jan 23, 2015 at 11:11 PM, <[email protected]> wrote: > Hey Endre, > > Thanks for the response but I don't quite understand how to implement what > you're suggesting. > I didn't suggest anything, I just gave an example how stream completion and cancellation work, using Fold as the example operation. > I did find the Fold class but it has no Promise/Future in it. > Please read this section of the documentation if you haven't done it before: http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-flows-and-basics.html "fter running (materializing) the RunnableFlow we get a special container object, the MaterializedMap. Both sources and sinks are able to put specific objects into this map. Whether they put something in or not is implementation dependent. For example a FoldSink will make a Future available in this map which will represent the result of the folding process over the stream. In general, a stream can expose multiple materialized values, but it is quite common to be interested in only the value of the Source or the Sink in the stream." > I also found the FoldSink class but the only way to get a future back from > that is to use the attach method and I've no idea how to get that into my > flow. Any example how to do this? > Sink.fold() is what you are after (in the Sink companion object). Again, the docs summarizes the most common sources and sinks here: http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-flows-and-basics.html#Defining_sources__sinks_and_flows > > Here's what I'm working with currently: > > val connection = StreamTcp().outgoingConnection(address) > val handler: Flow[ByteString, ByteString] = > Flow[ByteString].mapConcat(frameReconciler.reconcile) > > .map(decodeRequest).map(handleRequest).map(encodeResponse).map(createFrame) > connection.handleWith(handler) > > You will need to add an extra element in your flow that will complete the stream when you want it. You can look at this page: http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/stream-customize.html -Endre > Best regards, > Cole > > On Friday, January 23, 2015 at 8:55:32 AM UTC-8, drewhk wrote: >> >> Hi Cole, >> >> The connection disconnect event will be signalled as stream completion to >> the reading stream and cancellation to the writing stream. For example if >> you fold over the ouput stream of the TCP connection, on TCP closure >> (assuming normal close event) the fold element will emit the final result >> in its corresponding Future. >> >> -Endre >> >> On Fri, Jan 23, 2015 at 10:17 AM, <[email protected]> wrote: >> >>> Hey all, >>> >>> After making a StreamTcp().outgoingConnection(address) connection, how >>> can I watch the connection for disconnects so that I can establish a new >>> connection? I see a akka.io.Tcp$ConfirmedClosed$ and >>> a akka.actor.Terminated getting logged in dead letters after the server >>> restarts but no idea how I can get ahold of them or if there's a better way. >>> >>> Thanks in advance, >>> Cole >>> >>> -- >>> >>>>>>>>>> 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. >>> >> >> -- > >>>>>>>>>> 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. > -- >>>>>>>>>> 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.
