congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GrpcCallContext.createDefault
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: googleapis/google-cloud-java

private GrpcCallContext newCallContext(@Nullable Map<Option, ?> options, String resource) {
 GrpcCallContext context = GrpcCallContext.createDefault();
 if (options != null) {
  context = context.withChannelAffinity(Option.CHANNEL_HINT.getLong(options).intValue());
 }
 context = context.withExtraHeaders(metadataProvider.newExtraHeaders(resource, projectName));
 return context.withStreamWaitTimeout(waitTimeout).withStreamIdleTimeout(idleTimeout);
}
origin: googleapis/google-cloud-java

@Before
public void setUp() {
 innerCallable = new MockInnerCallable();
 retryCodes = ImmutableSet.of(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);
 callContext = GrpcCallContext.createDefault();
 parentFuture = new MockRetryingFuture();
}
origin: googleapis/google-cloud-java

.splitCall(
  responseObserver,
  GrpcCallContext.createDefault().withChannelAffinity(channelAffinity));
origin: com.google.api/gax-grpc

@Override
public GrpcCallContext getEmptyCallContext() {
 return GrpcCallContext.createDefault();
}
origin: com.google.api/gax-grpc

/**
 * Constructs a new call context and sets the CallOptions to add handlers to retrieve the headers
 * and trailers, and make them available via the getMetadata and getTrailingMetadata methods.
 */
public GrpcCallContext createContextWithHandlers() {
 return addHandlers(GrpcCallContext.createDefault());
}
origin: googleapis/gax-java

/**
 * Constructs a new call context and sets the CallOptions to add handlers to retrieve the headers
 * and trailers, and make them available via the getMetadata and getTrailingMetadata methods.
 */
public GrpcCallContext createContextWithHandlers() {
 return addHandlers(GrpcCallContext.createDefault());
}
origin: com.google.api/gax-grpc

 private ApiCallContext contextWithParamsEncoder(RequestT request, ApiCallContext inputContext) {
  return GrpcCallContext.createDefault()
    .nullToSelf(inputContext)
    .withRequestParamsDynamicHeaderOption(paramsEncoder.encode(request));
 }
}
origin: googleapis/gax-java

@Override
public ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext inputContext) {
 GrpcCallContext context = GrpcCallContext.createDefault().nullToSelf(inputContext);
 ApiFuture<ResponseT> innerCallFuture = callable.futureCall(request, context);
 ExceptionTransformingFuture transformingFuture =
   new ExceptionTransformingFuture(innerCallFuture);
 ApiFutures.addCallback(innerCallFuture, transformingFuture, directExecutor());
 return transformingFuture;
}
origin: com.google.api/gax-grpc

@Override
public ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext inputContext) {
 GrpcCallContext context = GrpcCallContext.createDefault().nullToSelf(inputContext);
 ApiFuture<ResponseT> innerCallFuture = callable.futureCall(request, context);
 ExceptionTransformingFuture transformingFuture =
   new ExceptionTransformingFuture(innerCallFuture);
 ApiFutures.addCallback(innerCallFuture, transformingFuture, directExecutor());
 return transformingFuture;
}
origin: googleapis/gax-java

 private ApiCallContext contextWithParamsEncoder(RequestT request, ApiCallContext inputContext) {
  return GrpcCallContext.createDefault()
    .nullToSelf(inputContext)
    .withRequestParamsDynamicHeaderOption(paramsEncoder.encode(request));
 }
}
origin: com.google.cloud/google-cloud-spanner

private GrpcCallContext newCallContext(@Nullable Map<Option, ?> options, String resource) {
 GrpcCallContext context = GrpcCallContext.createDefault();
 if (options != null) {
  context = context.withChannelAffinity(Option.CHANNEL_HINT.getLong(options).intValue());
 }
 context = context.withExtraHeaders(metadataProvider.newExtraHeaders(resource, projectName));
 return context.withStreamWaitTimeout(waitTimeout).withStreamIdleTimeout(idleTimeout);
}
origin: com.google.api/gax-grpc

 @Override
 public ApiFuture<ResponseT> futureCall(RequestT request, ApiCallContext inputContext) {
  GrpcCallContext newCallContext =
    GrpcCallContext.createDefault()
      .nullToSelf(inputContext)
      .withRequestParamsDynamicHeaderOption(paramsEncoder.encode(request));

  return callable.futureCall(request, newCallContext);
 }
}
origin: googleapis/gax-java

@Test
public void testMergeWithNullStreamingWaitTimeout() {
 Duration timeout = Duration.ofSeconds(10);
 GrpcCallContext baseContext = GrpcCallContext.createDefault().withStreamWaitTimeout(timeout);
 GrpcCallContext defaultOverlay = GrpcCallContext.createDefault();
 Truth.assertThat(baseContext.merge(defaultOverlay).getStreamWaitTimeout()).isEqualTo(timeout);
 GrpcCallContext explicitNullOverlay =
   GrpcCallContext.createDefault().withStreamWaitTimeout(null);
 Truth.assertThat(baseContext.merge(explicitNullOverlay).getStreamWaitTimeout())
   .isEqualTo(timeout);
}
origin: googleapis/gax-java

@Test
public void testMergeWithNullStreamingIdleTimeout() {
 Duration timeout = Duration.ofSeconds(10);
 GrpcCallContext baseContext = GrpcCallContext.createDefault().withStreamIdleTimeout(timeout);
 GrpcCallContext defaultOverlay = GrpcCallContext.createDefault();
 Truth.assertThat(baseContext.merge(defaultOverlay).getStreamIdleTimeout()).isEqualTo(timeout);
 GrpcCallContext explicitNullOverlay =
   GrpcCallContext.createDefault().withStreamIdleTimeout(null);
 Truth.assertThat(baseContext.merge(explicitNullOverlay).getStreamIdleTimeout())
   .isEqualTo(timeout);
}
origin: googleapis/gax-java

@Test
public void testWithTransportChannel() {
 ManagedChannel channel = Mockito.mock(ManagedChannel.class);
 GrpcCallContext context =
   GrpcCallContext.createDefault().withTransportChannel(GrpcTransportChannel.create(channel));
 Truth.assertThat(context.getChannel()).isSameAs(channel);
}
origin: googleapis/gax-java

@Test
public void testWithZeroStreamingIdleTimeout() {
 Duration timeout = Duration.ZERO;
 Truth.assertThat(
     GrpcCallContext.createDefault().withStreamIdleTimeout(timeout).getStreamIdleTimeout())
   .isEqualTo(timeout);
}
origin: googleapis/gax-java

@Test
public void testWithCredentials() {
 Credentials credentials = Mockito.mock(Credentials.class);
 GrpcCallContext emptyContext = GrpcCallContext.createDefault();
 Truth.assertThat(emptyContext.getCallOptions().getCredentials()).isNull();
 GrpcCallContext context = emptyContext.withCredentials(credentials);
 Truth.assertThat(context.getCallOptions().getCredentials()).isNotNull();
}
origin: googleapis/gax-java

@Test
public void testWithNegativeTimeout() {
 Truth.assertThat(
     GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(-1L)).getTimeout())
   .isNull();
}
origin: googleapis/gax-java

@Test
public void testWithStreamingIdleTimeout() {
 Duration timeout = Duration.ofSeconds(15);
 GrpcCallContext context = GrpcCallContext.createDefault().withStreamIdleTimeout(timeout);
 Truth.assertThat(context.getStreamIdleTimeout()).isEqualTo(timeout);
}
origin: googleapis/gax-java

@Test
public void testWithShorterTimeout() {
 GrpcCallContext ctxWithLongTimeout =
   GrpcCallContext.createDefault().withTimeout(Duration.ofSeconds(10));
 // Sanity check
 Truth.assertThat(ctxWithLongTimeout.getTimeout()).isEqualTo(Duration.ofSeconds(10));
 // Shorten the timeout and make sure it changed
 GrpcCallContext ctxWithShorterTimeout = ctxWithLongTimeout.withTimeout(Duration.ofSeconds(5));
 Truth.assertThat(ctxWithShorterTimeout.getTimeout()).isEqualTo(Duration.ofSeconds(5));
}
com.google.api.gax.grpcGrpcCallContextcreateDefault

Javadoc

Returns an empty instance with a null channel and default CallOptions.

Popular methods of GrpcCallContext

  • 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.
  • withChannel
    Returns a new instance with the channel set to the given channel.
  • withChannelAffinity
  • withRequestParamsDynamicHeaderOption
  • <init>
  • getChannelAffinity
    The channel affinity for this context.
  • <init>,
  • getChannelAffinity,
  • getMetadata,
  • withExtraHeaders,
  • withStreamIdleTimeout,
  • withStreamWaitTimeout,
  • getStreamIdleTimeout,
  • getStreamWaitTimeout,
  • getTracer

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • Kernel (java.awt.image)
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ImageIO (javax.imageio)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now