https://github.com/linux-china/proto-rsocket-plugin
Protobuf to RSocket service interface
https://github.com/linux-china/proto-rsocket-plugin
Last synced: 10 months ago
JSON representation
Protobuf to RSocket service interface
- Host: GitHub
- URL: https://github.com/linux-china/proto-rsocket-plugin
- Owner: linux-china
- Created: 2020-03-23T20:14:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T17:01:10.000Z (over 1 year ago)
- Last Synced: 2025-04-02T02:51:12.594Z (over 1 year ago)
- Language: Java
- Size: 57.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Proto to RSocket Reactive Interface
===================================

Generate Reactive service interfaces from services in the proto files.
For example, proto file as following:
```proto
syntax = "proto3";
option java_multiple_files = true;
option java_outer_classname = "AccountProto";
package org.mvnsearch.account;
import "google/protobuf/any.proto";
import "google/protobuf/wrappers.proto";
message Account {
int32 id = 1;
string email = 2;
string phone = 3;
int32 status = 4;
string nick = 5;
}
service AccountService {
// find account by id
rpc findById(google.protobuf.Int32Value /*id*/) returns (Account);
rpc findByStatus(google.protobuf.Int32Value /*status*/) returns (stream Account);
rpc findByIdStream(stream google.protobuf.Int32Value /*idFlux*/) returns (stream Account);
}
```
*Attention:*
* If you use [protoc-gen-doc](https://github.com/pseudomuto/protoc-gen-doc), please make comment in the same line.
generated Java Reactive interface:
```java
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import google.protobuf.Int32Value;
public interface AccountService {
Mono findById(Int32Value id);
Flux findByStatus(Int32Value status);
Flux findByIdStream(Flux idFlux);
}
```
### How to use it
* Use command line:
```
$ mvn org.mvnsearch:proto-rsocket-plugin:1.0.0-SNAPSHOT:proto2rsocket
```
* or add the plugin in your pom.xml
```xml
org.mvnsearch
proto-rsocket-plugin
1.0.4
generate-sources
proto2rsocket
```
# References
* Language Guide (proto3): https://developers.google.cn/protocol-buffers/docs/proto3
* gRPC Service definition: https://grpc.io/docs/what-is-grpc/core-concepts/
* protoc-gen-doc: Documentation generator plugin for Google Protocol Buffers https://github.com/pseudomuto/protoc-gen-doc