An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

Proto to RSocket Reactive Interface
===================================

![Version](https://img.shields.io/maven-central/v/org.mvnsearch/proto-rsocket-plugin)

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