-
Notifications
You must be signed in to change notification settings - Fork 83
Spring gRPC 1.1 Migration Guide
This document is meant to help you migrate your application to Spring gRPC 1.1.
|
Note
|
This is a preview draft of the migration guide. It will be completed when Spring gRPC 1.1 is released. |
The Spring Boot starters have moved from Spring gRPC into Spring Boot as follows:
From |
To |
|
|
|
|
|
Removed - just include both client and server starters |
|
Removed - see Servlet Server section below |
In addition there are now test starters shipped as part of Spring Boot:
Name |
|
|
To use your servlet container as a gRPC server you must now explicitly set the server.http2.enabled property to true and include the required dependencies as the org.springframework.grpc:spring-grpc-server-web-spring-boot-starter no longer exists.
Follow the steps in the Servlet Server section of the Spring Boot reference docs.
In Spring gRPC 1.0:
-
Applied to in-process servers
-
Not applied to regular servers
This is inconsistent with Spring Boot conventions so when migrating you should use a GrpcServerFactoryCustomizer to apply filters.
With Spring Boot there are only address (an InetAddress) and `port (an integer) properties available to configure gRPC.
The host property has not been migrated.
If you previously configured your project as follows:
spring:
grpc:
server:
address: 192.168.1.1:1234You should adapt it to:
spring:
grpc:
server:
address: 192.168.1.1
port: 1234Spring Boot introduces a GrpcServletRegistration instead of using DynamicRegistrationBean.
If you previously used a DynamicRegistrationBean to register your gRPC servlet, you should switch to GrpcServletRegistration so that auto-configuration can detect it.
Server properties have been restructured a little and you may need to adapt.
spring:
grpc:
server:
address: "*"
port: 9090
shutdown:
grace-period: 30s
inbound:
message:
max-size: 4m
metadata:
max-size: 8kb
inprocess:
name: "something"
keepalive:
time: 2h
timeout: 20s
permit:
time: 5m
without-calls: false
connection:
max-idle-time:
max-age:
grace-period: 30s
ssl:
enabled:
client-auth: optional
bundle: my-bundle
secure: true
servlet:
enabled:
validate-http2: true
health:
enabled:
include-overall-health: true
services:
validate-membership: true
service:
<name>:
include: *
exclude:
status:
order:
mapping:
up: serving
down: not-serving
scheduler:
enabled: true
period: 5s
delay: 5sspring:
grpc:
server:
address: "*:9090"
host:
port:
max-inbound-message-size:
max-inbound-metadata-size:
inprocess:
name:
keep-alive:
time:
timeout:
max-idle:
max-age:
max-age-grace:
permit-time:
permit-without-calls:
ssl:
enabled:
client-auth: optional
bundle: my-bundle
secure: true
health:
enabled:
actuator:
enabled:
update-overall-health:
update-rate:
update-initial-delay:
health-indicator-paths:Spring gRPC 1.0 Automatically scaned for .proto generated classes.
Spring Boot not longer does this and you should use explicit @ImportGrpcClients annotations.
Merging multiple defaultServiceConfig customizers is difficult when just using a GrpcChannelFactoryCustomizer because the last customizer wins.
To solve this, Spring Boot introduces a GrpcClientDefaultServiceConfigCustomizer that allows many customizers to mutate the defaultServiceConfig before it is set.
Client properties have been restructured a little and you may need to adapt.
spring:
grpc:
client:
channel:
<name>:
target:
user-agent:
bypass-certificate-validation:
inbound:
message:
max-size:
metadata:
max-size:
default:
deadline:
load-balancing-policy:
idle:
timeout:
keepalive:
time:
timeout:
without-calls: true
health:
enabled:
service-name:spring:
grpc:
client:
channels:
<name>:
address:
default-deadline:
default-load-balancing-policy:
enable-keep-alive:
health:
enabled:
service-name:
idle-timeout:
inherit-defaults:
keep-alive-time:
keep-alive-timeout:
keep-alive-without-calls:
max-inbound-message-size:
max-inbound-metadata-size:
negotiation-type:
secure:
service:config:
<key>: <value>
ssl:
user-agent:
default-channel:
channel-defaults:
defaultStubFactory:The following classes have been renamed:
-
@AutoConfigureInProcessTransport→@AutoConfigureTestGrpcTransport -
@LocalGrpcPort→@LocalGrpcServerPort
Tests now use a custom GrpcServerFactory to create in-process channels rather than using InProcessGrpcServerFactory.
This helps keep InProcessGrpcServerFactory for user code and allow better detection of then a factory is for test purposes.
The gRPC health check feature has been reworked to build directly on Spring Boot’s HealthIndicator classes rather than building on HTTP actuator endpoints.
This means that you can have health checking without needing actuator.
You may need to update your health properties to directly reference the indicators you wish to use. For example:
spring:
grpc:
server:
health:
service:
myservice:
include:
- db
- redisSee the Spring Boot gRPC health documentation for more details.
Security support has been simplified a little during the migration to Spring Boot. Please see the security section of the Spring Boot reference documentation for details.
Some SSL properties have been renamed or simplified.
You may need to update your application.properties or application.yaml file.
For details of the new properties please see the client SSL and server SSL documentation.