Skip to content

Commit 5273e1d

Browse files
committed
Docs
1 parent e648c28 commit 5273e1d

File tree

2 files changed

+21
-2
lines changed
  • jacodb-ets
    • src/test/kotlin/org/jacodb/ets/test
    • wire-server/src/main/kotlin/org/jacodb/ets/service

2 files changed

+21
-2
lines changed

jacodb-ets/src/test/kotlin/org/jacodb/ets/test/WireTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.jacodb.ets.test
1919
import greeter.GreeterClient
2020
import greeter.HelloRequest
2121
import mu.KotlinLogging
22+
import org.jacodb.ets.service.GreeterService
2223
import org.jacodb.ets.service.createGrpcClient
2324
import org.jacodb.ets.service.grpcServer
2425
import 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

jacodb-ets/wire-server/src/main/kotlin/org/jacodb/ets/service/Server.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@ import io.grpc.Server
2020
import io.grpc.ServerBuilder
2121
import 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+
*/
2338
fun 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)

0 commit comments

Comments
 (0)