Dogacel / kotlinx-protobuf-gen

Generate kotlinx serializable data classes from protobuf
Apache License 2.0
12 stars 3 forks source link

gRPC wire protocol support #4

Open Dogacel opened 1 year ago

Dogacel commented 1 year ago

Currently services and methods are generated. But there is no way to call or serve those actual methods.

There are several caveats,

  1. Don't write your own client library. There are lots of good options and we don't want our users to depend on our version which is definitely less reliable than something like Netty or grpc-kotlin.
  2. Make your code inter-operable. Investigate libraries for kotlin js, jvm and native. Make sure generated stubs can be plugged in into any of those libraries.

My service of preference is Armeria for testing.

Easiest way to develop such a feature would be starting with Unary only methods.

kansson commented 1 month ago

Hi 👋🏻 I'm looking to build a client for connect similar to https://github.com/collectiveidea/twirp-kmm that works on kmp. Does this package include something like the service code generation in https://github.com/streem/pbandk?tab=readme-ov-file#service-code-generation?

Also, I'm having trouble running this plugin with protoc. Could you provide some guidance?

Dogacel commented 1 month ago

Hi 👋🏻 I'm looking to build a client for connect similar to https://github.com/collectiveidea/twirp-kmm that works on kmp. Does this package include something like the service code generation in https://github.com/streem/pbandk?tab=readme-ov-file#service-code-generation?

Also, I'm having trouble running this plugin with protoc. Could you provide some guidance?

Hi @kansson , what kind of problem are you having? Did you follow the official docs? Setup and Documentation

You can use the flag generateServices to generate abstract classes but they will be just classes and won't be integrated into any of the frameworks.

Example: https://github.com/Dogacel/kotlinx-protobuf-gen/blob/main/generated-code-tests/src/main/kotlin/testgen/test/grpc/test_grpc.proto.kt

If you want to contribute service code generation for a framework such as Ktor, Netty, Armeria etc. I would be glad to review it.