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,可以支持一元和流式輸出的服務調用

 

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