diff --git a/build.sbt b/build.sbt index 4c366215..3b2a10c5 100644 --- a/build.sbt +++ b/build.sbt @@ -63,7 +63,7 @@ lazy val api = (project in file("modules/api")) name := "lila-search-api", smithy4sWildcardArgument := "?", libraryDependencies ++= Seq( - "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value + smithy4sCore ) ) @@ -73,9 +73,8 @@ lazy val client = (project in file("modules/client")) scalaVersion := scala3, name := "lila-search-client", libraryDependencies ++= Seq( - "com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value, - "com.typesafe.play" %% "play-ahc-ws-standalone" % "2.2.7", - http4sEmberClient + smithy4sJson, + playWS ) ) .dependsOn(api) @@ -87,9 +86,9 @@ lazy val app = (project in file("modules/app")) commonSettings, scalaVersion := scala3, libraryDependencies ++= Seq( - "com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value, - "com.disneystreaming.smithy4s" %% "smithy4s-http4s-swagger" % smithy4sVersion.value, - "com.sksamuel.elastic4s" %% "elastic4s-effect-cats" % "8.11.5", + smithy4sHttp4s, + smithy4sHttp4sSwagger, + elastic4s, catsCore, catsEffect, ducktape, diff --git a/modules/client/src/main/scala/Client.scala b/modules/client/src/main/scala/Client.scala deleted file mode 100644 index 18bafc14..00000000 --- a/modules/client/src/main/scala/Client.scala +++ /dev/null @@ -1,37 +0,0 @@ -package lila.search -package client - -import smithy4s.http4s.* -import org.http4s.Uri -import org.http4s.client.Client -import cats.effect.{ IO, Resource } -import org.http4s.ember.client.EmberClientBuilder -import lila.search.spec.* -import scala.concurrent.Future -import cats.effect.unsafe.implicits.global - -object Client: - - def apply(uri: Uri): Resource[IO, FutureClient] = - instance(uri).map(FutureClient(_)) - - def instance(uri: Uri): Resource[IO, SearchService[IO]] = - makeClient.flatMap(makeIO(uri)) - - private def makeClient: Resource[IO, Client[IO]] = - EmberClientBuilder.default[IO].build - - def makeIO(uri: Uri)(client: Client[IO]): Resource[IO, SearchService[IO]] = - SimpleRestJsonBuilder - .apply(SearchService) - .client(client) - .uri(uri) - .resource - -class FutureClient(io: SearchService[IO]) extends SearchService[Future]: - - override def countForum(text: String, troll: Boolean): Future[CountResponse] = - io.countForum(text, troll).unsafeToFuture() - - override def searchForum(body: ForumInputBody, from: Int, size: Int): Future[SearchResponse] = - io.searchForum(body, from, size).unsafeToFuture() diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 6c9ac5ee..0c54eb72 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,9 +8,11 @@ object Dependencies { val fs2 = "3.10.2" val http4s = "0.23.27" val iron = "2.5.0" + val smithy4s = "0.18.16" } - def http4s(artifact: String) = "org.http4s" %% s"http4s-$artifact" % V.http4s + def http4s(artifact: String) = "org.http4s" %% s"http4s-$artifact" % V.http4s + def smithy4s(artifact: String) = "com.disneystreaming.smithy4s" %% s"smithy4s-$artifact" % V.smithy4s val catsCore = "org.typelevel" %% "cats-core" % "2.10.0" val catsEffect = "org.typelevel" %% "cats-effect" % V.catsEffect @@ -27,6 +29,15 @@ object Dependencies { val http4sClient = http4s("client") val http4sEmberClient = http4s("ember-client") + val smithy4sCore = smithy4s("core") + val smithy4sHttp4s = smithy4s("http4s") + val smithy4sHttp4sSwagger = smithy4s("http4s-swagger") + val smithy4sJson = smithy4s("json") + + val playWS = "com.typesafe.play" %% "play-ahc-ws-standalone" % "2.2.7" + + val elastic4s = "com.sksamuel.elastic4s" %% "elastic4s-effect-cats" % "8.11.5" + val log4Cats = "org.typelevel" %% "log4cats-slf4j" % "2.7.0" val logbackX = "ch.qos.logback" % "logback-classic" % "1.5.6"