Codota Logo
GrpcCallContext.withChannel
Code IndexAdd Codota to your IDE (free)

How to use
withChannel
method
in
com.google.api.gax.grpc.GrpcCallContext

Best Java code snippets using com.google.api.gax.grpc.GrpcCallContext.withChannel (Showing top 7 results out of 315)

  • Common ways to obtain GrpcCallContext
private void myMethod () {
GrpcCallContext g =
  • Codota IconGrpcCallContext.createDefault()
  • Smart code suggestions by Codota
}
origin: com.google.api/gax-grpc

@Override
public GrpcCallContext withTransportChannel(TransportChannel inputChannel) {
 Preconditions.checkNotNull(inputChannel);
 if (!(inputChannel instanceof GrpcTransportChannel)) {
  throw new IllegalArgumentException(
    "Expected GrpcTransportChannel, got " + inputChannel.getClass().getName());
 }
 GrpcTransportChannel transportChannel = (GrpcTransportChannel) inputChannel;
 return withChannel(transportChannel.getChannel());
}
origin: googleapis/gax-java

@Test
public void testAffinity() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> clientCall0 = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> clientCall1 = Mockito.mock(ClientCall.class);
 ManagedChannel channel0 = Mockito.mock(ManagedChannel.class);
 ManagedChannel channel1 = Mockito.mock(ManagedChannel.class);
 Mockito.when(channel0.newCall(Mockito.eq(descriptor), Mockito.<CallOptions>any()))
   .thenReturn(clientCall0);
 Mockito.when(channel1.newCall(Mockito.eq(descriptor), Mockito.<CallOptions>any()))
   .thenReturn(clientCall1);
 Channel pool = new ChannelPool(Arrays.asList(channel0, channel1));
 GrpcCallContext context = GrpcCallContext.createDefault().withChannel(pool);
 ClientCall<Color, Money> gotCallA =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(0));
 ClientCall<Color, Money> gotCallB =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(0));
 ClientCall<Color, Money> gotCallC =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(1));
 assertThat(gotCallA).isSameAs(gotCallB);
 assertThat(gotCallA).isNotSameAs(gotCallC);
}
origin: googleapis/gax-java

@Override
public GrpcCallContext withTransportChannel(TransportChannel inputChannel) {
 Preconditions.checkNotNull(inputChannel);
 if (!(inputChannel instanceof GrpcTransportChannel)) {
  throw new IllegalArgumentException(
    "Expected GrpcTransportChannel, got " + inputChannel.getClass().getName());
 }
 GrpcTransportChannel transportChannel = (GrpcTransportChannel) inputChannel;
 return withChannel(transportChannel.getChannel());
}
origin: googleapis/gax-java

  GrpcCallContext.createDefault().withChannel(mockChannel).withExtraHeaders(extraHeaders);
GrpcClientCalls.newCall(descriptor, context).start(mockListener, emptyHeaders);
origin: googleapis/gax-java

@Test
public void testTimeoutToDeadlineConversion() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
 @SuppressWarnings("unchecked")
 Channel mockChannel = Mockito.mock(ManagedChannel.class);
 ArgumentCaptor<CallOptions> capturedCallOptions = ArgumentCaptor.forClass(CallOptions.class);
 Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), capturedCallOptions.capture()))
   .thenReturn(mockClientCall);
 Duration timeout = Duration.ofSeconds(10);
 Deadline minExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
 GrpcCallContext context =
   GrpcCallContext.createDefault().withChannel(mockChannel).withTimeout(timeout);
 GrpcClientCalls.newCall(descriptor, context).start(mockListener, new Metadata());
 Deadline maxExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtLeast(minExpectedDeadline);
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtMost(maxExpectedDeadline);
}
origin: googleapis/gax-java

@Test
public void testTimeoutAfterDeadline() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
 @SuppressWarnings("unchecked")
 Channel mockChannel = Mockito.mock(ManagedChannel.class);
 ArgumentCaptor<CallOptions> capturedCallOptions = ArgumentCaptor.forClass(CallOptions.class);
 Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), capturedCallOptions.capture()))
   .thenReturn(mockClientCall);
 // Configure a timeout that occurs after the grpc deadline
 Deadline priorDeadline = Deadline.after(5, TimeUnit.SECONDS);
 Duration timeout = Duration.ofSeconds(10);
 GrpcCallContext context =
   GrpcCallContext.createDefault()
     .withChannel(mockChannel)
     .withCallOptions(CallOptions.DEFAULT.withDeadline(priorDeadline))
     .withTimeout(timeout);
 GrpcClientCalls.newCall(descriptor, context).start(mockListener, new Metadata());
 // Verify that the timeout is ignored
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isEqualTo(priorDeadline);
}
origin: googleapis/gax-java

.withChannel(mockChannel)
.withCallOptions(CallOptions.DEFAULT.withDeadline(subsequentDeadline))
.withTimeout(timeout);
com.google.api.gax.grpcGrpcCallContextwithChannel

Javadoc

Returns a new instance with the channel set to the given channel.

Popular methods of GrpcCallContext

  • createDefault
    Returns an empty instance with a null channel and default CallOptions.
  • getCallOptions
    The CallOptions set on this context.
  • getChannel
    The Channel set on this context.
  • getExtraHeaders
    The extra header for this context.
  • getTimeout
  • nullToSelf
    Returns inputContext cast to GrpcCallContext, or an empty GrpcCallContext if inputContext is null.
  • of
    Returns an instance with the given channel and CallOptions.
  • withCallOptions
    Returns a new instance with the call options set to the given call options.
  • withChannelAffinity
  • withRequestParamsDynamicHeaderOption
  • <init>
  • getChannelAffinity
    The channel affinity for this context.
  • <init>,
  • getChannelAffinity,
  • getMetadata,
  • withExtraHeaders,
  • withStreamIdleTimeout,
  • withStreamWaitTimeout,
  • getStreamIdleTimeout,
  • getStreamWaitTimeout,
  • getTracer

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • orElseThrow (Optional)
  • putExtra (Intent)
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Reference (javax.naming)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JCheckBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now