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

Remove transcoding server #43

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/usr/bin/env bash

# format code
./gradlew spotlessApply > /dev/null

# generate configuration properties docs
./gradlew classes > /dev/null
./gradlew generateConfigurationPropertiesDocs > /dev/null

# escape {} in md
sed -i '' 's/{/\\{/g' build/configuration-properties.md

# add sidebar_position
sed -i '' '1i\
---\
sidebar_position: 40\
---\
\
' build/configuration-properties.md

cp -f build/configuration-properties.md website/docs/40-configuration-properties.md

git add -u
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[Documentation](https://danielliu1123.github.io/grpc-starter/)

[gRPC](https://grpc.io/) is a RPC framework, with support for robust features like
high-performance, multi-language support, concise service definition, streaming.
gRPC proves to be an ideal choice for building scalable and efficient microservice systems.
[gRPC](https://grpc.io/) is an RPC framework with robust features like high performance,
multi-language support, concise service definitions, and streaming.
It is an ideal choice for building scalable and efficient microservice systems.

This project provides out-of-the-box, highly extensible Spring Boot starters for gRPC ecosystem.
Make the integration of Spring Boot and gRPC feel seamless and native.
Expand Down
19 changes: 17 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.rodnansol:spring-configuration-property-documenter-gradle-plugin:${springConfigurationPropertyDocumenterVersion}"
}
}

plugins {
id "org.springframework.boot" version "${springBootVersion}" apply false
id "io.spring.dependency-management" version "${springDependencyManagementVersion}" apply false
Expand All @@ -15,9 +24,13 @@ allprojects {
apply plugin: "java"
apply plugin: "java-library"

sourceSets {
optionalSupport
}

java {
registerFeature("optionalSupport") {
usingSourceSet(sourceSets.main)
registerFeature("optionalSuppor") {
usingSourceSet(sourceSets.optionalSupport)
}
}

Expand Down Expand Up @@ -82,3 +95,5 @@ allprojects {
excludeFilter = file("${rootDir}/config/spotbugs/exclude.xml")
}
}

apply from: "${rootDir}/gradle/generate-configuration-properties-docs.gradle"
25 changes: 25 additions & 0 deletions examples/transcoding/webflux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1. Start the application

```shell
./gradlew :examples:transcoding:webflux:bootRun
```

2. Use HTTP and gRPC clients to access the `Unary` api

```shell
curl -X POST -d '{"requestMessage": "World!"}' http://localhost:8080/unary
```

```shell
grpcurl -plaintext -d '{"requestMessage": "World!"}' localhost:9090 transcoding.flux.SimpleService/UnaryRpc
```

3. Use HTTP and gRPC clients to access the `Server Streaming` api

```shell
curl http://localhost:8080/serverstreaming?requestMessage=World!
```

```shell
grpcurl -plaintext -d '{"requestMessage": "World!"}' localhost:9090 transcoding.flux.SimpleService/ServerStreamingRpc
```
25 changes: 25 additions & 0 deletions examples/transcoding/webmvc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1. Start the application

```shell
./gradlew :examples:transcoding:webmvc:bootRun
```

2. Use HTTP and gRPC clients to access the `Unary` api

```shell
curl -X POST -d '{"requestMessage": "World!"}' http://localhost:8080/unary
```

```shell
grpcurl -plaintext -d '{"requestMessage": "World!"}' localhost:9090 transcoding.mvc.SimpleService/UnaryRpc
```

3. Use HTTP and gRPC clients to access the `Server Streaming` api

```shell
curl http://localhost:8080/serverstreaming?requestMessage=World!
```

```shell
grpcurl -plaintext -d '{"requestMessage": "World!"}' localhost:9090 transcoding.mvc.SimpleService/ServerStreamingRpc
```
23 changes: 8 additions & 15 deletions examples/transcoding/webmvc/src/main/proto/simpleservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,25 @@ import "google/api/annotations.proto";

package transcoding.mvc;

// A simple service for test.
message SimpleRequest {
string requestMessage = 1;
}

message SimpleResponse {
string responseMessage = 1;
}

service SimpleService {
// Simple unary RPC.
rpc UnaryRpc (SimpleRequest) returns (SimpleResponse) {
option (google.api.http) = {
post: "/unary",
body: "*"
};
}

// Simple server-to-client streaming RPC.
rpc ServerStreamingRpc (SimpleRequest) returns (stream SimpleResponse) {
option (google.api.http) = {
get: "/serverstreaming"
};
}
}

// A simple request message type for test.
message SimpleRequest {
// An optional string message for test.
string requestMessage = 1;
}

// A simple response message type for test.
message SimpleResponse {
// An optional string message for test.
string responseMessage = 1;
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ springCloudContextVersion=4.1.3
# https://github.com/spring-gradle-plugins/dependency-management-plugin
springDependencyManagementVersion=1.1.5

# https://github.com/rodnansol/spring-configuration-property-documenter/blob/master/docs/modules/ROOT/pages/gradle-plugin.adoc
springConfigurationPropertyDocumenterVersion=0.7.1

# gRPC related
# https://github.com/google/protobuf-gradle-plugin
protobufGradlePluginVersion=0.9.4
Expand Down
54 changes: 54 additions & 0 deletions gradle/generate-configuration-properties-docs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apply plugin: "org.rodnansol.spring-configuration-property-documenter"

// see https://github.com/rodnansol/spring-configuration-property-documenter/blob/master/docs/modules/ROOT/pages/gradle-plugin.adoc#multi-module-multiple-sub-projects
tasks.register('generateConfigurationPropertiesDocs') {
dependsOn generateAndAggregateDocuments {
documentName = "Configuration Properties"
documentDescription = """
Configuration properties for the gRPC starter project.

This page was generated by [spring-configuration-property-documenter](https://github.com/rodnansol/spring-configuration-property-documenter/blob/master/docs/modules/ROOT/pages/gradle-plugin.adoc).
"""
type = "MARKDOWN"

metadataInputs {
metadata {
name = "grpc-client-boot-autoconfigure"
input = file("grpc-boot-autoconfigure/grpc-client-boot-autoconfigure")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-server-boot-autoconfigure"
input = file("grpc-boot-autoconfigure/grpc-server-boot-autoconfigure")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-metrics"
input = file("grpc-extensions/grpc-metrics")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-test"
input = file("grpc-extensions/grpc-test")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-tracing"
input = file("grpc-extensions/grpc-tracing")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-transcoding"
input = file("grpc-extensions/grpc-transcoding")
excludedGroups = ["Unknown group"]
}
metadata {
name = "grpc-validation"
input = file("grpc-extensions/grpc-validation")
excludedGroups = ["Unknown group"]
}
}

outputFile = new File("build/configuration-properties.md")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@ public class GrpcClientProperties implements InitializingBean {
public static final String PREFIX = "grpc.client";

/**
* Whether to enable gRPC client autoconfiguration, default {@code true}.
* Whether to enable gRPC client autoconfiguration, default true.
*/
private boolean enabled = true;
/**
* Default authority.
*
* <p> e.g. {@code localhost:8080}
* <p> e.g. localhost:8080 </p>
*/
private String authority;
/**
* Base packages to scan for gRPC stubs.
*
* <p> This value will merge with {@link EnableGrpcClients#basePackages}, only takes effect if {@link EnableGrpcClients#basePackages} is not set.
* <p> The advantage of using configuration is no need to introduce external annotations.
* <p> This value will merge with {@link EnableGrpcClients#basePackages}, only takes effect if {@link EnableGrpcClients#basePackages} is not set. </p>
*
* <p> The advantage of using configuration is no need to introduce external annotations. </p>
*/
private List<String> basePackages = new ArrayList<>();
/**
* Default max inbound message size, default value is {@code 4MB}.
* Default max inbound message size, default value is 4MB.
*
* @see DataSize
* @see GrpcUtil#DEFAULT_MAX_MESSAGE_SIZE
Expand All @@ -65,7 +66,7 @@ public class GrpcClientProperties implements InitializingBean {
*/
private DataSize maxOutboundMessageSize;
/**
* Default max metadata size, default value is {@code 8KB}.
* Default max metadata size, default value is 8KB.
*
* @see DataSize
* @see GrpcUtil#DEFAULT_MAX_HEADER_LIST_SIZE
Expand All @@ -80,7 +81,7 @@ public class GrpcClientProperties implements InitializingBean {
*/
private InProcess inProcess;
/**
* Channel shutdown timeout in milliseconds, default value is {@code 5000}.
* Channel shutdown timeout in milliseconds, default value is 5000.
*/
private Long shutdownTimeout = 5000L;
/**
Expand All @@ -92,7 +93,7 @@ public class GrpcClientProperties implements InitializingBean {
*/
private Retry retry;
/**
* Deadline after in milliseconds, default value is {@code 5000}.
* Deadline after in milliseconds, default value is 5000.
*
* @see AbstractStub#withDeadline(Deadline)
* @since 3.2.0
Expand All @@ -113,7 +114,7 @@ public class GrpcClientProperties implements InitializingBean {
*/
private Refresh refresh = new Refresh();
/**
* Whether to enable warn unused config, default {@code true}.
* Whether to enable warn unused config, default true.
*/
private boolean warnUnusedConfigEnabled = true;

Expand Down Expand Up @@ -181,43 +182,43 @@ public static class Channel {
/**
* gRPC stub classes to apply this channel.
*
* <p> This is a more IDE-friendly alternative to {@link #services}/{@link #stubs}, using classes first if both set.
* <p> This is a more IDE-friendly alternative to {@link #services}/{@link #stubs}, using classes first if both set. </p>
*
* <p> The priority is classes > {@link #stubs} > {@link #services}.
* <p> The priority is classes > {@link #stubs} > {@link #services}. </p>
*/
@SuppressWarnings("rawtypes")
private List<Class<? extends AbstractStub>> classes = new ArrayList<>();
/**
* gRPC stubs to apply this channel.
*
* <p> Support Ant-style patterns.
* <p> Support Ant-style patterns. </p>
*
* <p> e.g. {@link HealthGrpc.HealthBlockingStub} can be identified by
* <p> e.g. {@link HealthGrpc.HealthBlockingStub} can be identified by </p>
* <ul>
* <li> {@code io.grpc.health.v1.HealthGrpc.HealthBlockingStub} (Class canonical name) </li>
* <li> {@code io.grpc.health.v1.HealthGrpc$HealthBlockingStub} (Class name) </li>
* <li> {@code io.grpc.**.*BlockingStub} (<a href="https://stackoverflow.com/questions/2952196/ant-path-style-patterns">Ant style pattern</a>) </li>
* <li> io.grpc.health.v1.HealthGrpc.HealthBlockingStub (Class canonical name) </li>
* <li> io.grpc.health.v1.HealthGrpc$HealthBlockingStub (Class name) </li>
* <li> io.grpc.**.*BlockingStub (<a href="https://stackoverflow.com/questions/2952196/ant-path-style-patterns">Ant style pattern</a>) </li>
* </ul>
*
* <p> This is a more flexible alternative to {@link #classes}, using {@link #classes} first if both set.
* <p> This is a more flexible alternative to {@link #classes}, using {@link #classes} first if both set. </p>
*
* <p> The priority is {@link #classes} > stubs > {@link #services}.
* <p> The priority is {@link #classes} > stubs > {@link #services}. </p>
*/
private List<String> stubs = new ArrayList<>();
/**
* gRPC service names to apply this channel.
*
* <p> Support Ant-style patterns.
* <p> Support Ant-style patterns. </p>
*
* <p> e.g. {@link HealthGrpc.HealthBlockingStub} can be identified by
* <p> e.g. {@link HealthGrpc.HealthBlockingStub} can be identified by </p>
* <ul>
* <li> {@code grpc.health.v1.Health} (SERVICE_NAME field in {@link HealthGrpc}) </li>
* <li> {@code grpc.health.v*.**} (<a href="https://stackoverflow.com/questions/2952196/ant-path-style-patterns">Ant style pattern</a>) </li>
* <li> grpc.health.v1.Health (SERVICE_NAME field in {@link HealthGrpc}) </li>
* <li> grpc.health.v*.** (<a href="https://stackoverflow.com/questions/2952196/ant-path-style-patterns">Ant style pattern</a>) </li>
* </ul>
*
* <p> This is a more flexible alternative to {@link #classes}, using {@link #classes} first if both set.
* <p> This is a more flexible alternative to {@link #classes}, using {@link #classes} first if both set. </p>
*
* <p> The priority is {@link #classes} > {@link #stubs} > services.
* <p> The priority is {@link #classes} > {@link #stubs} > services. </p>
*
* @see AntPathMatcher
*/
Expand Down Expand Up @@ -245,7 +246,7 @@ public static class InProcess {
/**
* In-process client name.
*
* <p> If set, will create an in-process channel by default, usually for testing.
* <p> If set, will create an in-process channel by default, usually for testing. </p>
*/
private String name;
}
Expand Down Expand Up @@ -285,9 +286,9 @@ public static class Refresh {
public static final String PREFIX = GrpcClientProperties.PREFIX + ".refresh";

/**
* Whether to enable refresh grpc clients, default {@code false}.
* Whether to enable refresh grpc clients, default false.
*
* <p> NOTE: this feature needs {@code spring-cloud-context} dependency in the classpath.
* <p> NOTE: this feature needs 'spring-cloud-context' dependency in the classpath. </p>
*/
private boolean enabled = false;
}
Expand Down
Loading