diff --git a/build.sbt b/build.sbt index 29aa6a7..b4276b6 100644 --- a/build.sbt +++ b/build.sbt @@ -38,12 +38,10 @@ lazy val `http4s-consul-middleware` = crossProject(JSPlatform, JVMPlatform) libraryDependencies ++= { val http4sVersion = "0.23.27" val munitVersion = "1.0.0" - val circeOpticsV = if (scalaBinaryVersion.value == "2.12") "0.14.1" else "0.15.0" Seq( "org.http4s" %%% "http4s-client" % http4sVersion, "org.http4s" %%% "http4s-circe" % http4sVersion, - "io.circe" %%% "circe-optics" % circeOpticsV, "io.circe" %%% "circe-literal" % "0.14.9", "io.monix" %%% "newtypes-core" % "0.2.3", "org.typelevel" %%% "log4cats-core" % log4catsVersion, diff --git a/core/shared/src/main/scala/com/dwolla/consul/ConsulServiceDiscoveryAlg.scala b/core/shared/src/main/scala/com/dwolla/consul/ConsulServiceDiscoveryAlg.scala index 2349f16..42008fa 100644 --- a/core/shared/src/main/scala/com/dwolla/consul/ConsulServiceDiscoveryAlg.scala +++ b/core/shared/src/main/scala/com/dwolla/consul/ConsulServiceDiscoveryAlg.scala @@ -10,9 +10,7 @@ import cats.syntax.all._ import cats.{Monad, ~>} import com.dwolla.consul.ThirdPartyTypeCodecs._ import fs2.Stream -import io.circe.optics.JsonPath.root -import io.circe.{Decoder, Json} -import monocle.Traversal +import io.circe._ import natchez.{EntryPoint, Span, Trace} import org.http4s.Method.GET import org.http4s._ @@ -109,9 +107,6 @@ object ConsulServiceDiscoveryAlg { } } - private val serviceLens: Traversal[Json, Uri.Authority] = - root.each.Service.as[Uri.Authority] - /** * Makes a request of the Consul API to retrieve the set of healthy instances for the given service. * @@ -148,7 +143,18 @@ object ConsulServiceDiscoveryAlg { Logger[F].trace(s"📠 ${AnsiColorCodes.red}Consul response ${AnsiColorCodes.reset}") >> resp .as[Json] - .map(serviceLens.getAll(_).toVector) + .map { + _ + .asArray + .toVector + .flatten + .flatMap { + _.asObject + .flatMap(_("Service")) + .flatMap(_.as[Uri.Authority].toOption) + .toVector + } + } .tupleRight(resp.headers.get[ConsulIndex]) } .timeout(longPollTimeout + 1.second)