From 8b11c3ed5898c0db1be62b85e7c9a4056d7d906b Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 20 Apr 2022 11:35:43 +0200 Subject: [PATCH] chore: update to zio-2.0.0-RC5 (#522) * chore: update to zio-2.0.0-RC5 --- .../opentelemetry/example/JaegerTracer.scala | 19 ++++++++----------- .../opentelemetry/example/ProxyServer.scala | 4 +++- .../opentelemetry/example/http/Client.scala | 4 ++-- project/Dependencies.scala | 10 +++++----- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/JaegerTracer.scala b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/JaegerTracer.scala index 7de8b962..0c601822 100644 --- a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/JaegerTracer.scala +++ b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/JaegerTracer.scala @@ -11,16 +11,13 @@ import zio.telemetry.opentelemetry.example.config.AppConfig object JaegerTracer { def live: RLayer[AppConfig, Tracer] = - ZLayer - .service[AppConfig] - .flatMap(c => - (for { - spanExporter <- ZIO.attempt(JaegerGrpcSpanExporter.builder().setEndpoint(c.get.tracer.host).build()) - spanProcessor <- ZIO.succeed(SimpleSpanProcessor.create(spanExporter)) - tracerProvider <- ZIO.succeed(SdkTracerProvider.builder().addSpanProcessor(spanProcessor).build()) - openTelemetry <- ZIO.succeed(OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build()) - tracer <- ZIO.succeed(openTelemetry.getTracer("zio.telemetry.opentelemetry.example.JaegerTracer")) - } yield tracer).toLayer - ) + ZLayer(for { + c <- ZIO.service[AppConfig] + spanExporter <- ZIO.attempt(JaegerGrpcSpanExporter.builder().setEndpoint(c.tracer.host).build()) + spanProcessor <- ZIO.succeed(SimpleSpanProcessor.create(spanExporter)) + tracerProvider <- ZIO.succeed(SdkTracerProvider.builder().addSpanProcessor(spanProcessor).build()) + openTelemetry <- ZIO.succeed(OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build()) + tracer <- ZIO.succeed(openTelemetry.getTracer("zio.telemetry.opentelemetry.example.JaegerTracer")) + } yield tracer) } diff --git a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/ProxyServer.scala b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/ProxyServer.scala index 56eeae59..42fd9c34 100644 --- a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/ProxyServer.scala +++ b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/ProxyServer.scala @@ -36,7 +36,9 @@ object ProxyServer extends ZIOAppDefault { val configLayer = TypesafeConfig.fromResourcePath(descriptor[AppConfig]) val httpBackend: ZLayer[Any, Throwable, SttpBackend[Task, ZioStreams with WebSockets]] = - ZLayer.fromAcquireRelease(AsyncHttpClientZioBackend())(_.close().ignore) + ZLayer.scoped { + ZIO.acquireRelease(AsyncHttpClientZioBackend())(_.close().ignore) + } val sttp: ZLayer[AppConfig, Throwable, Client.Service] = httpBackend >>> Client.live diff --git a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/http/Client.scala b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/http/Client.scala index 6630718b..69ae8a89 100644 --- a/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/http/Client.scala +++ b/opentelemetry-example/src/main/scala/zio/telemetry/opentelemetry/example/http/Client.scala @@ -19,7 +19,7 @@ object Client { val up = Status.up("proxy") - val live: ZLayer[AppConfig with Backend, Throwable, Service] = (for { + val live: ZLayer[AppConfig with Backend, Throwable, Service] = ZLayer(for { conf <- ZIO.service[AppConfig] backend <- ZIO.service[Backend] service = new Service { @@ -33,5 +33,5 @@ object Client { Statuses(List(status, up)) } } - } yield service).toLayer + } yield service) } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index d4cfc821..0e74b627 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,15 +3,15 @@ import sbt._ object Dependencies { object Versions { val jaeger = "1.6.0" - val sttp3 = "3.5.1" + val sttp3 = "3.5.2" val opentracing = "0.33.0" val opentelemetry = "1.11.0" val opencensus = "0.31.0" val zipkin = "2.16.3" - val zio = "2.0.0-RC4" - val zioHttp = "2.0.0-RC6" - val zioJson = "0.3.0-RC6" - val zioConfig = "3.0.0-RC7" + val zio = "2.0.0-RC5" + val zioHttp = "2.0.0-RC7" + val zioJson = "0.3.0-RC7" + val zioConfig = "3.0.0-RC8" } lazy val zio = Seq(