当前位置: 首页>>代码示例>>Java>>正文


Java InProcessServerBuilder类代码示例

本文整理汇总了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);
        }
    };
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:19,代码来源:GrpcServerHostInProcessEndToEndTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:20,代码来源:_ProfileInfoServiceIntTest.java

示例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();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:26,代码来源:GrpcRemoteCacheTest.java

示例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();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:27,代码来源:GrpcServerRule.java

示例5: startServer

import io.grpc.inprocess.InProcessServerBuilder; //导入依赖的package包/类
public void startServer() throws Exception {
    server = InProcessServerBuilder
            .forName("GradleProof")
            .addService(this)
            .build()
            .start();
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:8,代码来源:GradleProof.java

示例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();
    }
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:39,代码来源:SessionIdTest.java

示例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();
    }
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:30,代码来源:SessionIdTest.java

示例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();
    }
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:29,代码来源:PerSessionServiceTest.java

示例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();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:31,代码来源:BuildFarmServerTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_JWTServiceIntTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_MetricServiceIntTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_LoggersServiceIntTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_EnvironmentServiceIntTest.java

示例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());
}
 
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:11,代码来源:_HealthServiceIntTest.java


注:本文中的io.grpc.inprocess.InProcessServerBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。