11/5/2022 0 Comments Summer lesson vr ebay![]() ![]() To learn more about Kotlin protos check out these docs: For an example Maven project check out the grpc-hello-world-mvn sample.įor examples that can be deployed with a couple clicks on Google Cloud Run (a fully managed serverless platform) check out: grpc-hello-world-gradle, grpc-hello-world-streaming (server push), or grpc-hello-world-bidi-streaming (bi-directional streaming). Give the complete gRPC Kotlin example a spin and also explore other aspects like the Android client and native client (built with GraalVM Native Image) which both use the lite protos. A bit of configuration is needed to tell your build tool (Maven, Gradle, etc) to do that. The protobuf compiler (protoc) now has built-in support for generating Kotlin code. Thanks to static typing and the type-safe builders, you can easily code-complete your way through code that is "correct" in-that the types / properties are consistent with the protos. ![]() What isn't evident in these examples is how nice the experience is when writing high-performance RPC code. Those code examples really illustrate how concise the syntax is, which means less boilerplate to write and less for our brains to parse as we try to read the code. val totalRolls = Ĭheck out the full example client source. Note: Since protos use the get prefix for their fields and Kotlin recognizes that as a property, reading from a proto already works smoothly from Kotlin as if the proto were a data class. Note that this works with both the proto compiler’s standard and "proto lite" modes, the latter generating smaller, higher performance classes which are more suitable for Android. The Kotlin version uses Kotlin type-safe builders, which makes it concise and removes the need to explicitly call a build method. Here is the equivalent dice roll code written using the new Kotlin proto bindings: With this release, protos offer an expressive set of DSL factory methods that make this code elegant and idiomatic in Kotlin. In the Java language, constructing a series of dice rolls might look like this:ĭiceSeries series = DiceSeries.newBuilder() String nickname = 2 // string nickname, e.g. Int32 value = 1 // value of this roll, e.g. From a proto definition, you can use the new built-in Kotlin support in the proto compiler to generate idiomatic Kotlin Domain Specific Languages (DSLs).įor example, here’s a simple protocol buffer message representing a series of dice rolls: ![]() “protos”), Google’s platform-neutral, high-performance data interchange format. We’re excited to deepen our investment in the Kotlin language with official support for Kotlin in the open source Protocol Buffers project (a.k.a. Last year, we open sourced Kotlin support for gRPC, the open source Remote Procedure Call (RPC) framework that powers thousands of microservices at Google. We love Kotlin for its expressiveness, safety, simple async support through coroutines, and easy bidirectional interoperability with the Java programming language. Android development is now Kotlin first, our engineering teams work on language evolution through the Kotlin Foundation, and inside of Google we’re using Kotlin more and more to build our backend services. Posted by Deanna Garcia and Louis Wasserman - Software Developers, and Developer Advocate, James Ward Google’s commitment to KotlinĪt Google, we’re investing deeply in the Kotlin language and ecosystem. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |