From 9f42e5796e245431ac5468e9d79fc08e86470825 Mon Sep 17 00:00:00 2001 From: sebver Date: Wed, 5 Aug 2020 11:43:10 +0200 Subject: [PATCH] Upgrades to zio 1.0 (#54) --- build.sbt | 6 +++--- statsd/src/main/scala/zio/metrics/Client.scala | 15 ++++++++------- .../zio/metrics/dogstatsd/DogStatsDClient.scala | 6 +++--- .../scala/zio/metrics/statsd/StatsDClient.scala | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.sbt b/build.sbt index 3f75a7ef..50bf61d0 100644 --- a/build.sbt +++ b/build.sbt @@ -23,9 +23,9 @@ fork in Test := true fork in run := true val http4sVersion = "0.21.6" -val zioVersion = "1.0.0-RC21-2" -val interopVersion = "2.1.4.0-RC17" -val zioNIOVersion = "1.0.0-RC8" +val zioVersion = "1.0.0" +val interopVersion = "2.1.4.0" +val zioNIOVersion = "1.0.0-RC9" val prometheusVersion = "0.9.0" val dropwizardVersion = "4.1.10.1" val circeVersion = "0.13.0" diff --git a/statsd/src/main/scala/zio/metrics/Client.scala b/statsd/src/main/scala/zio/metrics/Client.scala index 9c669edf..9e0bdb24 100644 --- a/statsd/src/main/scala/zio/metrics/Client.scala +++ b/statsd/src/main/scala/zio/metrics/Client.scala @@ -4,17 +4,18 @@ import java.util.concurrent.ThreadLocalRandom import zio._ import zio.clock.Clock +import zio.duration.Duration import zio.duration.Duration.Finite import zio.metrics.encoders._ import zio.stream.ZStream -class Client(val bufferSize: Long, val timeout: Long, host: Option[String], port: Option[Int])( +class Client(val bufferSize: Int, val timeout: Long, host: Option[String], port: Option[Int])( private val queue: Queue[Metric] ) { type UDPQueue = ZQueue[Nothing, Any, Encoder, Throwable, Nothing, Metric] - private val duration: Finite = Finite(timeout) + private val duration: Duration = Finite(timeout) private val udpClient: ZManaged[Any, Throwable, UDPClient] = (host, port) match { case (None, None) => UDPClient() @@ -52,7 +53,7 @@ class Client(val bufferSize: Long, val timeout: Long, host: Option[String], port ZStream .fromQueue[Encoder, Throwable, Metric](queue) .groupedWithin(bufferSize, duration) - .mapM(l => f(l)) + .mapM(l => f(l.toList)) .runDrain .fork @@ -77,14 +78,14 @@ object Client { def apply(): ZManaged[ClientEnv, Throwable, Client] = apply(5, 5000, 100, None, None) - def apply(bufferSize: Long, timeout: Long): ZManaged[ClientEnv, Throwable, Client] = + def apply(bufferSize: Int, timeout: Long): ZManaged[ClientEnv, Throwable, Client] = apply(bufferSize, timeout, 100, None, None) - def apply(bufferSize: Long, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, Client] = + def apply(bufferSize: Int, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, Client] = apply(bufferSize, timeout, queueCapacity, None, None) def apply( - bufferSize: Long, + bufferSize: Int, timeout: Long, queueCapacity: Int, host: Option[String], @@ -103,7 +104,7 @@ object Client { withListener(5, 5000, 100, None, None)(listener) def withListener[F[_], A]( - bufferSize: Long, + bufferSize: Int, timeout: Long, queueCapacity: Int, host: Option[String], diff --git a/statsd/src/main/scala/zio/metrics/dogstatsd/DogStatsDClient.scala b/statsd/src/main/scala/zio/metrics/dogstatsd/DogStatsDClient.scala index a20e3748..4ca43d2a 100644 --- a/statsd/src/main/scala/zio/metrics/dogstatsd/DogStatsDClient.scala +++ b/statsd/src/main/scala/zio/metrics/dogstatsd/DogStatsDClient.scala @@ -131,14 +131,14 @@ object DogStatsDClient { def apply(): ZManaged[ClientEnv, Throwable, DogStatsDClient] = apply(5, 5000, 100, None, None) - def apply(bufferSize: Long, timeout: Long): ZManaged[ClientEnv, Throwable, DogStatsDClient] = + def apply(bufferSize: Int, timeout: Long): ZManaged[ClientEnv, Throwable, DogStatsDClient] = apply(bufferSize, timeout, 100, None, None) - def apply(bufferSize: Long, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, DogStatsDClient] = + def apply(bufferSize: Int, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, DogStatsDClient] = apply(bufferSize, timeout, queueCapacity, None, None) def apply( - bufferSize: Long, + bufferSize: Int, timeout: Long, queueCapacity: Int, host: Option[String], diff --git a/statsd/src/main/scala/zio/metrics/statsd/StatsDClient.scala b/statsd/src/main/scala/zio/metrics/statsd/StatsDClient.scala index 608b8950..c6cd2630 100644 --- a/statsd/src/main/scala/zio/metrics/statsd/StatsDClient.scala +++ b/statsd/src/main/scala/zio/metrics/statsd/StatsDClient.scala @@ -64,14 +64,14 @@ class StatsDClient(client: Client) { object StatsDClient { def apply(): ZManaged[ClientEnv, Throwable, StatsDClient] = apply(5, 5000, 100, None, None) - def apply(bufferSize: Long, timeout: Long): ZManaged[ClientEnv, Throwable, StatsDClient] = + def apply(bufferSize: Int, timeout: Long): ZManaged[ClientEnv, Throwable, StatsDClient] = apply(bufferSize, timeout, 100, None, None) - def apply(bufferSize: Long, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, StatsDClient] = + def apply(bufferSize: Int, timeout: Long, queueCapacity: Int): ZManaged[ClientEnv, Throwable, StatsDClient] = apply(bufferSize, timeout, queueCapacity, None, None) def apply( - bufferSize: Long, + bufferSize: Int, timeout: Long, queueCapacity: Int, host: Option[String],