I am using Autowire to connect my client with the server. In defining the Api
trait, the interface method expects a Future to be return. Like so:
case class UserController(implicit ec: ExecutionContext) extends UserApi {
val routes: Route = {
get {
path("login") {
get(complete(HttpEntity(ContentTypes.`text/html(UTF-8)`,
LoginView.render)))
}
} ~ post {
path("user" / Segments) { s =>
entity(as[ByteString]) { b =>
complete {
BinaryServer.route[UserApi](this)(
autowire.Core.Request(s, Unpickle[Map[String,
ByteBuffer]].fromBytes(b.asByteBuffer)))
.map { b =>
val data = Array.ofDim[Byte](b.remaining())
b.get(data)
ByteString.fromArray(data)
}
.map(HttpResponse().withEntity(ContentTypes.`application/octet-stream`, _))
}
}
}
}
}
def login(email: String, password: String): Future[Boolean] = {
Future.successful(false) // Api method expects a future and would require
using the ask pattern to process the command
}
The problem I have with this approach is that I would need to using the Ask
pattern to process the Api method. Since the http server is an Akka Stream
source, I was wondering if it would be possible to handle all the routing
inside an actor instead. This is because I have a process manager actor that
already handles the business logic for all the commands. I would like the
request to be complete by the process manager actor rather than spawning a
temporary ask actor for each request, waiting for a response from the pm actor.
Everything the ask actor does is already handled by the process manager such
as the timeout and waiting for a response for the command. It also introduces
a potential bottleneck; although, I do notice its kind of exaggerated by the
community. Does anyone have any suggestions? It would ideally work with
Autowire.
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.