Re: [akka-user] How to change this game loop to message-driven actors?

2016-10-07 Thread Steve Winfield
Am Freitag, 7. Oktober 2016 22:06:26 UTC+2 schrieb Justin du coeur: > > When the player wants to move, the Player Actor sends an "I'd like to move > to X" message to the Space Actor responsible for that location, and the > Space returns either a "yes, go ahead, you now own that position" or

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Akka Team
You can still pattern match on the type, like so: case result: SomeType => complete(result) -- Johan Akka Team On Fri, Oct 7, 2016 at 4:30 PM, Richard Rodseth wrote: > You're right the types are different, and PimpedResult is not a case class > so pattern matching

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Richard Rodseth
You're right the types are different, and PimpedResult is not a case class so pattern matching doesn't work out. I think I must abandon this approach and mimic Heiko's. Was hoping to ease the port from Spray but this BinTray contribution is too complex. Sent from my phone - will be brief > On

Re: [akka-user] How to change this game loop to message-driven actors?

2016-10-07 Thread Justin du coeur
So this: On Fri, Oct 7, 2016 at 11:28 AM, Steve Winfield < mail.stevewinfi...@gmail.com> wrote: > I want everything to be synchronized > is something you basically have to give up -- global synchronization is fundamentally contradictory to the Actors view of the world. Mind, though, it doesn't

[akka-user] Re: onUpstreamFinish not getting called

2016-10-07 Thread Eric Swenson
I found my (stupid) problem. I had used: val encryptedOut = Sink.head[ByteString] instead of: val encryptedOut: Sink[ByteString, Future[ByteString]] = Sink.fold[ByteString, ByteString](ByteString())(_ ++ _) Consequently, only the first chunk of the stream was being kept. I’m not entirely

[akka-user] Re: onUpstreamFinish not getting called

2016-10-07 Thread Eric Swenson
I wrote a simple test case using a graph rather than using src.runForEach. "CipherStage in graph" should "work" in { val clearText = "0123456789abcdef" val clearSource = Source.single(ByteString(clearText)) val encryptedOut = Sink.head[ByteString] val encodedKey: String =

Re: [akka-user] Re: [akka-stream] How to implement Spark's cogroup/join operation

2016-10-07 Thread Akka Team
If you groupBy with an upper bound of substreams at Int.MaxValue you can at some point have more than 256 substreams, which is what you limit mergeSubstreamsWithParallelism with, this means that it will backpressure indefinitely (as none of the substreams will complete until upstream completes and

Re: [akka-user] Re: onUpstreamFinish not getting called

2016-10-07 Thread Viktor Klang
Can you post a minimal reproducer? On Fri, Oct 7, 2016 at 9:02 PM, Eric Swenson wrote: > I wrote a simple test for my CipherStage and it appears to work fine: > > "CipherStage" should "work" in { > val clearText = "0123456789abcdef" > val clearSource =

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Akka Team
To be fair you are doing something pretty complex with them, but I agree, the magnet pattern definitely can be humbling. Did the code that worked just fine earlier really deal with the exact same type (tuple with statuscode and APIError)? -- Johan Akka Team On Fri, Oct 7, 2016 at 1:30 PM,

Re: [akka-user] Re: Organizing Route Directives

2016-10-07 Thread Akka Team
There are no requirements from Akka HTTPs side limiting how you create your Route instances at all (Please let us know if the documentation says so anywhere). Additionally all built in directives are available statically. So for extra clarity, you can (and likely should) do: import static

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Richard Rodseth
Heiko has a different approach here https://github.com/hseeberger/reactive-flows/blob/master/src/main/scala/de/heikoseeberger/reactiveflows/Api.scala onSuccess(flowFacade ? addFlow) { case bc: BadCommand => complete(BadRequest -> bc) case fe: FlowExists => complete(Conflict -> fe) case fa:

Re: [akka-user] Re: Organizing Route Directives

2016-10-07 Thread Richard Rodseth
Isn't it true that your routes need to be in a trait t be able to make use of the Routing Testkit? On Fri, Oct 7, 2016 at 12:08 PM, wrote: > Thank you for the response Johan but I'm not sure that really answers my > question but perhaps I can ask some other questions

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Richard Rodseth
That's the trouble. Depending on whether the actor calls withStatusCode, it could be a Result or a PimpedResult. Both can be marshalled. In the Spray application we completed the request inside a per-request actor. That is no longer possible, hence using Ask. On Fri, Oct 7, 2016 at 11:18 AM,

Re: [akka-user] Re: Organizing Route Directives

2016-10-07 Thread Akka Team
In general, don't try to mimic the way it is done in Akka HTTP itself unless you actually have the same requirements. (To support both mixin and static imports, dealing with both a Scala and Java API etc) Modularising the routes is not different from modularising other kinds of codebases, you

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Viktor Klang
If you know the type of the expected response from the ask, then you use `mapTo` on the returned Future to coerce it. On Fri, Oct 7, 2016 at 5:55 PM, Richard Rodseth wrote: > Continuing my struggles to port something we did with Spray, using > > // See

Re: [akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Akka Team
Hi Richard, You can combine ask with mapTo to cast it to the right type (or fail the future if it does not have that type), see the docs here: http://doc.akka.io/docs/akka/2.4/scala/futures.html#use-with-actors -- Johan Akka Team On Fri, Oct 7, 2016 at 10:55 AM, Richard Rodseth

Re: [akka-user] Sending response back to sender from remote routee

2016-10-07 Thread Viktor Klang
happy hakking! On Fri, Oct 7, 2016 at 4:50 PM, Jegan wrote: > Thanks friends. I tried the options suggested by both of you. Both are > working great. > > On Friday, October 7, 2016 at 7:23:05 AM UTC-7, √ wrote: >> >> pipeTo >> >> On Fri, Oct 7, 2016 at 4:17 PM, Justin du

[akka-user] Akka HTTP complete Future obtained from ask, with custom marshalling

2016-10-07 Thread Richard Rodseth
Continuing my struggles to port something we did with Spray, using // See https://bitbucket.org/binarycamp/spray-contrib/src I have resolved my implicit conversion errors to the point where I can execute the following (Result[T] is an alias for Either[APIError, T]): val successResult:

Re: [akka-user] Akka streams in web application

2016-10-07 Thread Akka Team
As you have a finite stream of customer ids the stream will complete after all elements has been processed. If your actual business problem does in fact look like this though, it may make sense to not involve Akka Streams at all and just use the regular Scala collection API to achieve the same.

[akka-user] Re: Organizing Route Directives

2016-10-07 Thread Rafał Krzewski
I'm not familiar with Java API but my impression is that AllDirectives is a device for bringing all pre-defined directives in scope of your Route producing functions. Routes themselves are values and you can combine them to produce more complex routes. For example you could have several classes

Re: [akka-user] XMPP API development in Scala

2016-10-07 Thread Akka Team
A quick google search doesn't turn up any Scala specific libraries so you are probably best off using one of the Java libraries listed on the XMPP homepage (http://xmpp.org/software/libraries.html) to interact with XMPP from the JVM. If you decide to use Akka Streams as the abstraction (which

Re: [akka-user] Sending response back to sender from remote routee

2016-10-07 Thread Jegan
Thanks friends. I tried the options suggested by both of you. Both are working great. On Friday, October 7, 2016 at 7:23:05 AM UTC-7, √ wrote: > > pipeTo > > On Fri, Oct 7, 2016 at 4:17 PM, Justin du coeur > wrote: > >> This is kind of the number-one FAQ for Akka: you must

Re: [akka-user] Sending response back to sender from remote routee

2016-10-07 Thread Viktor Klang
pipeTo On Fri, Oct 7, 2016 at 4:17 PM, Justin du coeur wrote: > This is kind of the number-one FAQ for Akka: you must never, ever use > "sender" in the results of a Future. "sender" is only set *synchronously*, > while the receive method is running -- after that (in your

Re: [akka-user] Sending response back to sender from remote routee

2016-10-07 Thread Justin du coeur
This is kind of the number-one FAQ for Akka: you must never, ever use "sender" in the results of a Future. "sender" is only set *synchronously*, while the receive method is running -- after that (in your Future's onComplete), it's probably not set to anything, and *might* be set to something

[akka-user] How to handle web socket message to upload base64 encoded string of 10mb file

2016-10-07 Thread Narayan Kumar
Hi everyone, Actually i was trying to handle a Web Socket message for base64 encoded string of 10mb file.but unable to handle it. is there any way to handle large message please suggest ? Here is the code: def mediaUploadHandler: Flow[Message, Message, _] = { val (accountSource,

[akka-user] Sending response back to sender from remote routee

2016-10-07 Thread Jegan
Hello Friends, I need your help in figuring out what is going wrong here. I have posted this question in SO too. I am using Akka Cluster (version 2.4.10) with few nodes designated for "front-end" role and few others as "workers". The workers are on remote machines. The incoming work is