Grpc

Available in a dev version: 0․11․0-grpc-186

How to configure

annotation class Grpc(val protoPackage: String = "", val protoServiceName: String = "")(source)

Marks an interface as a gRPC service definition.

The annotation supports customizing the gRPC service name and package used in the protocol. By default, the service name is derived from the interface name and the package from the Kotlin package.

Example:

@Grpc(protoPackage = "com.example.api", protoServiceName = "RpcUserService")
interface UserService {
suspend fun getUser(request: GetUserRequest): User

@Grpc.Method(name = "CustomName", safe = true, idempotent = true)
suspend fun searchUsers(query: SearchQuery): SearchResults
}

See also

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class Method(val name: String = "", val safe: Boolean = false, val idempotent: Boolean = false, val sampledToLocalTracing: Boolean = true)

Configures gRPC-specific metadata for a service method.

Properties

Link copied to clipboard

The Protocol Buffers package name for this service. If empty (default), the Kotlin package name is used. This affects the fully qualified service name in gRPC (e.g., "com.example.api.RpcUserService").

Link copied to clipboard

The Protocol Buffers service name. If empty (default), the interface name is used. Useful when the service name in the proto definition differs from the Kotlin interface name, such as when multiple client/server interfaces map to the same proto service.