gRPC的newStub与newBlockingStub的区别

/**
   * Creates a new async stub that supports all call types for the service
   */
  public static GoodsServiceStub newStub(io.grpc.Channel channel) {
    return new GoodsServiceStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static GoodsServiceBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new GoodsServiceBlockingStub(channel);
  }

通过源码注释可以看到:

newStub:    是创建一个新的异步的stub,可以支持所有的服务调用;

newBlockingStub:创建一个新的阻塞式的sutb,可以支持一元和流式输出的服务调用

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章