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

Java ClientCallStreamObserver类代码示例

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

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



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

示例1: onNextDelegates

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onNextDelegates() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    RxConsumerStreamObserver rxObs = new RxConsumerStreamObserver();
    Subscriber<Object> sub = mock(Subscriber.class);

    rxObs.beforeStart(obs);
    rxObs.getRxConsumer().subscribe(sub);

    TestSubscriber<Object> testSubscriber = ((Flowable<Object>)rxObs.getRxConsumer()).test();

    Object obj = new Object();
    rxObs.onNext(obj);
    rxObs.onCompleted();

    testSubscriber.awaitTerminalEvent(3, TimeUnit.SECONDS);
    testSubscriber.assertValues(obj);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:19,代码来源:RxConsumerStreamObserverTest.java


示例2: onErrorDelegates

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onErrorDelegates() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    RxConsumerStreamObserver rxObs = new RxConsumerStreamObserver();
    Subscriber<Object> sub = mock(Subscriber.class);

    rxObs.beforeStart(obs);
    rxObs.getRxConsumer().subscribe(sub);

    TestSubscriber<Object> testSubscriber = ((Flowable<Object>)rxObs.getRxConsumer()).test();

    Throwable obj = new Exception();
    rxObs.onError(obj);

    testSubscriber.awaitTerminalEvent(3, TimeUnit.SECONDS);
    testSubscriber.assertError(obj);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:18,代码来源:RxConsumerStreamObserverTest.java


示例3: onNextKeepsPumpRunning

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onNextKeepsPumpRunning() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    when(obs.isReady()).thenReturn(true);

    ReactivePublisherBackpressureOnReadyHandler<Object> handler = new ReactivePublisherBackpressureOnReadyHandler<Object>(obs);
    Subscription sub = mock(Subscription.class);

    handler.onSubscribe(sub);

    Object obj = new Object();
    handler.onNext(obj);

    verify(obs).onNext(obj);
    verify(sub).request(1);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:17,代码来源:ReactivePublisherBackpressureOnReadyHandlerTest.java


示例4: onNextStopsPump

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onNextStopsPump() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    when(obs.isReady()).thenReturn(false);

    ReactivePublisherBackpressureOnReadyHandler<Object> handler = new ReactivePublisherBackpressureOnReadyHandler<Object>(obs);
    Subscription sub = mock(Subscription.class);

    handler.onSubscribe(sub);

    Object obj = new Object();
    handler.onNext(obj);

    verify(obs).onNext(obj);
    verify(sub, never()).request(1);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:17,代码来源:ReactivePublisherBackpressureOnReadyHandlerTest.java


示例5: onNextDelegates

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onNextDelegates() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    ReactorConsumerStreamObserver rxObs = new ReactorConsumerStreamObserver();
    Subscriber<Object> sub = mock(Subscriber.class);

    rxObs.beforeStart(obs);
    rxObs.getRxConsumer().subscribe(sub);

    Object obj = new Object();
    StepVerifier.create(rxObs.getRxConsumer())
            .then(() -> rxObs.onNext(obj))
            .expectNext(obj)
            .then(rxObs::onCompleted)
            .expectComplete()
            .verify(Duration.ofSeconds(3));
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:18,代码来源:ReactorConsumerStreamObserverTest.java


示例6: testCallsAreForwardedAndOnReadyHandlerBound

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void testCallsAreForwardedAndOnReadyHandlerBound() {
  @SuppressWarnings("unchecked")
  StreamObserver<Object> delegateObserver = mock(StreamObserver.class);
  @SuppressWarnings("unchecked")
  ClientCallStreamObserver<Object> callStreamObserver =
      mock(ClientCallStreamObserver.class);
  Runnable onReadyHandler = new Runnable() {
    @Override
    public void run() {
    }
  };
  ClientResponseObserver<Object, Object> observer =
      new ForwardingClientResponseObserver<>(delegateObserver, onReadyHandler);
  observer.onNext("A");
  verify(delegateObserver).onNext("A");
  Throwable t = new RuntimeException();
  observer.onError(t);
  verify(delegateObserver).onError(t);
  observer.onCompleted();
  verify(delegateObserver).onCompleted();
  observer.beforeStart(callStreamObserver);
  verify(callStreamObserver).setOnReadyHandler(onReadyHandler);
  verifyNoMoreInteractions(delegateObserver, callStreamObserver);
}
 
开发者ID:apache,项目名称:beam,代码行数:26,代码来源:ForwardingClientResponseObserverTest.java


示例7: flowControl

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void flowControl() throws Exception {
  FlowControlClientResponseObserver clientResponseObserver =
      new FlowControlClientResponseObserver();
  ClientCallStreamObserver<ServerReflectionRequest> requestObserver =
      (ClientCallStreamObserver<ServerReflectionRequest>)
          stub.serverReflectionInfo(clientResponseObserver);

  // ClientCalls.startCall() calls request(1) initially, so we should get an immediate response.
  requestObserver.onNext(flowControlRequest);
  assertEquals(1, clientResponseObserver.getResponses().size());
  assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(0));

  // Verify we don't receive an additional response until we request it.
  requestObserver.onNext(flowControlRequest);
  assertEquals(1, clientResponseObserver.getResponses().size());

  requestObserver.request(1);
  assertEquals(2, clientResponseObserver.getResponses().size());
  assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(1));

  requestObserver.onCompleted();
  assertTrue(clientResponseObserver.onCompleteCalled());
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:25,代码来源:ProtoReflectionServiceTest.java


示例8: flowControlOnCompleteWithPendingRequest

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void flowControlOnCompleteWithPendingRequest() throws Exception {
  FlowControlClientResponseObserver clientResponseObserver =
      new FlowControlClientResponseObserver();
  ClientCallStreamObserver<ServerReflectionRequest> requestObserver =
      (ClientCallStreamObserver<ServerReflectionRequest>)
          stub.serverReflectionInfo(clientResponseObserver);

  // ClientCalls.startCall() calls request(1) initially, so make additional request.
  requestObserver.onNext(flowControlRequest);
  requestObserver.onNext(flowControlRequest);
  requestObserver.onCompleted();
  assertEquals(1, clientResponseObserver.getResponses().size());
  assertFalse(clientResponseObserver.onCompleteCalled());

  requestObserver.request(1);
  assertTrue(clientResponseObserver.onCompleteCalled());
  assertEquals(2, clientResponseObserver.getResponses().size());
  assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(1));
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:21,代码来源:ProtoReflectionServiceTest.java


示例9: rxConsumerIsSet

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void rxConsumerIsSet() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    RxConsumerStreamObserver rxObs = new RxConsumerStreamObserver();

    rxObs.beforeStart(obs);

    assertThat(rxObs.getRxConsumer()).isNotNull();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:10,代码来源:RxConsumerStreamObserverTest.java


示例10: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver<TRequest> producerStream) {
    Preconditions.checkNotNull(producerStream);
    // Subscribe to the rxProducer with an adapter to a gRPC StreamObserver that respects backpressure
    // signals from the underlying gRPC client transport.
    onReadyHandler = new ReactivePublisherBackpressureOnReadyHandler<TRequest>(producerStream);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:8,代码来源:ReactiveProducerStreamObserver.java


示例11: runPrimesThePump

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void runPrimesThePump() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    ReactivePublisherBackpressureOnReadyHandler<Object> handler = new ReactivePublisherBackpressureOnReadyHandler<Object>(obs);
    Subscription sub = mock(Subscription.class);

    handler.onSubscribe(sub);

    handler.run();
    verify(sub).request(1);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:12,代码来源:ReactivePublisherBackpressureOnReadyHandlerTest.java


示例12: rxConsumerIsSet

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void rxConsumerIsSet() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    ReactorConsumerStreamObserver rxObs = new ReactorConsumerStreamObserver();

    rxObs.beforeStart(obs);

    assertThat(rxObs.getRxConsumer()).isNotNull();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:10,代码来源:ReactorConsumerStreamObserverTest.java


示例13: onErrorDelegates

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Test
public void onErrorDelegates() {
    ClientCallStreamObserver<Object> obs = mock(ClientCallStreamObserver.class);
    ReactorConsumerStreamObserver rxObs = new ReactorConsumerStreamObserver();
    Subscriber<Object> sub = mock(Subscriber.class);

    rxObs.beforeStart(obs);
    rxObs.getRxConsumer().subscribe(sub);

    Throwable obj = new Exception("test error");
    StepVerifier.create(rxObs.getRxConsumer())
            .then(() -> rxObs.onError(obj))
            .expectErrorMessage("test error")
            .verify(Duration.ofSeconds(3));
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:16,代码来源:ReactorConsumerStreamObserverTest.java


示例14: ReactivePublisherBackpressureOnReadyHandler

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
public ReactivePublisherBackpressureOnReadyHandler(ClientCallStreamObserver<T> requestStream) {
    this.requestStream = Preconditions.checkNotNull(requestStream);
    requestStream.setOnReadyHandler(this);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:ReactivePublisherBackpressureOnReadyHandler.java


示例15: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver<TRequest> requestStream) {
    delegate.beforeStart(requestStream);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:CancellableStreamObserver.java


示例16: subscribe

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void subscribe(Subscriber<? super T> subscriber) {
    Preconditions.checkNotNull(subscriber);
    subscriber.onSubscribe(new Subscription() {
        private static final int MAX_REQUEST_RETRIES = 20;

        @Override
        public void request(long l) {
            // Some Reactive Streams implementations use Long.MAX_VALUE to indicate "all messages"; gRPC uses Integer.MAX_VALUE.
            int i = (int) Math.min(l, Integer.MAX_VALUE);

            // Very rarely, request() gets called before the client has finished setting up its stream. If this
            // happens, wait momentarily and try again.
            for (int j = 0; j < MAX_REQUEST_RETRIES; j++) {
                try {
                    callStreamObserver.request(i);
                    break;
                } catch (IllegalStateException ex) {
                    if (j == MAX_REQUEST_RETRIES - 1) {
                        throw ex;
                    }
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        // no-op
                    }
                }
            }
        }

        @Override
        public void cancel() {
            // Don't cancel twice if the server is already canceled
            if (callStreamObserver instanceof ServerCallStreamObserver && ((ServerCallStreamObserver) callStreamObserver).isCancelled()) {
                return;
            }

            isCanceled = true;
            if (callStreamObserver instanceof ClientCallStreamObserver) {
                ((ClientCallStreamObserver) callStreamObserver).cancel("Client canceled request", null);
            } else {
                callStreamObserver.onError(Status.CANCELLED.withDescription("Server canceled request").asRuntimeException());
            }
        }
    });
    this.subscriber = subscriber;

    subscribed.countDown();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:50,代码来源:ReactiveStreamObserverPublisher.java


示例17: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver<TRequest> requestStream) {
    super.beforeStart(Preconditions.checkNotNull(requestStream));
    onReadyHandler = new ReactivePublisherBackpressureOnReadyHandler<TRequest>(requestStream);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:6,代码来源:ReactiveProducerConsumerStreamObserver.java


示例18: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver<TRequest> requestStream) {
    publisher = new ReactiveStreamObserverPublisher<TResponse>(Preconditions.checkNotNull(requestStream));
    rxConsumer = getReactiveConsumerFromPublisher(publisher);
    beforeStartCalled.countDown();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:7,代码来源:ReactiveConsumerStreamObserver.java


示例19: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver<RespT> stream) {
  stream.setOnReadyHandler(onReadyHandler);
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:ForwardingClientResponseObserver.java


示例20: beforeStart

import io.grpc.stub.ClientCallStreamObserver; //导入依赖的package包/类
@Override
public void beforeStart(ClientCallStreamObserver requestStream) {
  requestStream.setOnReadyHandler(phaser::arrive);
}
 
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:BeamFnLoggingClient.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ImageViewUtil类代码示例发布时间:2022-05-22
下一篇:
Java HTMLCollection类代码示例发布时间: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