Skip to content

Commit

Permalink
weaken typeclass constraint in client middleware from Effect to Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bplommer committed Aug 21, 2020
1 parent 30c4c62 commit 8c66884
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package kamon.http4s
package middleware.client

import cats.effect.{Effect, Resource}
import cats.effect.{Sync, Resource}
import cats.implicits._
import com.typesafe.config.Config
import kamon.Kamon
Expand All @@ -39,7 +39,7 @@ object KamonSupport {
Kamon.onReconfigure(newConfig => _instrumentation = instrumentation(newConfig))


def apply[F[_]](underlying: Client[F])(implicit F:Effect[F]): Client[F] = Client { request =>
def apply[F[_]](underlying: Client[F])(implicit F:Sync[F]): Client[F] = Client { request =>

for {
ctx <- Resource.liftF(F.delay(Kamon.currentContext()))
Expand All @@ -52,7 +52,7 @@ object KamonSupport {
(request: Request[F])
(ctx: Context)
(instrumentation: HttpClientInstrumentation)
(implicit F:Effect[F]): Resource[F, Response[F]] =
(implicit F:Sync[F]): Resource[F, Response[F]] =
for {
requestHandler <- Resource.liftF(F.delay(instrumentation.createHandler(getRequestBuilder(request), ctx)))
response <- underlying.run(requestHandler.request).attempt
Expand All @@ -63,7 +63,7 @@ object KamonSupport {
response: Either[Throwable, Response[F]],
requestHandler: HttpClientInstrumentation.RequestHandler[Request[F]],
settings: HttpClientInstrumentation.Settings
)(implicit F:Effect[F]): F[Response[F]] =
)(implicit F:Sync[F]): F[Response[F]] =
response match {
case Right(res) =>
if(res.status.code == 404) requestHandler.span.name(settings.defaultOperationName)
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/kamon/http4s/HttpMetricsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class HttpMetricsSpec extends WordSpec
def withServerAndClient[A](f: (Server[IO], Client[IO], HttpServerMetrics.HttpServerInstruments) => IO[A]): A =
(srv, client, metrics).tupled.use(f.tupled).unsafeRunSync()

private def get[F[_]: ConcurrentEffect](path: String)(server: Server[F], client: Client[F]): F[String] = {
private def get[F[_]: Sync](path: String)(server: Server[F], client: Client[F]): F[String] = {
client.expect[String](s"http://127.0.0.1:${server.address.getPort}$path")
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/kamon/http4s/ServerInstrumentationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package kamon.http4s

import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer}
import cats.effect.{ContextShift, IO, Sync, Timer}
import kamon.http4s.middleware.server.KamonSupport
import kamon.trace.Span
import org.http4s.{Headers, HttpRoutes}
Expand Down Expand Up @@ -66,7 +66,7 @@ class ServerInstrumentationSpec extends WordSpec
def withServerAndClient[A](f: (Server[IO], Client[IO]) => IO[A]): A =
(srv, client).tupled.use(f.tupled).unsafeRunSync()

private def getResponse[F[_]: ConcurrentEffect](path: String)(server: Server[F], client: Client[F]): F[(String, Headers)] = {
private def getResponse[F[_]: Sync](path: String)(server: Server[F], client: Client[F]): F[(String, Headers)] = {
client.get(s"http://127.0.0.1:${server.address.getPort}$path"){ r =>
r.bodyAsText.compile.toList.map(_.mkString).map(_ -> r.headers)
}
Expand Down

0 comments on commit 8c66884

Please sign in to comment.