|
| 1 | +/* |
| 2 | + * Copyright 2022 UnitTestBot contributors (utbot.org) |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.jacodb.ets.service |
| 18 | + |
| 19 | +import com.squareup.wire.GrpcMethod |
| 20 | +import greeter2.HelloReply |
| 21 | +import greeter2.HelloRequest |
| 22 | + |
| 23 | +fun main() { |
| 24 | + val port = 50051 |
| 25 | + // val greeter: GreeterClient = grpcClient(port).create() |
| 26 | + // val request = HelloRequest(name = "Kotlin") |
| 27 | + // val response = greeter.SayHello().executeBlocking(request) |
| 28 | + // println("Response: \"${response.message}\"") |
| 29 | + |
| 30 | + // Below is the manual way to create a gRPC call. |
| 31 | + // We use it here to make 'path' contain 'greeter' instead of 'greeter2', |
| 32 | + val client = grpcClient(port) |
| 33 | + val call = client.newCall( |
| 34 | + GrpcMethod( |
| 35 | + path = "/greeter.Greeter/SayHello", |
| 36 | + requestAdapter = HelloRequest.ADAPTER, |
| 37 | + responseAdapter = HelloReply.ADAPTER |
| 38 | + ) |
| 39 | + ) |
| 40 | + val request = HelloRequest(name = "Kotlin") |
| 41 | + val response: HelloReply = call.executeBlocking(request) |
| 42 | + println("Response: \"${response.message}\"") |
| 43 | +} |
0 commit comments