Hi,

I have the following events that I'm trying to put into a non blocking way. 
The events are as follows

1. database call to get list of asset ids.
2. create a list of futures to get assets (getting assets can take a while 
and are independent of one another)
3. process all the assets and return a Result.

What I have is the following 

 public Future<Result> buildFuture(){ 
  //Blocking DB call
    Collection<Long> assetIds = assetDao.getAssetIds();
    
    Collection<Future<Asset>> assetFutures = new 
ArrayList<>(assetIds.size());

        for (Long assetId : assetIds) {
      assetFutures.add(createFutureAsset(assetId, executionContext));
    }

    Future<Collection<Asset>> futureAssets = 
sequence((Iterable)assetFutures, executionContext);

    //once we have all Assets process them and return result
    Future<Result> futureResult = futureAssets.map(
        new Mapper<Collection<Asset>, Result>() {

          @Override
          public Result apply(Collection<Asset> assets) {
            //do something with the assets
            return new Result("done");
          }
        },
        executionContext
      );

    return futureResult;
}

What I'm trying to get my head around is how to wrap all 3 events into one 
Future<Result>.  Any ideas? Thanks in advance

Regards

-- 
>>>>>>>>>>      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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to