From 9fca0325a961215339535bfdb759bf0b242bc2da Mon Sep 17 00:00:00 2001 From: LYK Date: Tue, 11 Jul 2023 02:25:22 +0900 Subject: [PATCH] kotlin: Update quickstart.md (#1159) Updated example code that doesn't use Builder. The current example code doesn't use Builder. https://github.com/grpc/grpc-kotlin/blob/master/examples/server/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldServer.kt#L49 https://github.com/grpc/grpc-kotlin/blob/master/examples/client/src/main/kotlin/io/grpc/examples/helloworld/HelloWorldClient.kt#L29 --- content/en/docs/languages/kotlin/quickstart.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/content/en/docs/languages/kotlin/quickstart.md b/content/en/docs/languages/kotlin/quickstart.md index 6399fcf..5b490a0 100644 --- a/content/en/docs/languages/kotlin/quickstart.md +++ b/content/en/docs/languages/kotlin/quickstart.md @@ -125,15 +125,13 @@ method like this: ```kotlin private class HelloWorldService : GreeterGrpcKt.GreeterCoroutineImplBase() { - override suspend fun sayHello(request: HelloRequest) = HelloReply - .newBuilder() - .setMessage("Hello ${request.name}") - .build() + override suspend fun sayHello(request: HelloRequest) = helloReply { + message = "Hello ${request.name}" + } - override suspend fun sayHelloAgain(request: HelloRequest) = HelloReply - .newBuilder() - .setMessage("Hello again ${request.name}") - .build() + override suspend fun sayHelloAgain(request: HelloRequest) = helloReply { + message = "Hello again ${request.name}" + } } ``` @@ -150,7 +148,7 @@ class HelloWorldClient( private val stub: GreeterCoroutineStub = GreeterCoroutineStub(channel) suspend fun greet(name: String) { - val request = HelloRequest.newBuilder().setName(name).build() + val request = helloRequest { this.name = name } val response = stub.sayHello(request) println("Received: ${response.message}") val againResponse = stub.sayHelloAgain(request)