/wire-grpc

Easily implement a grpc server with the wire library

Primary LanguageKotlinApache License 2.0Apache-2.0

Wire GRPC

Create grpc BindableService using your wire generated interfaces. Simply wrap your service implementation in a ReflectionBindableService class.

class ServiceImpl : SomeServiceServer {
  override suspend fun Unary(request: Input): Output {
    // [...]
  }

  override suspend fun ServerStream(request: Input, response: SendChannel<Output>) {
    // [...]
  }

  override suspend fun ClientStream(request: ReceiveChannel<Input>): Output {
    // [...]
  }

  override suspend fun BiDiStream(request: ReceiveChannel<Input>, response: SendChannel<Output>) {
    // [...]
  }

}

fun main() {
    val bindableService = ReflectionBindableService(ServiceImpl())
    server = ServerBuilder.forPort(8080)
        .addService(bindableService)
        .build()
        .start()
}