Skip to content

Commit

Permalink
remove circe-optics from the project to reduce the number of dependen…
Browse files Browse the repository at this point in the history
…cies
  • Loading branch information
bpholt committed Jul 17, 2024
1 parent 01036c0 commit aac99b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aac99b9

Please sign in to comment.