Skip to content

Commit becf4a3

Browse files
committed
Clarify in-process set up for tests
1 parent 49307ff commit becf4a3

File tree

1 file changed

+13
-7
lines changed
  • spring-grpc-docs/src/main/antora/modules/ROOT/pages

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ If you want to do that in any Spring Boot application, it should be sufficient *
125125
This dependency is only provided by the `spring-grpc-server-web-spring-boot-starter` (or if you include it explicitly yourself), but if you need to be explicit you can set `spring.grpc.server.servlet.enabled=false` in your application configuration.
126126

127127
[[in-process-server]]
128-
== InProcess Server
128+
== In-Process Transport
129129

130-
You can run an in-process server (i.e. not listening on a network port) by including the `io.grpc.grpc-inprocess` dependency on your classpath and specifying the `spring.grpc.server.inprocess.name` property which is used as the identity of the server for clients to connect to.
130+
You can run an in-process server (i.e. not listening on a network port) by including the `io.grpc:grpc-inprocess` dependency on your classpath and specifying the `spring.grpc.server.inprocess.name` property which is used as the identity of the server for clients to connect to.
131131

132132
In this mode, the in-process server factory is auto-configured in *addition* to the regular server factory (e.g. Netty).
133133

134-
NOTE: To use the inprocess server the channel target must be set to `in-process:<in-process-name>`
134+
NOTE: In application code, to connect a client to the inprocess server the channel target can be set to `in-process:<in-process-name>`.
135+
In tests, if you are using only the in-process transport (see <<Testing,Testing>>), the autoconfigured `GrpcChannelFactory` will automatically connect to the in-process server without any special configuration.
135136

136137

137138
[[server-interceptor]]
@@ -167,7 +168,7 @@ ServerInterceptorFilter myInterceptorFilter() {
167168
}
168169
----
169170

170-
An `InProcessGrpcServerFactory` picks up the `ServerInterceptorFilter` automatically.
171+
An `InProcessGrpcServerFactory` picks up the `ServerInterceptorFilter` automatically, if it is present.
171172
Any other server factory will require you to provide a `GrpcServerFactoryCustomizer` in which you can modify the factory by adding a filter, as shown in the following example:
172173

173174
[source,java]
@@ -238,10 +239,15 @@ A `GrpcExceptionHandler` can be used to handle exceptions of a specific type, re
238239
== Testing
239240

240241
If you include `spring-grpc-test` in your project, your gRPC server in a `@SpringBootTest` can be started in-process (i.e. not listening on a network port) by enabling the in-process server.
241-
All clients that connect to any server via the autoconfigured `GrpcChannelFactory` will be able to connect to it.
242-
You can switch the in-process server on by setting `spring.grpc.test.inprocess.enabled` to `true` or by adding the `@AutoConfigureInProcessTransport` annotation to your `@SpringBootTest` class.
242+
Additionally the `grpc-inprocess` dependency must be present on the classpath (which is automatic if you already depend on `spring-grpc-test``).
243+
All clients that connect to any server via the autoconfigured `GrpcChannelFactory` will be able to connect to it instead.
243244

244-
NOTE: When the in-process server is run in test mode (as opposed to <<in-process-server,running normally>>) it replaces the regular server and channel factories (e.g. Netty)
245+
The in-process transport is an opt-in feature, so it requires an explicit configuration.
246+
You can switch it on by setting `spring.grpc.test.inprocess.enabled` to `true` or by adding the `@AutoConfigureInProcessTransport` annotation to your `@SpringBootTest` class.
247+
There is no need to set `spring.grpc.server.inprocess.name` as that is done automatically.
248+
Using the annotation is equivalent to setting the "enabled" property to true, and in addition marking the in-process transport as "exclusive", meaning that no other transport will be used.
249+
250+
NOTE: When the in-process server is run in test mode using `@AutoConfigureInProcessTransport` (as opposed to <<in-process-server,running in an application>>) it replaces the regular server and channel factories (e.g. Netty)
245251

246252

247253
== Security

0 commit comments

Comments
 (0)