RSProto is a framework that designed to provide ability to expose your API as RPC Services. It facilitates the creation of gRPC-like services from .proto files through code generation. The framework also provides essential core components for both server and client.
Warning
This project is experimental, be ready for bugs and possible changes.
- Gradle Plugin:
.proto
to RSocket code generator (both client and server). - Server Core (JVM only): Interceptors, Instances API and bridge between Ktor and library.
- Client Core (JVM, Web, iOS): Metadata and basic interface-markers.
Known issues
As RSocket does not natively support client-only streaming – it's not supported by the code-generator.
First of all, you should have the following repository:
repositories {
maven("https://maven.timemates.org")
}
Before using builtin generation from .proto
to RSocket services, you should add the following dependencies:
dependencies {
// for server
implementation("org.timemates.rsproto:server-core:$version")
// for client
commonMainImplementation("org.timemates.rsproto:client-core:$version")
// for server & client
commonMainImplementation("org.timemates.rsproto:common-core:$version")
}
To configure your server, you can use ready-to-use build-bridges between Ktor and RSProto:
fun Application.configureServer() {
routing {
rSocketServer("/rsocket") {
interceptor(MyInterceptor())
service(MyService())
instances {
protobuf {
encodeDefaults = true
}
}
}
}
}
Clients are generated by the code-generation Gradle plugin. To use them you need instance of rsocket
and protobuf
:
val apiService = TestServiceApi(rsocket, protobuf)
apiService.sayHello()
To implement code-generation plugin in your buildscript, add the following:
plugins {
id("org.timemates.rsproto") version "$version"
}
And use it inside your buildscript:
rsproto {
protoSourcePath.set("src/main/proto")
generationOutputPath.set("generated/proto-generator/src/commonMain")
clientGeneration.set(true)
serverGeneration.set(true)
}
For bugs, questions and discussions please use the GitHub Issues.
This library is licensed under MIT License. Feel free to use, modify, and distribute it for any purpose.