Skip to content

szkug/krpc

Repository files navigation

krpc-plugin

Generate kotlin multiplatform RPC code from .proto files.

Krpc base on wire.

Usage

Use plugin

// build.gradle.kts
plugins {
    id("cn.szkug.krpc") version "<version>"
}

wire {
    // wire configuration
}

Import Schema Handler

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.szkug.krpc:schema:<version>")
  }
}

Then configuration WireExtension schema handler with custom.

// build.gradle.kts
wire {
    custom {
        schemaHandlerFactory = KrpcSchemaHandlerFactory.client()
        out = "${layout.buildDirectory.asFile.get()}/generated"
    }
    // wire configuration
}

// must import runtime without plugin
dependencies {
    implementation("org.szkug.krpc:runtime:<version>")
}

Sample

message ActiveReq {
  string os = 1; // System
  string brd = 2; // Device
  string ver = 3; // App Version
  optional int64 uid = 4; // User id if logged in
}

message ActiveResp {}

service ActiveService {

  rpc report(ActiveReq) returns (ActiveResp);

}

This proto file will generate kotlin code like:

interface KrpcActiveService {
    fun report(req: ActiveReq): ActiveResp
}

About

A KMP RPC support wire custom handler plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages