Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fine-grained starter modules #106

Merged
merged 10 commits into from
Feb 12, 2025
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<module>spring-grpc-test</module>
<module>spring-grpc-spring-boot-autoconfigure</module>
<module>spring-grpc-spring-boot-starter</module>
<module>spring-grpc-client-spring-boot-starter</module>
<module>spring-grpc-server-spring-boot-starter</module>
<module>spring-grpc-server-web-spring-boot-starter</module>
<module>samples</module>
</modules>

Expand Down
12 changes: 2 additions & 10 deletions samples/grpc-tomcat-secure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@
<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -61,10 +57,6 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-servlet-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-test</artifactId>
Expand Down Expand Up @@ -180,4 +172,4 @@
</pluginRepositories>


</project>
</project>
12 changes: 2 additions & 10 deletions samples/grpc-tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,12 @@
<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-servlet-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down Expand Up @@ -185,4 +177,4 @@
</pluginRepositories>


</project>
</project>
42 changes: 42 additions & 0 deletions spring-grpc-client-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc</artifactId>
<version>0.4.0-SNAPSHOT</version>
</parent>
<artifactId>spring-grpc-client-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<name>Spring gRPC Client Spring Boot Starter</name>
<description>Spring gRPC Client Spring Boot Starter</description>

<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>

</project>
16 changes: 10 additions & 6 deletions spring-grpc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
<artifactId>spring-security-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-core</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
Expand All @@ -50,6 +59,7 @@
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
Expand Down Expand Up @@ -83,12 +93,6 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
15 changes: 15 additions & 0 deletions spring-grpc-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@
<artifactId>spring-grpc-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-client-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-server-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Utilities -->
<dependency>
<groupId>org.springframework.grpc</groupId>
Expand Down
18 changes: 5 additions & 13 deletions spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,15 @@ dependencies {
== Servlet Server

Any servlet container can be used to run a gRPC server.
Spring gRPC includes autoconfiguration that configures the server to use the servlet container if it detects that it is in a web application, so all you have to do is include `spring-boot-starter-web` and the `grpc-servlet` dependnecy in your application.
Spring gRPC includes autoconfiguration that configures the server to use the servlet container if it detects that it is in a web application.
Spring gRPC also provides a convenience starter that includes the required dependencies (`spring-boot-starter-web` and the `grpc-servlet-jakarta`) for this scenario.
So all you have to do is include the `spring-boot-starter-web` dependency as follows:

[source,xml]
----
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-servlet-jakarta</artifactId>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
</dependency>
----

Expand All @@ -82,9 +76,7 @@ For Gradle users
[source,gradle]
----
dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.grpc:spring-grpc-spring-boot-starter"
implementation "io.grpc:grpc-servlet-jakarta"
implementation "org.springframework.grpc:spring-grpc-server-web-spring-boot-starter"
}
----

Expand Down
28 changes: 7 additions & 21 deletions spring-grpc-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,13 @@
[[what-s-new-in-0-4-0-since-0-3-0]]
== What's New in 0.4.0 Since 0.3.0

This section covers the changes made from version 0.2.0 to version 0.3.0.
This section covers the changes made from version 0.3.0 to version 0.4.0.

=== Channel Factory
The `GrpcChannelFactory` has a new interface and its methods now return a `Channel` (instead of a `ChannelBuilder`).
The `createChannel()` method is overloaded with a new method that accepts a `ChannelBuilderOptions` which can be used to configure the channel before it is created.
=== Fine-grained starter modules
The following fine-grained Spring Boot starter modules have been added:

=== Client Side Observability
A gRPC client will generate a new span for each RPC call. The span will be automatically closed when the call is completed.
- `spring-grpc-client-spring-boot-starter` provides Netty gRPC client
- `spring-grpc-server-spring-boot-starter` provides Netty gRPC server
- `spring-grpc-server-spring-boot-starter` provides Servlet gRPC server

=== Security in Servlet Containers
Spring Security works with gRPC servers running in servlet containers. You can use all your favourite Spring Security features to secure your gRPC services.

[[what-s-new-in-0-3-0-since-0-2-0]]
== What's New in 0.3.0 Since 0.2.0

This section covers the changes made from version 0.2.0 to version 0.3.0.

=== Client Interceptors
You can now add xref:client.adoc#client-interceptor[Client Interceptors] to created gRPC channels.

=== Breaking Changes

==== GrpcChannelConfigurer renamed
The `GrpcChannelConfigurer` has been renamed to `GrpcChannelBuilderCustomizer` to more accurately represent its purpose and be consistent with the server-side terminology.
The current coarse-grained starter `spring-grpc-spring-boot-starter` still provides Netty gRPC server and client.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
|spring.grpc.server.port | `+++9090+++` | Server port to listen on. When the value is 0, a random available port is selected. The default is 9090.
|spring.grpc.server.reflection.enabled | `+++true+++` | Whether to enable Reflection on the gRPC server.
|spring.grpc.server.security.csrf.enabled | `+++false+++` | Whether to enable CSRF protection on gRPC requests.
|spring.grpc.server.servlet.enabled | `+++true+++` | Whether to use a servlet server in a servlet-based web application (set to false to force a native gRPC server).
|spring.grpc.server.servlet.enabled | `+++true+++` | Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be forced.
|spring.grpc.server.shutdown-grace-period | `+++30s+++` | Maximum time to wait for the server to gracefully shutdown. When the value is negative, the server waits forever. When the value is 0, the server will force shutdown immediately. The default is 30 seconds.
|spring.grpc.server.ssl.bundle | | SSL bundle name.
|spring.grpc.server.ssl.client-auth | `+++none+++` | Client authentication mode.
Expand Down
43 changes: 43 additions & 0 deletions spring-grpc-server-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc</artifactId>
<version>0.4.0-SNAPSHOT</version>
</parent>
<artifactId>spring-grpc-server-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<name>Spring gRPC Server (Netty) Spring Boot Starter</name>
<description>Spring gRPC Server (Netty) Spring Boot Starter</description>

<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>

</project>
32 changes: 32 additions & 0 deletions spring-grpc-server-web-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc</artifactId>
<version>0.4.0-SNAPSHOT</version>
</parent>
<artifactId>spring-grpc-server-web-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<name>Spring gRPC Servlet Server Spring Boot Starter</name>
<description>Spring gRPC Servlet Server Spring Boot Starter</description>

<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-servlet-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>

</project>
11 changes: 11 additions & 0 deletions spring-grpc-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-core</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -72,6 +73,16 @@
<artifactId>grpc-services</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
"name": "spring.grpc.server.servlet.enabled",
"type": "java.lang.Boolean",
"description": "Whether to use a servlet server in a servlet-based web application (set to false to force a native gRPC server).",
"description": "Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be forced.",
"defaultValue": true
},
{
Expand Down
15 changes: 4 additions & 11 deletions spring-grpc-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,17 @@
</parent>
<artifactId>spring-grpc-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<name>Spring gRPC Spring Boot Starter</name>
<description>Spring gRPC Spring Boot Starter</description>
<name>Spring gRPC Server and Client Spring Boot Starter</name>
<description>Spring gRPC Server and Client Spring Boot Starter</description>

<dependencies>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-core</artifactId>
<version>${project.version}</version>
<artifactId>spring-grpc-client-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.grpc</groupId>
<artifactId>spring-grpc-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<artifactId>spring-grpc-server-spring-boot-starter</artifactId>
</dependency>
</dependencies>

Expand Down
Loading
Loading