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,可以支持一元和流式输出的服务调用

 

你可能感兴趣的:(gRPC)