Oh, jeez. Yeah, that's entirely hideous.

You know there's a cure for this disease. It's called Scala. However, side 
effects may include crawling compiles, awkward builds, and speaking 
optionally in futures :-)

Seriously, if I'd known you were approaching this from Java, I'd advised 
against using Streams.
You need the right language features and a good DSL to make this stuff 
accessible and maintainable (which the Akka guys have done a great job with 
so far, IMHO).

You're right on about the Future contained in an Agent. That's the key 
interface between the two components (access and request). Like any 
software, as long as you get the interfaces right, the implementation 
should be swappable.

Good luck!

On Tuesday, August 11, 2015 at 10:32:57 AM UTC-4, David Pinn wrote:
>
> Lance, I've been translating your autoRefresh method into Java. 
>
> Kill. Me. Now.
>
> You wrote this:
>
> val auto = Sink(
>       Flow[(RefreshToken, Promise[AccessToken])],
>       Merge[(RefreshToken, Promise[AccessToken])](2), 
>       request, 
>       Unzip[RefreshToken, Promise[AccessToken]],
>       Zip[Future[RefreshResponse], Promise[AccessToken]],
>       Broadcast[(RefreshResponse, Promise[AccessToken])](3)
>     )((mat, _, _, _, _, _) => mat) {
>       implicit b => (initial, merge, request, unzip, zip, bcast) =>
>             ...
>     }
>
>
>
>  ... which translates into Java 7 like this:
>
> Sink<Pair<RefreshToken, F.Promise<OAuth2Info>>, BoxedUnit> auto = 
>     Sink.factory().create6(
>         Flow.<Pair<RefreshToken, F.Promise<OAuth2Info>>>create(),
>         Merge.<Pair<RefreshToken, F.Promise<OAuth2Info>>>create(2),
>         request,
>         Unzip.<RefreshToken, F.Promise<OAuth2Info>>create(),
>         Zip.<Future<RefreshResponse>, F.Promise<OAuth2Info>>create(),
>         Broadcast.<Pair<RefreshResponse, F.Promise<OAuth2Info>>>create(3),
>         new Function6<BoxedUnit, BoxedUnit, BoxedUnit, BoxedUnit, 
> BoxedUnit, BoxedUnit, BoxedUnit>() {
>             @Override
>             public BoxedUnit apply(BoxedUnit m1, BoxedUnit m2, BoxedUnit 
> m3, BoxedUnit m4, BoxedUnit m5, BoxedUnit m6) {
>                 return m1;
>             }
>         },
>         new Function7<FlowGraph.Builder<BoxedUnit>,
>             FlowShape<Pair<RefreshToken, F.Promise<OAuth2Info>>, Pair<
> RefreshToken, F.Promise<OAuth2Info>>>,
>             UniformFanInShape<Pair<RefreshToken, F.Promise<OAuth2Info>>, 
> Pair<RefreshToken, F.Promise<OAuth2Info>>>,
>             FlowShape<RefreshToken, F.Promise<RefreshResponse>>,
>             FanOutShape2<Pair<RefreshToken, F.Promise<OAuth2Info>>, 
> RefreshToken, F.Promise<OAuth2Info>>,
>             FanInShape2<Future<RefreshResponse>,
>
> ...

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

Reply via email to