• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceCall类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.lightbend.lagom.javadsl.api.ServiceCall的典型用法代码示例。如果您正苦于以下问题:Java ServiceCall类的具体用法?Java ServiceCall怎么用?Java ServiceCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceCall类属于com.lightbend.lagom.javadsl.api包,在下文中一共展示了ServiceCall类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLiveChirps

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<LiveChirpsRequest, Source<Chirp, ?>> getLiveChirps() {
    return req -> chirps.getRecentChirps(req.userIds).thenApply(recentChirps -> {
        List<Source<Chirp, ?>> sources = new ArrayList<>();
        for (String userId : req.userIds) {
            sources.add(topic.subscriber(userId));
        }
        HashSet<String> users = new HashSet<>(req.userIds);
        Source<Chirp, ?> publishedChirps = Source.from(sources).flatMapMerge(sources.size(), s -> s)
                .filter(c -> users.contains(c.userId));

        // We currently ignore the fact that it is possible to get duplicate chirps
        // from the recent and the topic. That can be solved with a de-duplication stage.
        return Source.from(recentChirps).concat(publishedChirps);
    });
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:17,代码来源:ChirpServiceImpl.java


示例2: getAllRegistrations

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
/**
* Get all registered Cargo
*
* @return
*/
   @Override
   public ServiceCall<NotUsed, NotUsed, PSequence<Cargo>> getAllRegistrations() {
       return (userId, req) -> {
           CompletionStage<PSequence<Cargo>> result = db.selectAll("SELECT cargoid, name, description, owner, destination FROM cargo")
                   .thenApply(rows -> {
                       List<Cargo> cargos = rows.stream().map(row -> Cargo.of(row.getString("cargoid"),
                               row.getString("name"),
                               row.getString("description"),
                               row.getString("owner"),
                               row.getString("destination"))).collect(Collectors.toList());
                       return TreePVector.from(cargos);
                   });
           return result;
       };
   }
 
开发者ID:lagom,项目名称:activator-lagom-cargotracker,代码行数:21,代码来源:RegistrationServiceImpl.java


示例3: getHistoricalChirps

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<HistoricalChirpsRequest, Source<Chirp, ?>> getHistoricalChirps() {
  return req -> {
    List<Source<Chirp, ?>> sources = new ArrayList<>();
    for (String uid : req.getUserIds()) {
        Source<Chirp, NotUsed> select = db
          .select("SELECT * FROM chirp WHERE userId = ? AND timestamp >= ? ORDER BY timestamp ASC", uid,
              req.getFromTime().toEpochMilli())
          .map(this::mapChirp);
      sources.add(select);
    }
      // Chirps from one user are ordered by timestamp, but chirps from different
      // users are not ordered. That can be improved by implementing a smarter
      // merge that takes the timestamps into account.
    Source<Chirp, ?> result = Source.from(sources).flatMapMerge(sources.size(), s -> s);
    return CompletableFuture.completedFuture(result);
  };
}
 
开发者ID:negokaz,项目名称:lagom-hands-on-development,代码行数:19,代码来源:ChirpServiceImpl.java


示例4: provisionItems

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<Shipment, Done> provisionItems() {
    return shipment ->
            refFor(shipment.getId())
                    .ask(new IncreaseInventory(
                            shipment.getName(),
                            shipment.getId(),
                            shipment.getCount()))
                    .thenApply(ignored -> Done.getInstance())
            ;
}
 
开发者ID:ignasi35,项目名称:lagom-java-workshop,代码行数:12,代码来源:InventoryServiceImpl.java


示例5: hello

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
public ServiceCall<NotUsed, String> hello(String id) {
  return request -> {
    // Look up the hello world entity for the given ID.
    PersistentEntityRef<HelloCommand> ref = persistentEntityRegistry.refFor(HelloEntity.class, id);
    // Ask the entity the Hello command.
    return ref.ask(new Hello(id, Optional.empty()));
  };
}
 
开发者ID:MarioAriasC,项目名称:lagomkotlin,代码行数:9,代码来源:HelloServiceImpl.java


示例6: useGreeting

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
public ServiceCall<GreetingMessage, Done> useGreeting(String id) {
  return request -> {
    // Look up the hello world entity for the given ID.
    PersistentEntityRef<HelloCommand> ref = persistentEntityRegistry.refFor(HelloEntity.class, id);
    // Tell the entity to use the greeting name specified.
    return ref.ask(new UseGreetingMessage(request.message));
  };

}
 
开发者ID:MarioAriasC,项目名称:lagomkotlin,代码行数:10,代码来源:HelloServiceImpl.java


示例7: getUser

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, User> getUser(String userId) {
  return request -> {
    return friendEntityRef(userId).ask(new GetUser()).thenApply(reply -> {
      if (reply.user.isPresent())
        return reply.user.get();
      else
        throw new NotFound("user " + userId + " not found");
    });
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:FriendServiceImpl.java


示例8: createUser

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<User, NotUsed> createUser() {
  return request -> {
    return friendEntityRef(request.userId).ask(new CreateUser(request))
        .thenApply(ack -> NotUsed.getInstance());
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:8,代码来源:FriendServiceImpl.java


示例9: addFriend

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<FriendId, NotUsed> addFriend(String userId) {
  return request -> {
    return friendEntityRef(userId).ask(new AddFriend(request.friendId))
        .thenApply(ack -> NotUsed.getInstance());
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:8,代码来源:FriendServiceImpl.java


示例10: getFollowers

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, PSequence<String>> getFollowers(String userId) {
  return req -> {
    CompletionStage<PSequence<String>> result = db.selectAll("SELECT * FROM follower WHERE userId = ?", userId)
      .thenApply(rows -> {
      List<String> followers = rows.stream().map(row -> row.getString("followedBy")).collect(Collectors.toList());
      return TreePVector.from(followers);
    });
    return result;
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:FriendServiceImpl.java


示例11: startLoadHeadless

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<TestParams, NotUsed> startLoadHeadless() {
  return params -> {
    load(params).runWith(Sink.ignore(), materializer);
    return CompletableFuture.completedFuture(NotUsed.getInstance());
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:8,代码来源:LoadTestServiceImpl.java


示例12: addChirp

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<Chirp, NotUsed> addChirp(String userId) {
    return chirp -> {
        if (!userId.equals(chirp.userId))
            throw new IllegalArgumentException("UserId " + userId + " did not match userId in " + chirp);

        return persistentEntities.refFor(ChirpTimelineEntity.class, userId)
                .ask(new AddChirp(chirp))
                .thenApply(done -> NotUsed.getInstance());
    };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:ChirpServiceImpl.java


示例13: getHistoricalChirps

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<HistoricalChirpsRequest, Source<Chirp, ?>> getHistoricalChirps() {
    return req -> {
        PSequence<String> userIds = req.userIds;
        long timestamp = req.fromTime.toEpochMilli();
        Source<Chirp, ?> result = chirps.getHistoricalChirps(userIds, timestamp);
        return CompletableFuture.completedFuture(result);
    };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:10,代码来源:ChirpServiceImpl.java


示例14: getLiveActivityStream

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, Source<Chirp, ?>> getLiveActivityStream(String userId) {
  return req -> {
    return friendService.getUser(userId).invoke().thenCompose(user -> {
      PSequence<String> userIds = user.friends.plus(userId);
      LiveChirpsRequest chirpsReq =  new LiveChirpsRequest(userIds);
      // Note that this stream will not include changes to friend associates,
      // e.g. adding a new friend.
      CompletionStage<Source<Chirp, ?>> result = chirpService.getLiveChirps().invoke(chirpsReq);
      return result;
    });
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:14,代码来源:ActivityStreamServiceImpl.java


示例15: getHistoricalActivityStream

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, Source<Chirp, ?>> getHistoricalActivityStream(String userId) {
  return req ->
    friendService.getUser(userId).invoke().thenCompose(user -> {
      PSequence<String> userIds = user.friends.plus(userId);
      // FIXME we should use HistoricalActivityStreamReq request parameter
      Instant fromTime = Instant.now().minus(Duration.ofDays(7));
      HistoricalChirpsRequest chirpsReq = new HistoricalChirpsRequest(fromTime, userIds);
      CompletionStage<Source<Chirp, ?>> result = chirpService.getHistoricalChirps().invoke(chirpsReq);
      return result;
    });
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:13,代码来源:ActivityStreamServiceImpl.java


示例16: getUser

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, User> getUser(String userId) {
  return req -> {
    if (userId.equals(usr1.userId))
      return completedFuture(usr1);
    else if (userId.equals(usr2.userId))
      return completedFuture(usr2);
    else
      throw new NotFound(userId);
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:ActivityStreamServiceTest.java


示例17: getFollowers

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<NotUsed, PSequence<String>> getFollowers(String userId) {
  return req -> {
    if (userId.equals(usr1.userId))
      return completedFuture(TreePVector.<String>empty());
    else if (userId.equals(usr2.userId))
      return completedFuture(TreePVector.<String>empty().plus("usr1"));
    else
      throw new NotFound(userId);
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:ActivityStreamServiceTest.java


示例18: getLiveChirps

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<LiveChirpsRequest, Source<Chirp, ?>> getLiveChirps() {
  return req -> {
    if (req.userIds.contains("usr2")) {
      Chirp c1 = new Chirp("usr2", "msg1");
      Chirp c2 = new Chirp("usr2", "msg2");
      return completedFuture(Source.from(Arrays.asList(c1, c2)));
    } else
      return completedFuture(Source.empty());
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:12,代码来源:ActivityStreamServiceTest.java


示例19: getHistoricalChirps

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<HistoricalChirpsRequest, Source<Chirp, ?>> getHistoricalChirps() {
  return req -> {
    if (req.userIds.contains("usr2")) {
      Chirp c1 = new Chirp("usr2", "msg1");
      return completedFuture(Source.single(c1));
    } else
      return completedFuture(Source.empty());
  };
}
 
开发者ID:lagom,项目名称:lagom-java-chirper-example,代码行数:11,代码来源:ActivityStreamServiceTest.java


示例20: addLeg

import com.lightbend.lagom.javadsl.api.ServiceCall; //导入依赖的package包/类
@Override
public ServiceCall<String, Leg, Done> addLeg() {
    return (id, request) -> {
        CompletionStage<Cargo> response = registrationService.getRegistration().invoke(request.getCargoId(), NotUsed.getInstance());
        PersistentEntityRef<ShippingCommand> itinerary = persistentEntityRegistry.refFor(ItineraryEntity.class, id);
        return itinerary.ask(AddLeg.of(request));
    };
}
 
开发者ID:lagom,项目名称:activator-lagom-cargotracker,代码行数:9,代码来源:ShippingServiceImpl.java



注:本文中的com.lightbend.lagom.javadsl.api.ServiceCall类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QueryExceptionHTTP类代码示例发布时间:2022-05-22
下一篇:
Java StringSupport类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap