square / square/wire

Create BindableService or ServerServiceDefinition from within Kotlin source

Open
#1,904 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
4.4k
Forks
627
Avg merge
3d 15m
Merged PRs (30d)
20

Description

For implementing a gRPC-service into the framework, I need to pass an io.grpc.BindableService to the addService method on the ServerBuilder which basically provides io.grpc.ServerServiceDefinition.

To get this info, usually you extend some kind of ImplBase that has all the methods to gather this. You can achieve this by enabling this option: grpcServerCompatible = true
I have been trying this in this issue: https://github.com/square/wire/issues/1903

But honestly I prefer not to generate all this "legacy" code, but just stick to the Kotlin generated files and provide the BindableService from there. Is this possible - and if it is - how?

I tried to create something myself, but it's hard.

    class Greeter : GreeterServer {
        override fun sayHello(request: HelloRequest): HelloReply = HelloReply(
            message = "Hello"
        )
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing ServerBuilder.addService, BindableService, ServerServiceDefinition, and the Kotlin-generated GreeterServer example described in the issue, then compare the grpcServerCompatible approach referenced in issue 1903. Done would mean a documented or implemented way to obtain a BindableService or ServerServiceDefinition directly from Kotlin-generated sources without generating legacy code.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, kotlin
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.