File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
src/test/kotlin/org/jacodb/ets/test
wire-server/src/main/kotlin/org/jacodb/ets/service Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package org.jacodb.ets.test
1919import greeter.GreeterClient
2020import greeter.HelloRequest
2121import mu.KotlinLogging
22+ import org.jacodb.ets.service.GreeterService
2223import org.jacodb.ets.service.createGrpcClient
2324import org.jacodb.ets.service.grpcServer
2425import kotlin.test.Test
@@ -32,7 +33,9 @@ class WireTest {
3233
3334 @Test
3435 fun `test Greeter` () {
35- val server = grpcServer(PORT )
36+ val server = grpcServer(PORT ) {
37+ addService(GreeterService ())
38+ }
3639 server.start()
3740 logger.info { " Server listening on port ${server.port} " }
3841
Original file line number Diff line number Diff line change @@ -20,10 +20,26 @@ import io.grpc.Server
2020import io.grpc.ServerBuilder
2121import io.grpc.protobuf.services.ProtoReflectionService
2222
23+ /* *
24+ * Creates a gRPC server with the specified port and optional reflection service.
25+ *
26+ * ### Example:
27+ * ```kotlin
28+ * val server = grpcServer(7777) {
29+ * addService(MyService())
30+ * }
31+ * ```
32+ *
33+ * @param port The port on which the server will listen.
34+ * @param addReflection Whether to add the [ProtoReflectionService] for introspection (see [gRPC Reflection](https://grpc.io/docs/guides/reflection/)).
35+ * @param setup A lambda to configure the server, where you can add services and other configurations.
36+ * @return A configured [Server] instance.
37+ */
2338fun grpcServer (
2439 port : Int ,
2540 addReflection : Boolean = true,
26- setup : ServerBuilder <* >.() -> Unit = {},
41+ setup : ServerBuilder <* >.() -> Unit ,
42+ // Note: `setup` is not `= {}` by default because you probably want to add at least one service.
2743): Server = ServerBuilder
2844 .forPort(port)
2945 .apply (setup)
You can’t perform that action at this time.
0 commit comments