Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krzema12/kotlin-rpc
Kotlin-centric, multiplatform-enabled approach to RPC.
https://github.com/krzema12/kotlin-rpc
kotlin multiplatform rpc
Last synced: 4 days ago
JSON representation
Kotlin-centric, multiplatform-enabled approach to RPC.
- Host: GitHub
- URL: https://github.com/krzema12/kotlin-rpc
- Owner: krzema12
- Created: 2020-11-14T21:37:34.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-31T19:24:42.000Z (almost 4 years ago)
- Last Synced: 2024-10-12T11:13:56.544Z (25 days ago)
- Topics: kotlin, multiplatform, rpc
- Language: Kotlin
- Homepage:
- Size: 115 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# kotlin-rpc
[![Download](https://api.bintray.com/packages/krzema1212/it.krzeminski/kotlin-rpc/images/download.svg)](https://bintray.com/krzema1212/it.krzeminski/kotlin-rpc/_latestVersion) ![Build](https://github.com/krzema12/kotlin-rpc/workflows/Build/badge.svg)
**Work in progress!**
It's a Kotlin-centric approach to Remote Procedure Calling, built on top of reflectionless [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization), [coroutines](https://github.com/Kotlin/kotlinx.coroutines) and [ktor](https://github.com/ktorio/ktor).
Safe and elegant.It works like this. First, the API is described with pure Kotlin, as an interface. Then, kotlin-rpc's build-time logic
kicks in and generates clients and server stubs. It works over HTTP (e. g. calling a JVM server from a JS client), but
other medium is possible, like Web workers (communication between the main UI thread and the worker thread).## Installation
In `build.gradle.kts` with your API, add my private repo:
```
repositories {
maven {
url = uri("https://dl.bintray.com/krzema1212/it.krzeminski")
}
}
```add kotlin-rpc to dependencies, together with adding custom source sets in `build` directory:
```
...
val jvmMain by getting {
dependencies {
...
implementation("it.krzeminski.kotlinrpc:kotlin-rpc:[put-newest-version-here]")
}
kotlin.srcDirs(kotlin.srcDirs, "$buildDir/jvm/generated/")
}
val jsMain by getting {
dependencies {
...
}
kotlin.srcDirs(kotlin.srcDirs, "$buildDir/js/generated/")
}
...
```and define tasks to execute the entry points:
```
val generateJsProxy = tasks.register("generateJsClient") {
group = "build"
description = "Generate JS proxy"
classpath = sourceSets["main"].runtimeClasspath
main = "it.krzeminski.kotlinrpc.api.generation.JsClientGenerationKt"
args("it.krzeminski.zoo.api.ZooApi", "$buildDir/js/generated")
}val generateJvmKtorServer = tasks.register("generateJvmKtorServer") {
group = "build"
description = "Generate JVM Ktor server"
classpath = sourceSets["main"].runtimeClasspath
main = "it.krzeminski.kotlinrpc.api.generation.JvmKtorServerGenerationKt"
args("it.krzeminski.zoo.api.ZooApi", "$buildDir/jvm/generated")
}tasks.getByName("jvmJar").dependsOn(generateJvmKtorServer)
tasks.getByName("jsJar").dependsOn(generateJsProxy)
```This is all pretty complicated, and is going to be simplified in scope of #13.