diff --git a/modules/backend/src/main/scala/docspell/backend/BackendApp.scala b/modules/backend/src/main/scala/docspell/backend/BackendApp.scala index 3881d537..4aea530f 100644 --- a/modules/backend/src/main/scala/docspell/backend/BackendApp.scala +++ b/modules/backend/src/main/scala/docspell/backend/BackendApp.scala @@ -116,12 +116,11 @@ object BackendApp { def apply[F[_]: Async]( cfg: Config, - connectEC: ExecutionContext, - httpClientEc: ExecutionContext + connectEC: ExecutionContext )(ftsFactory: Client[F] => Resource[F, FtsClient[F]]): Resource[F, BackendApp[F]] = for { store <- Store.create(cfg.jdbc, cfg.files.chunkSize, connectEC) - httpClient <- BlazeClientBuilder[F](httpClientEc).resource + httpClient <- BlazeClientBuilder[F].resource ftsClient <- ftsFactory(httpClient) backend <- create(cfg, store, httpClient, ftsClient) } yield backend diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OJoex.scala b/modules/backend/src/main/scala/docspell/backend/ops/OJoex.scala index fb35267c..d4aaf956 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OJoex.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OJoex.scala @@ -6,8 +6,6 @@ package docspell.backend.ops -import scala.concurrent.ExecutionContext - import cats.data.OptionT import cats.effect._ import cats.implicits._ @@ -42,10 +40,7 @@ object OJoex { } yield cancel.success).getOrElse(false) }) - def create[F[_]: Async]( - ec: ExecutionContext, - store: Store[F] - ): Resource[F, OJoex[F]] = - JoexClient.resource(ec).flatMap(client => apply(client, store)) + def create[F[_]: Async](store: Store[F]): Resource[F, OJoex[F]] = + JoexClient.resource.flatMap(client => apply(client, store)) } diff --git a/modules/common/src/main/scala/docspell/common/Pools.scala b/modules/common/src/main/scala/docspell/common/Pools.scala index 20d2771c..a704bdbb 100644 --- a/modules/common/src/main/scala/docspell/common/Pools.scala +++ b/modules/common/src/main/scala/docspell/common/Pools.scala @@ -10,7 +10,7 @@ import scala.concurrent.ExecutionContext /** Captures thread pools to use in an application. */ case class Pools( - connectEC: ExecutionContext, - httpClientEC: ExecutionContext, - restEC: ExecutionContext + connectEC: ExecutionContext +// httpClientEC: ExecutionContext, +// restEC: ExecutionContext ) diff --git a/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala b/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala index 0f13bab4..86c65efc 100644 --- a/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala +++ b/modules/joex/src/main/scala/docspell/joex/JoexAppImpl.scala @@ -116,11 +116,10 @@ object JoexAppImpl { def create[F[_]: Async]( cfg: Config, termSignal: SignallingRef[F, Boolean], - connectEC: ExecutionContext, - clientEC: ExecutionContext + connectEC: ExecutionContext ): Resource[F, JoexApp[F]] = for { - httpClient <- BlazeClientBuilder[F](clientEC).resource + httpClient <- BlazeClientBuilder[F].resource client = JoexClient(httpClient) store <- Store.create(cfg.jdbc, cfg.files.chunkSize, connectEC) queue <- JobQueue(store) diff --git a/modules/joex/src/main/scala/docspell/joex/JoexServer.scala b/modules/joex/src/main/scala/docspell/joex/JoexServer.scala index 202c830f..8c4773dc 100644 --- a/modules/joex/src/main/scala/docspell/joex/JoexServer.scala +++ b/modules/joex/src/main/scala/docspell/joex/JoexServer.scala @@ -33,9 +33,7 @@ object JoexServer { val app = for { signal <- Resource.eval(SignallingRef[F, Boolean](false)) exitCode <- Resource.eval(Ref[F].of(ExitCode.Success)) - joexApp <- - JoexAppImpl - .create[F](cfg, signal, pools.connectEC, pools.httpClientEC) + joexApp <- JoexAppImpl.create[F](cfg, signal, pools.connectEC) httpApp = Router( "/api/info" -> InfoRoutes(cfg), @@ -50,7 +48,7 @@ object JoexServer { Stream .resource(app) .flatMap(app => - BlazeServerBuilder[F](pools.restEC) + BlazeServerBuilder[F] .bindHttp(cfg.bind.port, cfg.bind.address) .withHttpApp(app.httpApp) .withoutBanner diff --git a/modules/joex/src/main/scala/docspell/joex/Main.scala b/modules/joex/src/main/scala/docspell/joex/Main.scala index a288c0b5..fa20b0e5 100644 --- a/modules/joex/src/main/scala/docspell/joex/Main.scala +++ b/modules/joex/src/main/scala/docspell/joex/Main.scala @@ -60,11 +60,7 @@ object Main extends IOApp { logger.warn(">>>>> Docspell is running in DEV mode! <<<<<") } - val pools = for { - cec <- connectEC - bec <- blockingEC - rec <- restserverEC - } yield Pools(cec, bec, rec) + val pools = connectEC.map(Pools.apply) pools.use(p => JoexServer .stream[IO](cfg, p) diff --git a/modules/joex/src/main/scala/docspell/joex/hk/CheckNodesTask.scala b/modules/joex/src/main/scala/docspell/joex/hk/CheckNodesTask.scala index ebcf49f5..ecba752b 100644 --- a/modules/joex/src/main/scala/docspell/joex/hk/CheckNodesTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/hk/CheckNodesTask.scala @@ -26,7 +26,7 @@ object CheckNodesTask { for { _ <- ctx.logger.info("Check nodes reachability") ec = scala.concurrent.ExecutionContext.global - _ <- BlazeClientBuilder[F](ec).resource.use { client => + _ <- BlazeClientBuilder[F].withExecutionContext(ec).resource.use { client => checkNodes(ctx, client) } _ <- ctx.logger.info( diff --git a/modules/joexapi/src/main/scala/docspell/joexapi/client/JoexClient.scala b/modules/joexapi/src/main/scala/docspell/joexapi/client/JoexClient.scala index df2e5065..d6a6a5c7 100644 --- a/modules/joexapi/src/main/scala/docspell/joexapi/client/JoexClient.scala +++ b/modules/joexapi/src/main/scala/docspell/joexapi/client/JoexClient.scala @@ -6,8 +6,6 @@ package docspell.joexapi.client -import scala.concurrent.ExecutionContext - import cats.effect._ import cats.implicits._ @@ -69,6 +67,6 @@ object JoexClient { Uri.unsafeFromString(u.asString) } - def resource[F[_]: Async](ec: ExecutionContext): Resource[F, JoexClient[F]] = - BlazeClientBuilder[F](ec).resource.map(apply[F]) + def resource[F[_]: Async]: Resource[F, JoexClient[F]] = + BlazeClientBuilder[F].resource.map(apply[F]) } diff --git a/modules/restserver/src/main/scala/docspell/restserver/Main.scala b/modules/restserver/src/main/scala/docspell/restserver/Main.scala index d8d838ac..7d441783 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/Main.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/Main.scala @@ -55,12 +55,7 @@ object Main extends IOApp { cfg.baseUrl, Some(cfg.fullTextSearch.solr.url).filter(_ => cfg.fullTextSearch.enabled) ) - val pools = for { - cec <- connectEC - bec <- blockingEC - rec <- restserverEC - } yield Pools(cec, bec, rec) - + val pools = connectEC.map(Pools.apply) logger.info(s"\n${banner.render("***>")}") if (EnvMode.current.isDev) { logger.warn(">>>>> Docspell is running in DEV mode! <<<<<") diff --git a/modules/restserver/src/main/scala/docspell/restserver/RestAppImpl.scala b/modules/restserver/src/main/scala/docspell/restserver/RestAppImpl.scala index fbfbd0e1..74b6a303 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/RestAppImpl.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/RestAppImpl.scala @@ -32,11 +32,10 @@ object RestAppImpl { def create[F[_]: Async]( cfg: Config, - connectEC: ExecutionContext, - httpClientEc: ExecutionContext + connectEC: ExecutionContext ): Resource[F, RestApp[F]] = for { - backend <- BackendApp(cfg.backend, connectEC, httpClientEc)( + backend <- BackendApp(cfg.backend, connectEC)( createFtsClient[F](cfg) ) app = new RestAppImpl[F](cfg, backend) diff --git a/modules/restserver/src/main/scala/docspell/restserver/RestServer.scala b/modules/restserver/src/main/scala/docspell/restserver/RestServer.scala index 9881fdcc..f64f0a93 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/RestServer.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/RestServer.scala @@ -34,10 +34,8 @@ object RestServer { val templates = TemplateRoutes[F](cfg) val app = for { - restApp <- - RestAppImpl - .create[F](cfg, pools.connectEC, pools.httpClientEC) - httpClient <- BlazeClientBuilder[F](pools.httpClientEC).resource + restApp <- RestAppImpl.create[F](cfg, pools.connectEC) + httpClient <- BlazeClientBuilder[F].resource httpApp = Router( "/api/info" -> routes.InfoRoutes(), "/api/v1/open/" -> openRoutes(cfg, httpClient, restApp), @@ -64,7 +62,7 @@ object RestServer { Stream .resource(app) .flatMap(httpApp => - BlazeServerBuilder[F](pools.restEC) + BlazeServerBuilder[F] .bindHttp(cfg.bind.port, cfg.bind.address) .withHttpApp(httpApp) .withoutBanner diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c97cfd87..c53bcc6c 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -19,7 +19,7 @@ object Dependencies { val Fs2Version = "3.1.6" val Fs2CronVersion = "0.7.1" val H2Version = "1.4.200" - val Http4sVersion = "0.23.4" + val Http4sVersion = "0.23.6" val Icu4jVersion = "69.1" val javaOtpVersion = "0.3.0" val JsoupVersion = "1.14.3"