https://github.com/linux-china/reactive-grpc-demo
gRPC with reactive Reactor
https://github.com/linux-china/reactive-grpc-demo
grpc reactive spring-boot
Last synced: about 1 year ago
JSON representation
gRPC with reactive Reactor
- Host: GitHub
- URL: https://github.com/linux-china/reactive-grpc-demo
- Owner: linux-china
- Created: 2019-03-12T19:11:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-05T03:16:49.000Z (over 1 year ago)
- Last Synced: 2025-04-02T02:51:13.155Z (about 1 year ago)
- Topics: grpc, reactive, spring-boot
- Language: Java
- Size: 83 KB
- Stars: 6
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Reactive gRPC Spring Boot Demo
==============================
Spring Boot Application with reactive gRPC support backbone by https://github.com/salesforce/reactive-grpc and https://github.com/LogNet/grpc-spring-boot-starter
### Development
* Modify protobuf-maven-plugin with 'reactor-grpc' protocPlugin support
```xml
org.xolstice.maven.plugins
protobuf-maven-plugin
0.6.1
com.google.protobuf:protoc:${protobuf-java.version}:exe:${os.detected.classifier}
grpc-java
io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
reactor-grpc
com.salesforce.servicelibs
reactor-grpc
${reactive-grpc.version}
com.salesforce.reactorgrpc.ReactorGrpcGenerator
compile
compile-custom
```
* Implement gRPC service to extend reactive class
```
@GRpcService
public class ReactiveAccountServiceGrpcImpl extends ReactorAccountServiceGrpc.AccountServiceImplBase {
@Autowired
private AccountService accountService;
@Override
public Mono findAccountById(Mono request) {
return request.map(GetAccountRequest::getId)
.flatMap(accountService::findById)
.map(AccountMapper.INSTANCE::pojoToProtobuf);
}
}
```
* Start Spring Boot application and test with evans
```
evans src/main/proto/account.proto
```
### Mapper between domain model and Protobuf message
Please refer MapStruct http://mapstruct.org
### References
* Reactive gPRC:
* Spring Boot starter module for gRPC framework:
* Evans:
* gRPCurl: Like cURL, but for gRPC https://github.com/fullstorydev/grpcurl
* grpcui: web UI for gRPC https://github.com/fullstorydev/grpcui
* xDS-Based Global Load Balancing: https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md
* Stop Breaking the Proto! Designing for Change in Microservices World https://www.youtube.com/watch?v=hbxOO2wnA1Y&list=PLj6h78yzYM2NN72UX_fdmc5CZI-D5qfJL&index=13
* Practical API Design at Netflix, Part 1: Using Protobuf FieldMask: https://netflixtechblog.com/practical-api-design-at-netflix-part-1-using-protobuf-fieldmask-35cfdc606518
* Protobuf Field Masks: https://pinkiepractices.com/posts/protobuf-field-masks/
* protoc-gen-doc: Documentation generator plugin for Google Protocol Buffers https://github.com/pseudomuto/protoc-gen-doc
* Various gRPC benchmarks: https://github.com/LesnyRumcajs/grpc_bench/wiki
* Spring WebFlux and gRPC: https://alexbryksin.medium.com/spring-webflux-and-grpc-cda3cabfaba8