You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,13 +125,14 @@ If you want to do that in any Spring Boot application, it should be sufficient *
125
125
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.
126
126
127
127
[[in-process-server]]
128
-
== InProcess Server
128
+
== In-Process Transport
129
129
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.
131
131
132
132
In this mode, the in-process server factory is auto-configured in *addition* to the regular server factory (e.g. Netty).
133
133
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.
An `InProcessGrpcServerFactory` picks up the `ServerInterceptorFilter` automatically.
171
+
An `InProcessGrpcServerFactory` picks up the `ServerInterceptorFilter` automatically, if it is present.
171
172
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:
172
173
173
174
[source,java]
@@ -238,10 +239,15 @@ A `GrpcExceptionHandler` can be used to handle exceptions of a specific type, re
238
239
== Testing
239
240
240
241
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.
243
244
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)
0 commit comments