https://kotlinlang.org logo
#grpc
Title
# grpc
m

Mark Allanson

04/30/2021, 7:33 AM
Has anyone developed a nice way of wrapping the generated java builders to make things a bit nicer in kotlin? At the moment we are doing
Copy code
val message = with(MyMessage.newBuilder()) {
    someField = 1
    build()
}
I was thinking it would be nicer to do something like....
Copy code
val message = build(MyMessage) {
   someField = 1
}
... but my Kotlin isn't good enough to be able to write that build function yet 😄
d

Dariusz Kuc

04/30/2021, 12:49 PM
Take a look at https://github.com/marcoferrer/kroto-plus - you can generate dsl style builders using gradle
m

Mark Allanson

04/30/2021, 1:03 PM
Any idea if this works with quarkus-grpc? I'd guess not
Thanks for the pointer though!
d

Dariusz Kuc

04/30/2021, 2:07 PM
I'd assume you should be able to generate DSL style builders and use it with anything as underlying libs generally still depend on protoc java compiler (e.g. we use
kroto+
DSL with
grpc-kotlin
)
m

Mark Allanson

04/30/2021, 2:34 PM
Yeah I was investigating that right now - if I can wire in the kroto+ message builders
m

Marc Plano-Lesay

04/30/2021, 10:28 PM
There are words of open-sourcing an "official" Google supported Kotlin proto generators (see on the gRPC-Kotlin issue tracker), but nothing there yet afaik
3 Views