@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1783") public final class InProcessServerBuilder extends io.grpc.internal.AbstractServerImplBuilder<InProcessServerBuilder>
The server is intended to be fully-featured, high performance, and useful in testing.
InProcessServer
and a ManagedChannel
. This
test rule contains the boilerplate code shown below. The classes "HelloWorldServerTest" and
"HelloWorldClientTest" (from "grpc-java/examples") demonstrate basic usage.
Server server = InProcessServerBuilder.forName("unique-name") .directExecutor() // directExecutor is fine for unit tests .addService(/* your code here */) .build().start(); ManagedChannel channel = InProcessChannelBuilder.forName("unique-name") .directExecutor() .build();
TestServiceGrpc.TestServiceBlockingStub blockingStub = TestServiceGrpc.newBlockingStub(channel);
Modifier and Type | Method and Description |
---|---|
protected io.grpc.inprocess.InProcessServer |
buildTransportServer(List<ServerStreamTracer.Factory> streamTracerFactories) |
static InProcessServerBuilder |
forName(String name)
Create a server builder that will bind with the given name.
|
InProcessServerBuilder |
useTransportSecurity(File certChain,
File privateKey)
Makes the server use TLS.
|
addService, addService, addStreamTracerFactory, addTransportFilter, build, compressorRegistry, decompressorRegistry, directExecutor, executor, fallbackHandlerRegistry, intercept, statsContextFactory
forPort
public static InProcessServerBuilder forName(String name)
name
- the identity of the server for clients to connect toprotected io.grpc.inprocess.InProcessServer buildTransportServer(List<ServerStreamTracer.Factory> streamTracerFactories)
buildTransportServer
in class io.grpc.internal.AbstractServerImplBuilder<InProcessServerBuilder>
public InProcessServerBuilder useTransportSecurity(File certChain, File privateKey)
ServerBuilder
useTransportSecurity
in class ServerBuilder<InProcessServerBuilder>
certChain
- file containing the full certificate chainprivateKey
- file containing the private key