本文整理汇总了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;未经允许,请勿转载。 |
请发表评论