From 964d04df24a2a446f6c3476845969d766fbd7abb Mon Sep 17 00:00:00 2001 From: Pierre Ricadat Date: Mon, 15 Apr 2024 09:55:43 +0900 Subject: [PATCH] Cleanup --- .../com/example/helloworld/GreeterServer.scala | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scala_zio_bench/src/main/scala/com/example/helloworld/GreeterServer.scala b/scala_zio_bench/src/main/scala/com/example/helloworld/GreeterServer.scala index 76309851..fa943de6 100644 --- a/scala_zio_bench/src/main/scala/com/example/helloworld/GreeterServer.scala +++ b/scala_zio_bench/src/main/scala/com/example/helloworld/GreeterServer.scala @@ -1,8 +1,7 @@ package com.example.helloworld -import io.grpc.ServerBuilder -import io.grpc.protobuf.services.ProtoReflectionService -import scalapb.zio_grpc.{ServerMain, ServiceList} +import scalapb.zio_grpc.{Server, ServerLayer, ServerMain, ServiceList} +import zio.ZLayer import java.util.concurrent.Executors @@ -12,10 +11,8 @@ object GreeterServer extends ServerMain { // Default port is 9000 override def port = 50051 - override def builder = { - val sb = ServerBuilder - .forPort(port) - .addService(ProtoReflectionService.newInstance()) + override def serverLive: ZLayer[Any, Throwable, Server] = { + val sb = builder /** * Allow customization of the Executor with two environment variables: @@ -42,6 +39,7 @@ object GreeterServer extends ServerMain { case "workStealing" => sb.executor(Executors.newWorkStealingPool(i_threads)) case "cached" => sb.executor(Executors.newCachedThreadPool) } - sb + + ServerLayer.fromServiceList(sb, services) } }