@Test void testConfigureServices() { final GrpcServerProperties properties = new GrpcServerProperties(); properties.setReflectionServiceEnabled(false); final NettyGrpcServerFactory serverFactory = new NettyGrpcServerFactory(properties, emptyList()); serverFactory.healthStatusManager = new HealthStatusManager(); serverFactory.addService(new GrpcServiceDefinition("test1", ProtoReflectionService.class, ProtoReflectionService.newInstance().bindService())); serverFactory.addService(new GrpcServiceDefinition("test2", ProtoReflectionService.class, ProtoReflectionService.newInstance().bindService())); final NettyServerBuilder serverBuilder = serverFactory.newServerBuilder(); assertEquals("Found duplicate service implementation: " + ServerReflectionGrpc.SERVICE_NAME, assertThrows(IllegalStateException.class, () -> serverFactory.configureServices(serverBuilder)) .getMessage()); }
protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescriptor().getName()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); serviceNames.add(ServerReflectionGrpc.getServiceDescriptor().getName()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); if (!serviceNames.add(serviceName)) { throw new IllegalStateException("Found duplicate service implementation: " + serviceName); } log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } }
AbstractGrpcServerFactory implements GrpcServerFactory { protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescriptor().getName()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); serviceNames.add(ServerReflectionGrpc.getServiceDescriptor().getName()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); if (!serviceNames.add(serviceName)) { throw new IllegalStateException("Found duplicate service implementation: " + serviceName); } log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } } }
AbstractGrpcServerFactory implements GrpcServerFactory { protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescriptor().getName()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); serviceNames.add(ServerReflectionGrpc.getServiceDescriptor().getName()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); if (!serviceNames.add(serviceName)) { throw new IllegalStateException("Found duplicate service implementation: " + serviceName); } log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } } AbstractGrpcServerFactory(final GrpcServerProperties properties,
            final List<GrpcServerConfigurer> serverConfigurers); }
AbstractGrpcServerFactory implements GrpcServerFactory { protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescriptor().getName()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); serviceNames.add(ServerReflectionGrpc.getServiceDescriptor().getName()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); if (!serviceNames.add(serviceName)) { throw new IllegalStateException("Found duplicate service implementation: " + serviceName); } log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } } AbstractGrpcServerFactory(final GrpcServerProperties properties,
            final List<GrpcServerConfigurer> serverConfigurers); @Override Server createServer(); @Override String getAddress(); @Override int getPort(); @Override void addService(final GrpcServiceDefinition service); @Override void destroy(); }
AbstractGrpcServerFactory implements GrpcServerFactory { protected void configureServices(final T builder) { final Set<String> serviceNames = new LinkedHashSet<>(); if (this.properties.isHealthServiceEnabled()) { builder.addService(this.healthStatusManager.getHealthService()); serviceNames.add(HealthGrpc.getServiceDescriptor().getName()); } if (this.properties.isReflectionServiceEnabled()) { builder.addService(ProtoReflectionService.newInstance()); serviceNames.add(ServerReflectionGrpc.getServiceDescriptor().getName()); } for (final GrpcServiceDefinition service : this.serviceList) { final String serviceName = service.getDefinition().getServiceDescriptor().getName(); if (!serviceNames.add(serviceName)) { throw new IllegalStateException("Found duplicate service implementation: " + serviceName); } log.info("Registered gRPC service: " + serviceName + ", bean: " + service.getBeanName() + ", class: " + service.getBeanClazz().getName()); builder.addService(service.getDefinition()); this.healthStatusManager.setStatus(serviceName, HealthCheckResponse.ServingStatus.SERVING); } } AbstractGrpcServerFactory(final GrpcServerProperties properties,
            final List<GrpcServerConfigurer> serverConfigurers); @Override Server createServer(); @Override String getAddress(); @Override int getPort(); @Override void addService(final GrpcServiceDefinition service); @Override void destroy();  }