Skip to content

Commit bfaf431

Browse files
committed
Update service filter doc example
This commit updates the code example in service filter section of the docs how to filter out the "health service" and "reflection service" which might be more useful (e.g. for the in-process server). See #207 Signed-off-by: Chris Bono <[email protected]>
1 parent 4daec6a commit bfaf431

File tree

1 file changed

+4
-3
lines changed
  • spring-grpc-docs/src/main/antora/modules/ROOT/pages

1 file changed

+4
-3
lines changed

spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ The easiest way to activate it is to simply add a Spring `@Service` annotation t
1717
All available `BindableService` beans are bound to all running gRPC servers.
1818
However, you can register a `ServerServiceDefinitionFilter` bean to decide which services are bound to which server factories.
1919

20-
The following example prevents the `my-unwanted-service` service from being applied to any servers created by the server factory that the filter is applied to.
20+
The following example prevents the "health" and "reflection" service from being bound to the server created by the server factory that the filter is applied to (e.g. the `InProcessGrpcServerFactory`).
2121

2222
[source,java]
2323
----
2424
@Bean
2525
ServerServiceDefinitionFilter myServiceFilter() {
26-
return (serviceDefinition, __) ->
27-
!(serviceDefinition.getServiceDescriptor().getName().equals("my-unwanted-service"));
26+
return (serviceDefinition, __) ->
27+
!Set.of(HealthGrpc.SERVICE_NAME, ServerReflectionGrpc.SERVICE_NAME)
28+
.contains(serviceDefinition.getServiceDescriptor().getName());
2829
}
2930
----
3031

0 commit comments

Comments
 (0)