Skip to content

Commit

Permalink
Merge branch 'master' into support-AuthenticationManagerResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrabisajad committed Apr 1, 2024
2 parents 18bd3e2 + de71ce3 commit a5904ab
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 43 deletions.
14 changes: 7 additions & 7 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ README: [English](README.md) | [中文](README-zh-CN.md)

## 版本

最新版本是 `2.15.0.RELEASE` 它能跟 Spring-Boot `2.7.16` 和 Spring-Cloud `2021.0.8` 搭配使用。 但它也与各种其他版本兼容。 我们的 [文档](https://yidongnan.github.io/grpc-spring-boot-starter/en/versions.html) 中可以找到所有版本及其相应的库版本的概览。
最新版本是 `3.0.0.RELEASE` 它能跟 Spring-Boot `3.2.2` 和 Spring-Cloud `2023.0.0` 搭配使用。 但它也与各种其他版本兼容。 我们的 [文档](https://yidongnan.github.io/grpc-spring-boot-starter/en/versions.html) 中可以找到所有版本及其相应的库版本的概览。

**注意:** 该项目也可以在没有 Spring-Boot 的情况下使用,但是您需要手动配置一些 bean。

Expand All @@ -54,15 +54,15 @@ README: [English](README.md) | [中文](README-zh-CN.md)
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

使用 Gradle 添加依赖:

````gradle
dependencies {
implementation 'net.devh:grpc-spring-boot-starter:2.15.0.RELEASE'
implementation 'net.devh:grpc-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand All @@ -74,15 +74,15 @@ dependencies {
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

使用 Gradle 添加依赖项:

````gradle
dependencies {
implementation 'net.devh:grpc-server-spring-boot-starter:2.15.0.RELEASE'
implementation 'net.devh:grpc-server-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand Down Expand Up @@ -114,15 +114,15 @@ public class GrpcServerService extends GreeterGrpc.GreeterImplBase {
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

使用 Gradle 添加依赖项:

````gradle
dependencies {
compile 'net.devh:grpc-client-spring-boot-starter:2.15.0.RELEASE'
compile 'net.devh:grpc-client-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Survey - gRPC/Spring

Dear gRPC/Spring users, in order to enhance the user experience of
grpc-ecosystem/grpc-spring, we have developed [this survey](https://docs.google.com/forms/d/e/1FAIpQLSfHgvh_Z0_wwX7JQLERanJ-AAXjiKh23_kSI3Rl5mnKVQ8Bpw/viewform?resourcekey=0-mEilI6lFvIfVXiUniEyCog) as a means of
establishing a direct line of communication. Your feedback is highly appreciated.

# gRPC Spring Boot Starter

[![Build master branch](https://github.com/grpc-ecosystem/grpc-spring/workflows/Build%20master%20branch/badge.svg)](https://github.com/grpc-ecosystem/grpc-spring/actions)
Expand All @@ -11,7 +17,7 @@

README: [English](README.md) | [中文](README-zh-CN.md)

**Documentation:** [English](https://yidongnan.github.io/grpc-spring-boot-starter/en/) | [中文](https://yidongnan.github.io/grpc-spring-boot-starter/zh-CN/)
**Documentation:** [English](https://grpc-ecosystem.github.io/grpc-spring/en/) | [中文](https://grpc-ecosystem.github.io/grpc-spring/zh-CN/)

## Features

Expand Down Expand Up @@ -50,7 +56,7 @@ README: [English](README.md) | [中文](README-zh-CN.md)

## Versions

The latest version is `2.15.0.RELEASE` it was compiled with spring-boot `2.7.16` and spring-cloud `2021.0.8`
The latest version is `3.0.0.RELEASE` it was compiled with spring-boot `3.2.2` and spring-cloud `2023.0.0`
but it is also compatible with a large variety of other versions.
An overview of all versions and their respective library versions can be found in our [documentation](https://yidongnan.github.io/grpc-spring-boot-starter/en/versions.html).

Expand All @@ -66,15 +72,15 @@ To add a dependency using Maven, use the following:
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

To add a dependency using Gradle:

````gradle
dependencies {
implementation 'net.devh:grpc-spring-boot-starter:2.15.0.RELEASE'
implementation 'net.devh:grpc-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand All @@ -86,15 +92,15 @@ To add a dependency using Maven, use the following:
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

To add a dependency using Gradle:

````gradle
dependencies {
implementation 'net.devh:grpc-server-spring-boot-starter:2.15.0.RELEASE'
implementation 'net.devh:grpc-server-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand Down Expand Up @@ -128,15 +134,15 @@ To add a dependency using Maven, use the following:
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-client-spring-boot-starter</artifactId>
<version>2.15.0.RELEASE</version>
<version>3.0.0.RELEASE</version>
</dependency>
````

To add a dependency using Gradle:

````gradle
dependencies {
compile 'net.devh:grpc-client-spring-boot-starter:2.15.0.RELEASE'
compile 'net.devh:grpc-client-spring-boot-starter:3.0.0.RELEASE'
}
````

Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ buildscript {
}
}
ext {
projectVersion = '3.0.0-SNAPSHOT'
projectVersion = '3.0.0.RELEASE'

// https://github.com/grpc/grpc-java/releases
grpcVersion = '1.60.1'

// https://github.com/google/guava/releases
guavaVersion = '33.0.0-jre'
guavaVersion = '33.1.0-jre'
// https://github.com/protocolbuffers/protobuf/releases
protobufVersion = '3.25.2'
protobufVersion = '3.25.3'
protobufGradlePluginVersion = '0.9.4'

// https://github.com/spring-projects/spring-boot/releases
springBootVersion = '3.2.2'
springBootVersion = '3.2.4'
// https://github.com/spring-cloud/spring-cloud-release/releases
springCloudVersion = '2023.0.0'
// https://github.com/alibaba/spring-cloud-alibaba/releases
springCloudAlibabaNacosVersion = '2022.0.0.0'

lombokPluginVersion = '8.4'
versioningPluginVersion = '3.0.0'
lombokPluginVersion = '8.6'
versioningPluginVersion = '3.1.0'
versionsPluginVersion = '0.51.0'

// https://github.com/JetBrains/kotlin/releases
kotlinVersion = "1.9.22"
kotlinVersion = "1.9.23"
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ if (hasProperty('buildScan')) {
wrapper {
// Update using:
// ./gradlew wrapper --gradle-version=8.4 --distribution-type=bin
gradleVersion = '8.5'
gradleVersion = '8.6'
}

def buildTimeAndDate = OffsetDateTime.now()
Expand Down
2 changes: 1 addition & 1 deletion docs/en/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Current version.

| Version | spring-boot | spring-cloud | gRPC | Date |
|:-------:|:-----------:|:------------:|:------:|----------:|
| 3.0.0\* | 3.1.4 | 2022.0.4 | 1.58.0 | Nov, 2023 |
| 3.0.0 | 3.2.2 | 2023.0.0 | 1.60.1 | Feb, 2024 |

(\* Future versions)

Expand Down
6 changes: 3 additions & 3 deletions docs/zh-CN/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

当前版本。

| 版本 | spring-boot | spring-cloud | gRPC | 日期 |
|:------:|:-----------:|:------------:|:------:|---------:|
| 3.0.0* | 3.1.4 | 2022.0.4 | 1.58.0 | 2023年9月 |
| 版本 | spring-boot | spring-cloud | gRPC | 日期 |
|:-----:|:-----------:|:------------:|:------:|--------:|
| 3.0.0 | 3.2.2 | 2023.0.0 | 1.60.1 | 2024年2月 |

(\* 未来的版本)

Expand Down
4 changes: 3 additions & 1 deletion examples/grpc-observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ The backend microservice will

- listen on the TCP port 9091 for the gRPC calls from the frontend microservice.
- listen on the TCP port 8081 for the Prometheus scrape requests.
The frontend microservice will

The frontend microservice will

- send the unary/client streaming/server streaming/bidi streaming calls to the
backend microservices via TCP port 9091.
- listen on the TCP port 8080 for the Prometheus scrape requests.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected boolean isNonNullAndNonBlank(final String value) {
}

/**
* Configures limits such as max message sizes that should be used by the channel.
* Configures limits such as max message or metadata sizes that should be used by the channel.
*
* @param builder The channel builder to configure.
* @param name The name of the client to configure.
Expand All @@ -245,6 +245,10 @@ protected void configureLimits(final T builder, final String name) {
if (maxInboundMessageSize != null) {
builder.maxInboundMessageSize((int) maxInboundMessageSize.toBytes());
}
final DataSize maxInboundMetadataSize = properties.getMaxInboundMetadataSize();
if (maxInboundMetadataSize != null) {
builder.maxInboundMetadataSize((int) maxInboundMetadataSize.toBytes());
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,43 @@ public void setMaxInboundMessageSize(final DataSize maxInboundMessageSize) {
}
}

@DataSizeUnit(DataUnit.BYTES)
private DataSize maxInboundMetadataSize = null;

/**
* Sets the maximum size of metadata in bytes allowed to be received. If not set ({@code null}) then it will default
* to gRPC's default. The default is implementation-dependent, but is not generally less than 8 KiB and may be
* unlimited. If set to {@code -1} then it will use the highest possible limit (not recommended). Integer.MAX_VALUE
* disables the enforcement.
*
* @return The maximum size of metadata in bytes allowed to be received or null if the default should be used.
*
* @see ManagedChannelBuilder#maxInboundMetadataSize(int) (int)
*/
public DataSize getMaxInboundMetadataSize() {
return maxInboundMetadataSize;
}

/**
* Sets the maximum size of metadata in bytes allowed to be received. If not set ({@code null}) then it will
* default.The default is implementation-dependent, but is not generally less than 8 KiB and may be unlimited. If
* set to {@code -1} then it will use the highest possible limit (not recommended). Integer.MAX_VALUE disables the
* enforcement.
*
* @param maxInboundMetadataSize The new maximum size of metadata in bytes allowed to be received. {@code -1} for
* max possible. Null to use the gRPC's default.
*
* @see ManagedChannelBuilder#maxInboundMetadataSize(int) (int)
*/
public void setMaxInboundMetadataSize(DataSize maxInboundMetadataSize) {
if (maxInboundMetadataSize == null || maxInboundMetadataSize.toBytes() >= 0) {
this.maxInboundMetadataSize = maxInboundMetadataSize;
} else if (maxInboundMetadataSize.toBytes() == -1) {
this.maxInboundMetadataSize = DataSize.ofBytes(Integer.MAX_VALUE);
} else {
throw new IllegalArgumentException("Unsupported maxInboundMetadataSize: " + maxInboundMetadataSize);
}
}
// --------------------------------------------------

private Boolean fullStreamDecompression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
"sourceType": "net.devh.boot.grpc.client.config.GrpcChannelProperties",
"description": "The maximum message size allowed to be received by the channel.\nIf not set (null) then it will default to gRPC's default.\nIf set to -1 then it will use the highest possible limit (not recommended)."
},
{
"name": "grpc.client.GLOBAL.max-inbound-metadata-size",
"type": "org.springframework.util.unit.DataSize",
"sourceType": "net.devh.boot.grpc.client.config.GrpcChannelProperties",
"description": "the maximum size of metadata in bytes allowed to be received. \nIf not set (null) then it will default to gRPC's default. \nIf set to {@code -1} then it will use the highest possible limit (not recommended)."
},
{
"name": "grpc.client.GLOBAL.negotiation-type",
"type": "net.devh.boot.grpc.client.config.NegotiationType",
Expand Down Expand Up @@ -158,4 +164,4 @@
"description": "The path to the trusted certificate collection.\nIf not set (null) it will use the system's default collection (Default).\nThis collection will be used to verify server certificates."
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
@ExtendWith(SpringExtension.class)
@SpringBootTest(properties = {
"grpc.client.test.keepAliveTime=42m",
"grpc.client.test.maxInboundMessageSize=5MB"
"grpc.client.test.maxInboundMessageSize=5MB",
"grpc.client.test.maxInboundMetadataSize=3MB"
})
class GrpcChannelPropertiesGivenUnitTest {

Expand All @@ -45,6 +46,7 @@ void test() {
final GrpcChannelProperties properties = this.grpcChannelsProperties.getChannel("test");
assertEquals(Duration.ofMinutes(42), properties.getKeepAliveTime());
assertEquals(DataSize.ofMegabytes(5), properties.getMaxInboundMessageSize());
assertEquals(DataSize.ofMegabytes(3), properties.getMaxInboundMetadataSize());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
@ExtendWith(SpringExtension.class)
@SpringBootTest(properties = {
"grpc.client.test.keepAliveTime=42",
"grpc.client.test.maxInboundMessageSize=5242880"
"grpc.client.test.maxInboundMessageSize=5242880",
"grpc.client.test.maxInboundMetadataSize=3145728"
})
class GrpcChannelPropertiesNoUnitTest {

Expand All @@ -45,6 +46,7 @@ void test() {
final GrpcChannelProperties properties = this.grpcChannelsProperties.getChannel("test");
assertEquals(Duration.ofSeconds(42), properties.getKeepAliveTime());
assertEquals(DataSize.ofMegabytes(5), properties.getMaxInboundMessageSize());
assertEquals(DataSize.ofMegabytes(3), properties.getMaxInboundMetadataSize());
}

}

0 comments on commit a5904ab

Please sign in to comment.