Ejemplo n.º 1
0
  public static Promise<Result> get(String symbol) {
    ActorRef stockSentimentActor =
        ActorManagerExtension.ActorManagerExtensionProvider.get(Akka.system())
            .getStockSentimentProxy();
    Future<Object> futureStockSentiments =
        Patterns.ask(stockSentimentActor, new StockSentimentActor.GetSentiment(symbol), timeout);
    Promise<Object> promiseSentiments = Promise.wrap(futureStockSentiments);

    return promiseSentiments
        .<Result>map(
            obj -> {
              StockSentimentActor.SendSentiment sendSentiment =
                  (StockSentimentActor.SendSentiment) obj;
              return Results.ok(sendSentiment.getSentiment());
            })
        .recover(StockSentiment::errorResponse);
  }
Ejemplo n.º 2
0
 /**
  * Completes this promise with the specified Promise, once that Promise is completed.
  *
  * @param other The value to complete with
  * @param ec An execution context
  * @return A promise giving the result of attempting to complete this promise with the other
  *     promise. If the completion was successful then the result will be true, if the completion
  *     couldn't occur then the result will be false.
  */
 public Promise<Boolean> tryCompleteWith(Promise other, ExecutionContext ec) {
   Promise<Boolean> r =
       Promise.wrap(FPromiseHelper.tryCompleteWith(this.promise, other.future, ec));
   return r;
 }
Ejemplo n.º 3
0
 /**
  * Completes this promise with the specified Promise, once that Promise is completed.
  *
  * @param other The value to complete with
  * @param ec An execution context
  * @return A promise giving the result of attempting to complete this promise with the other
  *     promise. If the completion was successful then the result will be a null value, if the
  *     completion failed then the result will be an IllegalStateException.
  */
 public Promise<Void> completeWith(Promise other, ExecutionContext ec) {
   Promise<Void> r = Promise.wrap(FPromiseHelper.completeWith(this.promise, other.future, ec));
   return r;
 }