There are a lot of ways you *could* slice this, but the most
straightforward is the simple Actor-per-request model.  Actors are fairly
lightweight, so it's sometimes worthwhile to just stand one up for a
complex request like this.  So you instantiate an Actor in charge of
managing the authorization process; that sends out the requests to the
various SecurityProvider workers, and collates the requests.  If any come
back negative, it immediately responds negative; if they all return
positive, it responds positive.

In practice, I would typically expect to have a Session Actor that is
managing the interactions for a particular User; that could often handle
this responsibility.

On Thu, Jul 21, 2016 at 3:33 AM, Nader Aeinehchi <na...@aeinehchi.com>
wrote:

> I have a classic question: how to fork some work and then join the results.
>
> Let me explain the problem:
>
> There is a security manager that asks several security providers (e.g.
> Active Directory, Tivoli, Mainframe) if a given call is authorized.  If all
> the security providers say "yes", the call is authorized. But if at least
> one of the security providers says "no", the called is denied.
>
> In the context of parallelism, a call to each of security providers is
> delegated to a worker (securityProvider).  Workers need to work in parallel.
>
> If one of the workers says "no", there is no point waiting for the answer
> from other workers. Then security mangager should immediately answer "no".
>
> Note that the application is multi-user.  Therefore, each fork-join should
> be related to some correlation id, e.g. a requestId.
>
> I would like to know how the above problem can be solved using actors.
> Let me assert that my motivations with actors is the fault-tolerance
> ability that actor model offers.
>
> In advance thank you very much.
>
> Nader
>
> <code>
>
> type AccessRequest = Tuple2[RequestId, Payload]
>
>   def isAuthorized(accessRequest: AccessRequest): AccessDecision = {
>
>     var decision: AccessDecision = No
>
>     val loop = new Breaks
>     loop.breakable {
>       for (securityProvider <- securityProviders.values) {
>
>         val newDecision = securityProvider.check(accessRequest)
>
>         if (newDecision == No)) {
>           loop.break
>         }
>
>         decision = newDecision
>
>       }
>     }
>     decision
>   }
> </code>
>
>
> --
> >>>>>>>>>> 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 https://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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to