mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Update http4s to 0.21.4
This commit is contained in:
@ -2,6 +2,7 @@ package docspell.joex
|
||||
|
||||
import cats.effect._
|
||||
import cats.effect.concurrent.Ref
|
||||
import docspell.common.Pools
|
||||
import docspell.joex.routes._
|
||||
import org.http4s.server.blaze.BlazeServerBuilder
|
||||
import org.http4s.implicits._
|
||||
@ -11,8 +12,6 @@ import org.http4s.HttpApp
|
||||
import org.http4s.server.middleware.Logger
|
||||
import org.http4s.server.Router
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
object JoexServer {
|
||||
|
||||
private case class App[F[_]](
|
||||
@ -23,15 +22,14 @@ object JoexServer {
|
||||
|
||||
def stream[F[_]: ConcurrentEffect: ContextShift](
|
||||
cfg: Config,
|
||||
connectEC: ExecutionContext,
|
||||
clientEC: ExecutionContext,
|
||||
blocker: Blocker
|
||||
pools: Pools
|
||||
)(implicit T: Timer[F]): Stream[F, Nothing] = {
|
||||
|
||||
val app = for {
|
||||
signal <- Resource.liftF(SignallingRef[F, Boolean](false))
|
||||
exitCode <- Resource.liftF(Ref[F].of(ExitCode.Success))
|
||||
joexApp <- JoexAppImpl.create[F](cfg, signal, connectEC, clientEC, blocker)
|
||||
joexApp <- JoexAppImpl
|
||||
.create[F](cfg, signal, pools.connectEC, pools.httpClientEC, pools.blocker)
|
||||
|
||||
httpApp = Router(
|
||||
"/api/info" -> InfoRoutes(),
|
||||
@ -46,7 +44,7 @@ object JoexServer {
|
||||
Stream
|
||||
.resource(app)
|
||||
.flatMap(app =>
|
||||
BlazeServerBuilder[F]
|
||||
BlazeServerBuilder[F](pools.restEC)
|
||||
.bindHttp(cfg.bind.port, cfg.bind.address)
|
||||
.withHttpApp(app.httpApp)
|
||||
.withoutBanner
|
||||
|
@ -4,9 +4,8 @@ import cats.effect.{Blocker, ExitCode, IO, IOApp}
|
||||
import cats.implicits._
|
||||
|
||||
import java.nio.file.{Files, Paths}
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
import docspell.common.{Banner, ThreadFactories}
|
||||
import docspell.common.{Banner, Pools, ThreadFactories}
|
||||
import org.log4s._
|
||||
|
||||
object Main extends IOApp {
|
||||
@ -16,6 +15,8 @@ object Main extends IOApp {
|
||||
ThreadFactories.cached[IO](ThreadFactories.ofName("docspell-joex-blocking"))
|
||||
val connectEC =
|
||||
ThreadFactories.fixed[IO](5, ThreadFactories.ofName("docspell-joex-dbconnect"))
|
||||
val restserverEC =
|
||||
ThreadFactories.workSteal[IO](ThreadFactories.ofNameFJ("docspell-joex-server"))
|
||||
|
||||
def run(args: List[String]) = {
|
||||
args match {
|
||||
@ -52,19 +53,14 @@ object Main extends IOApp {
|
||||
cec <- connectEC
|
||||
bec <- blockingEC
|
||||
blocker = Blocker.liftExecutorService(bec)
|
||||
} yield Pools(cec, bec, blocker)
|
||||
rec <- restserverEC
|
||||
} yield Pools(cec, bec, blocker, rec)
|
||||
pools.use(p =>
|
||||
JoexServer
|
||||
.stream[IO](cfg, p.connectEC, p.clientEC, p.blocker)
|
||||
.stream[IO](cfg, p)
|
||||
.compile
|
||||
.drain
|
||||
.as(ExitCode.Success)
|
||||
)
|
||||
}
|
||||
|
||||
case class Pools(
|
||||
connectEC: ExecutionContext,
|
||||
clientEC: ExecutionContext,
|
||||
blocker: Blocker
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user