本文整理汇总了Java中io.grpc.inprocess.InProcessServerBuilder类的典型用法代码示例。如果您正苦于以下问题:Java InProcessServerBuilder类的具体用法?Java InProcessServerBuilder怎么用?Java InProcessServerBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InProcessServerBuilder类属于io.grpc.inprocess包,在下文中一共展示了InProcessServerBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: factory
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Bean
public GrpcServerFactory factory() {
return new SimpleGrpcServerFactory() {
@Override
public Server buildServerForServices(int port, Collection<BindableService> services) {
System.out.println("Building an IN-PROC service for " + services.size() + " services");
ServerBuilder builder = InProcessServerBuilder.forName(SERVER_NAME);
services.forEach(builder::addService);
return builder.build();
}
@Override
public List<Class<? extends Annotation>> forAnnotations() {
return ImmutableList.of(InProcessGrpcService.class);
}
};
}
示例2: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
String mockProfile[] = {"other", "test"};
JHipsterProperties.Ribbon ribbon = new JHipsterProperties.Ribbon();
ribbon.setDisplayOnActiveProfiles(mockProfile);
when(jHipsterProperties.getRibbon()).thenReturn(ribbon);
String activeProfiles[] = {"test"};
when(environment.getDefaultProfiles()).thenReturn(activeProfiles);
when(environment.getActiveProfiles()).thenReturn(activeProfiles);
ProfileInfoService service = new ProfileInfoService(jHipsterProperties, environment);
String uniqueServerName = "Mock server for " + ProfileInfoService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = ProfileInfoServiceGrpc.newBlockingStub(channelBuilder.build());
}
示例3: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public final void setUp() throws Exception {
// Use a mutable service registry for later registering the service impl for each test case.
fakeServer =
InProcessServerBuilder.forName(fakeServerName)
.fallbackHandlerRegistry(serviceRegistry)
.directExecutor()
.build()
.start();
Chunker.setDefaultChunkSizeForTesting(1000); // Enough for everything to be one chunk.
fs = new InMemoryFileSystem(new JavaClock(), HashFunction.SHA256);
execRoot = fs.getPath("/exec/root");
FileSystemUtils.createDirectoryAndParents(execRoot);
fakeFileCache = new FakeActionInputFileCache(execRoot);
Path stdout = fs.getPath("/tmp/stdout");
Path stderr = fs.getPath("/tmp/stderr");
FileSystemUtils.createDirectoryAndParents(stdout.getParentDirectory());
FileSystemUtils.createDirectoryAndParents(stderr.getParentDirectory());
outErr = new FileOutErr(stdout, stderr);
Context withEmptyMetadata =
TracingMetadataUtils.contextWithMetadata(
"none", "none", DIGEST_UTIL.asActionKey(Digest.getDefaultInstance()));
withEmptyMetadata.attach();
}
示例4: before
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
/**
* 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();
}
示例5: startServer
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
public void startServer() throws Exception {
server = InProcessServerBuilder
.forName("GradleProof")
.addService(this)
.build()
.start();
}
示例6: uniqueSessionIdPerChannel
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Test
public void uniqueSessionIdPerChannel() throws Exception {
GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
@Override
public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
responseObserver.onNext(HelloResponse.newBuilder().setMessage(SessionIdServerInterceptor.SESSION_ID.get().toString()).build());
responseObserver.onCompleted();
}
};
Server server = InProcessServerBuilder.forName("uniqueSessionIdPerChannel")
.addTransportFilter(new ClientSessionTransportFilter())
.intercept(new SessionIdServerInterceptor())
.addService(svc)
.build()
.start();
ManagedChannel channel1 = InProcessChannelBuilder.forName("uniqueSessionIdPerChannel")
.usePlaintext(true)
.build();
GreeterGrpc.GreeterBlockingStub stub1 = GreeterGrpc.newBlockingStub(channel1);
ManagedChannel channel2 = InProcessChannelBuilder.forName("uniqueSessionIdPerChannel")
.usePlaintext(true)
.build();
GreeterGrpc.GreeterBlockingStub stub2 = GreeterGrpc.newBlockingStub(channel2);
try {
String sessionId1 = stub1.sayHello(HelloRequest.getDefaultInstance()).getMessage();
String sessionId2 = stub2.sayHello(HelloRequest.getDefaultInstance()).getMessage();
assertThat(sessionId1).isNotEqualTo(sessionId2);
} finally {
channel1.shutdown();
channel2.shutdown();
server.shutdown();
}
}
示例7: interceptorThrowsIfMissingTransportFilter
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Test
public void interceptorThrowsIfMissingTransportFilter() throws Exception {
GreeterGrpc.GreeterImplBase svc = new GreeterGrpc.GreeterImplBase() {
@Override
public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
responseObserver.onNext(HelloResponse.newBuilder().setMessage(SessionIdServerInterceptor.SESSION_ID.get().toString()).build());
responseObserver.onCompleted();
}
};
Server server = InProcessServerBuilder.forName("interceptorThrowsIfMissingTransportFilter")
.intercept(new SessionIdServerInterceptor())
.addService(svc)
.build()
.start();
ManagedChannel channel = InProcessChannelBuilder.forName("interceptorThrowsIfMissingTransportFilter")
.usePlaintext(true)
.build();
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);
try {
assertThatThrownBy(() -> stub.sayHello(HelloRequest.getDefaultInstance()).getMessage()).isInstanceOf(StatusRuntimeException.class);
} finally {
channel.shutdown();
server.shutdown();
}
}
示例8: perSessionShouldFailMissingTransportFilter
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Test
public void perSessionShouldFailMissingTransportFilter() throws Exception {
class TestService extends GreeterGrpc.GreeterImplBase {
@Override
public void sayHello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
responseObserver.onNext(HelloResponse.newBuilder().setMessage(Integer.toString(System.identityHashCode(this))).build());
responseObserver.onCompleted();
}
}
ClientSessionTransportFilter tf = new ClientSessionTransportFilter();
Server server = InProcessServerBuilder.forName("perSessionShouldInstantiateOneInstancePerSession")
.addService(new PerSessionService<>(() -> new TestService(), tf))
.build()
.start();
ManagedChannel channel = InProcessChannelBuilder.forName("perSessionShouldInstantiateOneInstancePerSession")
.usePlaintext(true)
.build();
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);
try {
assertThatThrownBy(() -> stub.sayHello(HelloRequest.getDefaultInstance()).getMessage()).isInstanceOf(StatusRuntimeException.class);
} finally {
channel.shutdown();
server.shutdown();
}
}
示例9: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String uniqueServerName = "in-process server for " + getClass();
memoryInstanceConfig = MemoryInstanceConfig.newBuilder()
.setListOperationsDefaultPageSize(1024)
.setListOperationsMaxPageSize(16384)
.setTreeDefaultPageSize(1024)
.setTreeMaxPageSize(16384)
.setOperationPollTimeout(Duration.newBuilder()
.setSeconds(10)
.setNanos(0))
.setOperationCompletedDelay(Duration.newBuilder()
.setSeconds(10)
.setNanos(0))
.build();
BuildFarmServerConfig.Builder configBuilder =
BuildFarmServerConfig.newBuilder().setPort(0);
configBuilder.addInstancesBuilder()
.setName("memory")
.setMemoryInstanceConfig(memoryInstanceConfig);
server = new BuildFarmServer(
InProcessServerBuilder.forName(uniqueServerName).directExecutor(),
configBuilder.build());
server.start();
inProcessChannel = InProcessChannelBuilder.forName(uniqueServerName)
.directExecutor().build();
}
示例10: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
JWTService service = new JWTService(tokenProvider, authenticationManager);
String uniqueServerName = "Mock server for " + JWTService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = JWTServiceGrpc.newBlockingStub(channelBuilder.build());
}
示例11: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
MetricService service = new MetricService(publicMetrics);
String uniqueServerName = "Mock server for " + MetricService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = MetricServiceGrpc.newBlockingStub(channelBuilder.build());
}
示例12: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
ConfigurationPropertiesReportService service = new ConfigurationPropertiesReportService(configurationPropertiesReportEndpoint);
String uniqueServerName = "Mock server for " + ConfigurationPropertiesReportService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = ConfigurationPropertiesReportServiceGrpc.newBlockingStub(channelBuilder.build());
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_ConfigurationPropertiesReportServiceIntTest.java
示例13: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
LoggersService service = new LoggersService(loggingSystem);
String uniqueServerName = "Mock server for " + LoggersService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = LoggersServiceGrpc.newBlockingStub(channelBuilder.build());
}
示例14: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
EnvironmentService service = new EnvironmentService(endpoint);
String uniqueServerName = "Mock server for " + EnvironmentService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = EnvironmentServiceGrpc.newBlockingStub(channelBuilder.build());
}
示例15: setUp
import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
HealthService service = new HealthService(healthAggregator, healthIndicators);
String uniqueServerName = "Mock server for " + HealthService.class;
mockServer = InProcessServerBuilder
.forName(uniqueServerName).directExecutor().addService(service).build().start();
InProcessChannelBuilder channelBuilder =
InProcessChannelBuilder.forName(uniqueServerName).directExecutor();
stub = HealthServiceGrpc.newBlockingStub(channelBuilder.build());
}