Java Code Examples for io.grpc.inprocess.InProcessChannelBuilder#forName()

The following examples show how to use io.grpc.inprocess.InProcessChannelBuilder#forName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrpcServerRule.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
/**
 * Before the test has started, create the server and channel.
 */
@Override
protected void before() throws Throwable {
  serverName = UUID.randomUUID().toString();

  serviceRegistry = new MutableHandlerRegistry();

  InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName)
      .fallbackHandlerRegistry(serviceRegistry);

  if (useDirectExecutor) {
    serverBuilder.directExecutor();
  }

  server = serverBuilder.build().start();

  InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName);

  if (useDirectExecutor) {
    channelBuilder.directExecutor();
  }

  channel = channelBuilder.build();
}
 
Example 2
Source File: GrpcServerExtension.java    From jetcd with Apache License 2.0 6 votes vote down vote up
/**
 * Before the test has started, create the server and channel.
 */
@Override
public void beforeEach(ExtensionContext context) throws Exception {
    serverName = UUID.randomUUID().toString();

    serviceRegistry = new MutableHandlerRegistry();

    InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName)
        .fallbackHandlerRegistry(serviceRegistry);

    if (useDirectExecutor) {
        serverBuilder.directExecutor();
    }

    server = serverBuilder.build().start();

    InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName);

    if (useDirectExecutor) {
        channelBuilder.directExecutor();
    }

    channel = channelBuilder.build();
}
 
Example 3
Source File: GrpcServerRule.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
/**
 * Before the test has started, create the server and channel.
 */
@Override
protected void before() throws Throwable {
  serverName = UUID.randomUUID().toString();

  serviceRegistry = new MutableHandlerRegistry();

  InProcessServerBuilder serverBuilder = InProcessServerBuilder.forName(serverName)
      .fallbackHandlerRegistry(serviceRegistry);

  if (useDirectExecutor) {
    serverBuilder.directExecutor();
  }

  server = serverBuilder.build().start();

  InProcessChannelBuilder channelBuilder = InProcessChannelBuilder.forName(serverName);

  if (useDirectExecutor) {
    channelBuilder.directExecutor();
  }

  channel = channelBuilder.build();
}
 
Example 4
Source File: InProcessTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Override
protected ManagedChannel createChannel() {
  InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME);
  io.grpc.internal.TestingAccessor.setStatsImplementation(
      builder, createClientCensusStatsModule());
  return builder.build();
}
 
Example 5
Source File: GrpcChannelBuilderFactory.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new gRPC InProcessChannelBuilder with instrumentation.
 */
public ManagedChannelBuilder<?> newInProcessChannelBuilder(String processName) {
  final ManagedChannelBuilder<?> builder = InProcessChannelBuilder.forName(processName);
  addDefaultBuilderProperties(builder);

  return builder;
}
 
Example 6
Source File: InProcessTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
protected ManagedChannel createChannel() {
  InProcessChannelBuilder builder = InProcessChannelBuilder.forName(SERVER_NAME);
  // Disable the default census stats interceptor, use testing interceptor instead.
  io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false);
  return builder.intercept(createCensusStatsClientInterceptor()).build();
}
 
Example 7
Source File: InProcessChannelFactory.java    From grpc-spring-boot-starter with MIT License 4 votes vote down vote up
@Override
protected InProcessChannelBuilder newChannelBuilder(final String name) {
    log.debug("Creating new channel: {}", name);
    return InProcessChannelBuilder.forName(name);
}
 
Example 8
Source File: InProcessChannelFactory.java    From grpc-spring-boot-starter with MIT License 4 votes vote down vote up
@Override
protected InProcessChannelBuilder newChannelBuilder(final String name) {
    log.debug("Creating new channel: {}", name);
    return InProcessChannelBuilder.forName(name);
}
 
Example 9
Source File: SpringAwareManagedChannelBuilder.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
public ManagedChannelBuilder<?> inProcessChannelBuilder(String serverName) {
	ManagedChannelBuilder<?> builder = InProcessChannelBuilder.forName(serverName);
	customize(builder);
	return builder;
}