Hi Javier,


Hi,
>
> Playing around with the receive pipeline pattern
> <http://doc.akka.io/docs/akka/2.4.2/contrib/receive-pipeline.html> I put
> together the following example to do some sort of user credentials
> validation composition with an actor.
>
> Problem is that only with the synchronous blocking semantics I managed to
> get the code compiling and running. With the other two alternatives for
> asynchronous nonblocking composition I get compilation error (about not
> having the proper response type por the pipeline).
>
So my questions are: Am I missing something here? Does the receive pipeline
> pattern only play well with blocking synchronous compositions?
>

Well, I wouldn't conflate blocking with synchronous, they are not the same.
The receive pipeline pattern is, well, a pipeline of Receive blocks.
Receive blocks are synchronous as the asynchrony comes from the surrounding
Actors mailbox, not its internals


> Is there a way to have non-blocking asynchronous compositions with
> pipelines?
>

This is only to support flexible composition of Actor behaviors. Since an
Actor's behavior function is always synchronous any asynchronous processing
must be expressed as messages sent to the actor or other actors.

-Endre




>
> /**
>   * Pipeline pattern for client validation, intercepts Query messages between 
> actors to authorize requests.
>   */
> trait ClientValidationPipeline {
>   this: ReceivePipeline =>
>
>     def clientService: ActorRef
>
>     pipelineInner {
>       case query @ Query(ctx: QueryContext, body: QueryBody) =>
>
>
>         implicit val timeout = Timeout(200 milliseconds)
>
>
>         */** synchronous *await impl */
>
>         val clientValidationFuture = clientService ? 
> CheckClient(ctx.clientName, ctx.clientPasswd)
>         val clientValidation = Await.result(clientValidationFuture, 
> timeout.duration)
>         clientValidation match {
>           case validClient: ValidClient =>
>             body.principal = Some(validClient.client)
>             Inner(query)
>           case invalidClient: InvalidClient =>
>             sender() ! invalidClient
>             HandledCompletely
>         }
>
>         /** a*synchronous *callback impl */
>
>         (clientService ? CheckClient(ctx.clientName, 
> ctx.clientPasswd)).onComplete {
>           case Success(validClient: ValidClient) =>
>             body.principal = Some(validClient.client)
>             Inner(query)
>           case Success(invalidClient: InvalidClient) =>
>             sender() ! invalidClient
>             HandledCompletely
>           case Failure(status) =>
>             sender() ! status
>             HandledCompletely
>         }
>
>         /** a*synchronous *for comprehension impl */
>
>         val clientValidationFuture = clientService ? 
> CheckClient(ctx.clientName, ctx.clientPasswd)
>         for {
>           clientValidation <- clientValidationFuture
>         } yield {
>           clientValidation match {
>             case validClient: ValidClient =>
>               body.principal = Some(validClient.client)
>               Inner(query)
>             case invalidClient: InvalidClient =>
>               sender() ! invalidClient
>               HandledCompletely
>           }
>         }
>
>       case x =>
>         Inner(x)
>     }
> }
>
>
> Thanks,
> Javier
>
> --
> >>>>>>>>>> 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.
>



-- 
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

-- 
>>>>>>>>>>      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.

Reply via email to