Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,24 @@
<version>${grpc.version}</version>
</dependency>

<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-kotlin-stub</artifactId>
<version>${grpc-kotlin.version}</version>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf.version}</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need coroutines for that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Kotlin, the base implementations of gRPC services use coroutines to deal with blocking operations. This way, developers don't need to deal with StreamObservers like they have to do in Java and just implement a suspend function that returns the object directly.

Java implementation:
https://github.com/grpc/grpc-java/blob/c540229d79c6d8d29da34d22c3c5add2138bdc87/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java#L81-L89

Kotlin implementation:
https://github.com/grpc/grpc-kotlin/blob/b7d06483bf597cd4a10e3ed2ef52b21ca95c80ad/examples/server/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldServer.kt#L48-L53

<version>${kotlin-coroutines.version}</version>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
Expand All @@ -46,7 +58,7 @@
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
Expand All @@ -58,20 +70,51 @@
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protocPlugins>
<protocPlugin>
<id>grpc-kotlin</id>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-kotlin</artifactId>
<version>${grpc-kotlin.version}</version>
<classifier>jdk7</classifier>
<mainClass>io.grpc.kotlin.generator.GeneratorRunner</mainClass>
</protocPlugin>
</protocPlugins>

<useArgumentFile>true</useArgumentFile>
<checkStaleness>true</checkStaleness>
<staleMillis>10000</staleMillis>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
9 changes: 6 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
<auto-value.version>1.6.3</auto-value.version>
<awaitility.version>3.1.6</awaitility.version>
<checkstyle.version>8.18</checkstyle.version>
<grpc.version>1.22.1</grpc.version>
<guava.version>26.0-android</guava.version><!-- Keep the Guava version in sync with grpc-java -->
<grpc.version>1.36.0</grpc.version>
<grpc-kotlin.version>1.1.0</grpc-kotlin.version><!-- Keep the gRPC Kotlin version in sync with grpc-java -->
<guava.version>30.0-android</guava.version><!-- Keep the Guava version in sync with grpc-java -->
<junit.version>4.13.1</junit.version>
<protobuf.version>3.9.1</protobuf.version><!-- Keep the Protobuf version in sync with grpc-java -->
<kotlin.version>1.3.61</kotlin.version><!-- Keep the Kotlin version in sync with grpc-kotlin -->
<kotlin-coroutines.version>1.3.3</kotlin-coroutines.version><!-- Keep the Kotlin Coroutines version in sync with grpc-kotlin -->
<protobuf.version>3.12.0</protobuf.version><!-- Keep the Protobuf version in sync with grpc-java -->
<rest-assured.version>3.1.0</rest-assured.version>
<slf4j.version>1.7.26</slf4j.version>
<testcontainers.version>1.15.3</testcontainers.version>
Expand Down