[akka-user] Re: [Akka-stream] How to do flow shortcut

2015-09-02 Thread Rafał Krzewski
There's an issue on file for doing the filter & nonFilter in a single graph 
element: https://github.com/akka/akka/issues/17038
Meanwhile, you can a use less powerful variant using FlexiRoute: 
https://github.com/rkrzewski/akka-cluster-etcd/blob/master/etcd-client/src/main/scala/pl/caltha/akka/streams/EitherJunction.scala
Usage 
example: 
https://github.com/rkrzewski/akka-cluster-etcd/blob/master/etcd-client/src/main/scala/pl/caltha/akka/http/HttpRedirects.scala#L59
The project binares are not published anywhere, so feel free to copy-paste 
the code if you find it useful :)

Cheers,
Rafał

W dniu wtorek, 1 września 2015 20:54:48 UTC+2 użytkownik Lance Arlaus 
napisał:
>
> Leon-
>
> There's a couple of ways to solve this, but one simple solution is to use 
> a combination of Broadcast, filter, and Merge.
> 1. Broadcast the elements to two branches and filter each branch. Assuming 
> the respective filters are mutually exclusive, each element will only go 
> down a single branch.
> 2. Place the FlowB on the desired branch to receive extra processing.
> 3. Place the Merge prior to FlowC to join the two branches
>
> The result will look something like this:
> FlowA ~> bcast ~> nonfilter ~> FlowB ~> merge
>   ~> filter   ~> merge
>  ~> merge.out 
> ~> FlowC
>
> However, an even simpler solution, depending on your requirements, is to 
> just implement FlowB as a map stage that passes through on false match. 
> Something like:
>
> val flowB = Flow[T].map(e => cond(e) match {
>   case true => // do something
>   case false => e
> }
>
> You can then just chain via() calls (flowA.via(flowB).via(flowC)). A wee 
> bit simpler if it fits your case.
>
> Lance
>
>

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Using Akka http for large uploads not uploading entire file

2015-09-02 Thread Konrad Malawski
I see, thanks for double-checking on your end then!

I hope you're enjoying Akka Http :-)
Happy hakking!

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 2 September 2015 at 16:08:55, Charlie Evans (charlesdevan...@gmail.com) 
wrote:

Hi Konrad,

Thanks so much in getting back to me, I'm starting to think it may be an issue 
outside of akka. We have Node proxying the request over to the akka server and 
it might be something funky going on there. 

Sorry to have wasted your time.

Charlie

On Wednesday, September 2, 2015 at 3:02:28 PM UTC+1, Konrad Malawski wrote:
Actually, follow up question – since the snippet seems incomplete.
How are you running the mapAsync?

In the snippet you posted there is no materialization of the 
formdata.parts.mapAsync(1)
part. You should have some run() at the end of the stream, otherwise it does 
nothing.

For example you could runWith(Sink.ignore).map(_ => "Upload completed!")

Would you mind posting the complete snippet so we can verify it?

// I quickly did so but was not able to reproduce the problem described so far.

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 2 September 2015 at 14:46:11, Charlie Evans (charles...@gmail.com) wrote:

Hi all,

I'm trying to use Akka http for large files (300MB is what I'm currently 
testing) coming in as multi-part form data. The file gets written straight to 
disk. The file ends up being a few MB short of complete and the upload hangs 
indefinitely. I had a look at the files and the top and bottom match so it must 
have missed a chunk somewhere in between? How would I prevent this?

The code of interest is below:

val file = new File(localPath)

val sink = SynchronousFileSink(file)


entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>

val fileNamesFuture = formdata.parts.mapAsync(1) { p =>

                    if (p.filename.isDefined) {

                      println(s"Got part. name: ${p.name} filename: 
${p.filename}")

                      p.entity.dataBytes.runWith(sink).map { bytesWritten => 

                        """{"result":"Finished upload"}""".parseJson

}

}



Thanks



--
>> 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 akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Using CircuitBreaker within outbound Http stream Flow

2015-09-02 Thread Konrad Malawski
Hi Chris,
that's definitely in the plans – here's the ticket for 
it: https://github.com/akka/akka/issues/15307
You can build elements like this currently, however you're right that it 
could be provided as an out of the box thing and certainly be pretty useful.

Thanks for the feedback! If you have specific requirements you'd like to 
voice please put them into the issue above so we don't lose track of them, 
thanks!

-- Konrad

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka Mobile

2015-09-02 Thread Konrad Malawski
Hi Joseph,
we're not actively working on supporting Akka on DVM or ART (Android runtimes).
Akka is aimed primarily at backend settings, not as much for mobile.

Having that said, I know Akka 2.3.x "just worked" on Android a while ago, 
because it looks "enough like Java"
from the feature set's perspective.

Akka 2.4.x will require JDK8, so you won't be able to use it on Android unless 
some trickery or Google decides to support JDK8.

Hope this helps, happy hakking!

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 29 August 2015 at 17:02:00, Joseph Mansigian (joseph.c.mansig...@gmail.com) 
wrote:

Is there a JVM or Dalvik virtual machine that is a sufficient base to run Akka 
on android mobile devices?  If none is available now does anyone know of any 
development efforts in this direction?
--
>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Using CircuitBreaker within outbound Http stream Flow

2015-09-02 Thread Chris Baxter
Are there any additional plans to provide enhancements to the 
CircuitBreaker to allow it to more tightly integrate into outbound Http 
stream Flows?  Right now we can make use of the current CircuitBreaker with 
a mapAsync step as the current breaker supports a Future based 
withCircuitBreaker method and this works fine.  It seems however that 
something like this (protecting external http calls) could be built right 
into the host connection pool flows as an optional input to allow the 
caller to supply a breaker to use for that pool flow.  Are there any plans 
to do something like this, and if not, might I suggest it as a new feature 
to include in some upcoming release because I think it would be very 
useful.  Perhaps if the breaker is open, then the Try that flows downstream 
after the http request is executed will always be failed until the breaker 
closes again.  I think something like that fits the model that exists 
already pretty well.

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Using Akka http for large uploads not uploading entire file

2015-09-02 Thread Konrad Malawski
Actually, follow up question – since the snippet seems incomplete.
How are you running the mapAsync?

In the snippet you posted there is no materialization of the 
formdata.parts.mapAsync(1)
part. You should have some run() at the end of the stream, otherwise it does 
nothing.

For example you could runWith(Sink.ignore).map(_ => "Upload completed!")

Would you mind posting the complete snippet so we can verify it?

// I quickly did so but was not able to reproduce the problem described so far.

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 2 September 2015 at 14:46:11, Charlie Evans (charlesdevan...@gmail.com) 
wrote:

Hi all,

I'm trying to use Akka http for large files (300MB is what I'm currently 
testing) coming in as multi-part form data. The file gets written straight to 
disk. The file ends up being a few MB short of complete and the upload hangs 
indefinitely. I had a look at the files and the top and bottom match so it must 
have missed a chunk somewhere in between? How would I prevent this?

The code of interest is below:

val file = new File(localPath)

val sink = SynchronousFileSink(file)



entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>

val fileNamesFuture = formdata.parts.mapAsync(1) { p =>

                    if (p.filename.isDefined) {

                      println(s"Got part. name: ${p.name} filename: 
${p.filename}")

                      p.entity.dataBytes.runWith(sink).map { bytesWritten => 

                        """{"result":"Finished upload"}""".parseJson

}

}



Thanks



--
>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Using Akka http for large uploads not uploading entire file

2015-09-02 Thread Charlie Evans
Hi Konrad,

Thanks so much in getting back to me, I'm starting to think it may be an 
issue outside of akka. We have Node proxying the request over to the akka 
server and it might be something funky going on there. 

Sorry to have wasted your time.

Charlie

On Wednesday, September 2, 2015 at 3:02:28 PM UTC+1, Konrad Malawski wrote:
>
> Actually, follow up question – since the snippet seems incomplete.
> How are you running the mapAsync?
>
> In the snippet you posted there is no materialization of the 
> formdata.parts.mapAsync(1)
> part. You should have some run() at the end of the stream, otherwise it 
> does nothing.
>
> For example you could runWith(Sink.ignore).map(_ => "Upload completed!")
>
> Would you mind posting the complete snippet so we can verify it?
>
> // I quickly did so but was not able to reproduce the problem described so 
> far.
>
> -- 
> Cheers,
> Konrad `ktoso` Malawski
> Akka  @ Typesafe 
>
> On 2 September 2015 at 14:46:11, Charlie Evans (charles...@gmail.com 
> ) wrote:
>
> Hi all, 
>
> I'm trying to use Akka http for large files (300MB is what I'm currently 
> testing) coming in as multi-part form data. The file gets written straight 
> to disk. The file ends up being a few MB short of complete and the upload 
> hangs indefinitely. I had a look at the files and the top and bottom match 
> so it must have missed a chunk somewhere in between? How would I prevent 
> this?
>
> The code of interest is below:
>
> val file = new File(localPath)
>
> val sink = SynchronousFileSink(file)
>
>
> entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>
>
> val fileNamesFuture = formdata.parts.mapAsync(1) { p =>
>
> if (p.filename.isDefined) {
>
>   println(s"Got part. name: ${p.name} filename: ${p.
> filename}")
>
>   p.entity.dataBytes.runWith(sink).map { bytesWritten 
> => 
>
> """{"result":"Finished upload"}""".parseJson
>
> }
>
> }
>
>
> Thanks
>
>
> --
> >> 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 akka-user+...@googlegroups.com .
> To post to this group, send email to akka...@googlegroups.com 
> .
> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [Akka-stream] How to do flow shortcut

2015-09-02 Thread Leon Ma
Thanks a lot!
It's really helpful!

Leon


在 2015年9月1日星期二 UTC-7上午11:54:48,Lance Arlaus写道:
>
> Leon-
>
> There's a couple of ways to solve this, but one simple solution is to use 
> a combination of Broadcast, filter, and Merge.
> 1. Broadcast the elements to two branches and filter each branch. Assuming 
> the respective filters are mutually exclusive, each element will only go 
> down a single branch.
> 2. Place the FlowB on the desired branch to receive extra processing.
> 3. Place the Merge prior to FlowC to join the two branches
>
> The result will look something like this:
> FlowA ~> bcast ~> nonfilter ~> FlowB ~> merge
>   ~> filter   ~> merge
>  ~> merge.out 
> ~> FlowC
>
> However, an even simpler solution, depending on your requirements, is to 
> just implement FlowB as a map stage that passes through on false match. 
> Something like:
>
> val flowB = Flow[T].map(e => cond(e) match {
>   case true => // do something
>   case false => e
> }
>
> You can then just chain via() calls (flowA.via(flowB).via(flowC)). A wee 
> bit simpler if it fits your case.
>
> Lance
>
>

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Using Akka http for large uploads not uploading entire file

2015-09-02 Thread Konrad Malawski
Hi Charlie,
I'll try to reproduce the problem you described - it definitely should not 
happen, so we may be looking at a bug here.
Is there anything else other than the snippet (thanks for pasting it!) that 
might be related to the issue you're seeing?

Does the same happen if you replicate the posted data with curl (I'll use that 
now locally to simulate the same situation,
and would like to confirm it fails for you with curl as well)?

// And a sanity check - you are using Akka Streams 1.0 and Akka 2.1.12 (if not 
please upgrade)?

-- 
Cheers,
Konrad `ktoso` Malawski
Akka @ Typesafe

On 2 September 2015 at 14:46:11, Charlie Evans (charlesdevan...@gmail.com) 
wrote:

Hi all,

I'm trying to use Akka http for large files (300MB is what I'm currently 
testing) coming in as multi-part form data. The file gets written straight to 
disk. The file ends up being a few MB short of complete and the upload hangs 
indefinitely. I had a look at the files and the top and bottom match so it must 
have missed a chunk somewhere in between? How would I prevent this?

The code of interest is below:

val file = new File(localPath)

val sink = SynchronousFileSink(file)



entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>

val fileNamesFuture = formdata.parts.mapAsync(1) { p =>

                    if (p.filename.isDefined) {

                      println(s"Got part. name: ${p.name} filename: 
${p.filename}")

                      p.entity.dataBytes.runWith(sink).map { bytesWritten => 

                        """{"result":"Finished upload"}""".parseJson

}

}



Thanks



--
>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Using Akka http for large uploads not uploading entire file

2015-09-02 Thread Charlie Evans
Hi all,

I'm trying to use Akka http for large files (300MB is what I'm currently 
testing) coming in as multi-part form data. The file gets written straight 
to disk. The file ends up being a few MB short of complete and the upload 
hangs indefinitely. I had a look at the files and the top and bottom match 
so it must have missed a chunk somewhere in between? How would I prevent 
this?

The code of interest is below:

val file = new File(localPath)

val sink = SynchronousFileSink(file)


entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>

val fileNamesFuture = formdata.parts.mapAsync(1) { p =>

if (p.filename.isDefined) {

  println(s"Got part. name: ${p.name} filename: ${p.
filename}")

  p.entity.dataBytes.runWith(sink).map { bytesWritten 
=> 

"""{"result":"Finished upload"}""".parseJson

}

}


Thanks


-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.