mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-04 12:30:12 +00:00 
			
		
		
		
	Merge pull request #2338 from rehanone/update-http4s-server
Replace `http4s-blaze-server` with `http4s-ember-server`.
This commit is contained in:
		@@ -802,6 +802,7 @@ val joex = project
 | 
				
			|||||||
        Dependencies.http4sDsl ++
 | 
					        Dependencies.http4sDsl ++
 | 
				
			||||||
        Dependencies.circe ++
 | 
					        Dependencies.circe ++
 | 
				
			||||||
        Dependencies.pureconfig ++
 | 
					        Dependencies.pureconfig ++
 | 
				
			||||||
 | 
					        Dependencies.pureconfigIp4s ++
 | 
				
			||||||
        Dependencies.emilTnef ++
 | 
					        Dependencies.emilTnef ++
 | 
				
			||||||
        Dependencies.poi ++
 | 
					        Dependencies.poi ++
 | 
				
			||||||
        Dependencies.emilMarkdown ++
 | 
					        Dependencies.emilMarkdown ++
 | 
				
			||||||
@@ -859,6 +860,7 @@ val restserver = project
 | 
				
			|||||||
        Dependencies.http4sDsl ++
 | 
					        Dependencies.http4sDsl ++
 | 
				
			||||||
        Dependencies.circe ++
 | 
					        Dependencies.circe ++
 | 
				
			||||||
        Dependencies.pureconfig ++
 | 
					        Dependencies.pureconfig ++
 | 
				
			||||||
 | 
					        Dependencies.pureconfigIp4s ++
 | 
				
			||||||
        Dependencies.yamusca ++
 | 
					        Dependencies.yamusca ++
 | 
				
			||||||
        Dependencies.kittens ++
 | 
					        Dependencies.kittens ++
 | 
				
			||||||
        Dependencies.webjars,
 | 
					        Dependencies.webjars,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,8 @@ import docspell.pubsub.naive.PubSubConfig
 | 
				
			|||||||
import docspell.scheduler.{PeriodicSchedulerConfig, SchedulerConfig}
 | 
					import docspell.scheduler.{PeriodicSchedulerConfig, SchedulerConfig}
 | 
				
			||||||
import docspell.store.{JdbcConfig, SchemaMigrateConfig}
 | 
					import docspell.store.{JdbcConfig, SchemaMigrateConfig}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.comcast.ip4s.{Host, Port}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case class Config(
 | 
					case class Config(
 | 
				
			||||||
    appId: Ident,
 | 
					    appId: Ident,
 | 
				
			||||||
    baseUrl: LenientUri,
 | 
					    baseUrl: LenientUri,
 | 
				
			||||||
@@ -59,7 +61,7 @@ case class Config(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
object Config {
 | 
					object Config {
 | 
				
			||||||
  case class Bind(address: String, port: Int)
 | 
					  case class Bind(address: Host, port: Port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) {
 | 
					  case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) {
 | 
				
			||||||
    def mailBatchSize: Int =
 | 
					    def mailBatchSize: Int =
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@ import emil.MailAddress
 | 
				
			|||||||
import emil.javamail.syntax._
 | 
					import emil.javamail.syntax._
 | 
				
			||||||
import pureconfig._
 | 
					import pureconfig._
 | 
				
			||||||
import pureconfig.generic.auto._
 | 
					import pureconfig.generic.auto._
 | 
				
			||||||
 | 
					import pureconfig.module.ip4s._
 | 
				
			||||||
import yamusca.imports._
 | 
					import yamusca.imports._
 | 
				
			||||||
 | 
					
 | 
				
			||||||
object ConfigFile {
 | 
					object ConfigFile {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package docspell.joex
 | 
					package docspell.joex
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cats.effect.Ref
 | 
					 | 
				
			||||||
import cats.effect._
 | 
					import cats.effect._
 | 
				
			||||||
import fs2.Stream
 | 
					import fs2.Stream
 | 
				
			||||||
import fs2.concurrent.SignallingRef
 | 
					import fs2.concurrent.SignallingRef
 | 
				
			||||||
@@ -19,8 +18,8 @@ import docspell.store.Store
 | 
				
			|||||||
import docspell.store.records.RInternalSetting
 | 
					import docspell.store.records.RInternalSetting
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.http4s.HttpApp
 | 
					import org.http4s.HttpApp
 | 
				
			||||||
import org.http4s.blaze.server.BlazeServerBuilder
 | 
					 | 
				
			||||||
import org.http4s.ember.client.EmberClientBuilder
 | 
					import org.http4s.ember.client.EmberClientBuilder
 | 
				
			||||||
 | 
					import org.http4s.ember.server.EmberServerBuilder
 | 
				
			||||||
import org.http4s.implicits._
 | 
					import org.http4s.implicits._
 | 
				
			||||||
import org.http4s.server.Router
 | 
					import org.http4s.server.Router
 | 
				
			||||||
import org.http4s.server.middleware.Logger
 | 
					import org.http4s.server.middleware.Logger
 | 
				
			||||||
@@ -70,13 +69,15 @@ object JoexServer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    Stream
 | 
					    Stream
 | 
				
			||||||
      .resource(app)
 | 
					      .resource(app)
 | 
				
			||||||
      .flatMap(app =>
 | 
					      .flatMap { app =>
 | 
				
			||||||
        BlazeServerBuilder[F]
 | 
					        Stream.resource {
 | 
				
			||||||
          .bindHttp(cfg.bind.port, cfg.bind.address)
 | 
					          EmberServerBuilder
 | 
				
			||||||
          .withHttpApp(app.httpApp)
 | 
					            .default[F]
 | 
				
			||||||
          .withoutBanner
 | 
					            .withHost(cfg.bind.address)
 | 
				
			||||||
          .serveWhile(app.termSig, app.exitRef)
 | 
					            .withPort(cfg.bind.port)
 | 
				
			||||||
      )
 | 
					            .withHttpApp(app.httpApp)
 | 
				
			||||||
 | 
					            .build
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
  }.drain
 | 
					  }.drain
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ import docspell.restserver.Config.{DownloadAllCfg, OpenIdConfig, ServerOptions}
 | 
				
			|||||||
import docspell.restserver.auth.OpenId
 | 
					import docspell.restserver.auth.OpenId
 | 
				
			||||||
import docspell.restserver.http4s.InternalHeader
 | 
					import docspell.restserver.http4s.InternalHeader
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.comcast.ip4s.IpAddress
 | 
					import com.comcast.ip4s.{Host, IpAddress, Port}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
case class Config(
 | 
					case class Config(
 | 
				
			||||||
    appName: String,
 | 
					    appName: String,
 | 
				
			||||||
@@ -63,7 +63,7 @@ object Config {
 | 
				
			|||||||
      enableHttp2: Boolean,
 | 
					      enableHttp2: Boolean,
 | 
				
			||||||
      maxConnections: Int
 | 
					      maxConnections: Int
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  case class Bind(address: String, port: Int)
 | 
					  case class Bind(address: Host, port: Port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  case class AdminEndpoint(secret: String)
 | 
					  case class AdminEndpoint(secret: String)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ import docspell.store.Db
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import pureconfig._
 | 
					import pureconfig._
 | 
				
			||||||
import pureconfig.generic.auto._
 | 
					import pureconfig.generic.auto._
 | 
				
			||||||
 | 
					import pureconfig.module.ip4s._
 | 
				
			||||||
import scodec.bits.ByteVector
 | 
					import scodec.bits.ByteVector
 | 
				
			||||||
 | 
					
 | 
				
			||||||
object ConfigFile {
 | 
					object ConfigFile {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,9 +24,9 @@ import docspell.store.Store
 | 
				
			|||||||
import docspell.store.records.RInternalSetting
 | 
					import docspell.store.records.RInternalSetting
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.http4s._
 | 
					import org.http4s._
 | 
				
			||||||
import org.http4s.blaze.server.BlazeServerBuilder
 | 
					 | 
				
			||||||
import org.http4s.dsl.Http4sDsl
 | 
					import org.http4s.dsl.Http4sDsl
 | 
				
			||||||
import org.http4s.ember.client.EmberClientBuilder
 | 
					import org.http4s.ember.client.EmberClientBuilder
 | 
				
			||||||
 | 
					import org.http4s.ember.server.EmberServerBuilder
 | 
				
			||||||
import org.http4s.headers.Location
 | 
					import org.http4s.headers.Location
 | 
				
			||||||
import org.http4s.implicits._
 | 
					import org.http4s.implicits._
 | 
				
			||||||
import org.http4s.server.Router
 | 
					import org.http4s.server.Router
 | 
				
			||||||
@@ -56,20 +56,27 @@ object RestServer {
 | 
				
			|||||||
            Stream(
 | 
					            Stream(
 | 
				
			||||||
              restApp.subscriptions,
 | 
					              restApp.subscriptions,
 | 
				
			||||||
              restApp.eventConsume(2),
 | 
					              restApp.eventConsume(2),
 | 
				
			||||||
              BlazeServerBuilder[F]
 | 
					              Stream.resource {
 | 
				
			||||||
                .bindHttp(cfg.bind.port, cfg.bind.address)
 | 
					                if (cfg.serverOptions.enableHttp2)
 | 
				
			||||||
                .withoutBanner
 | 
					                  EmberServerBuilder
 | 
				
			||||||
                .withResponseHeaderTimeout(cfg.serverOptions.responseTimeout.toScala)
 | 
					                    .default[F]
 | 
				
			||||||
                .enableHttp2(cfg.serverOptions.enableHttp2)
 | 
					                    .withHost(cfg.bind.address)
 | 
				
			||||||
                .withMaxConnections(cfg.serverOptions.maxConnections)
 | 
					                    .withPort(cfg.bind.port)
 | 
				
			||||||
                .withHttpWebSocketApp(
 | 
					                    .withMaxConnections(cfg.serverOptions.maxConnections)
 | 
				
			||||||
                  createHttpApp(setting, pubSub, restApp)
 | 
					                    .withHttpWebSocketApp(createHttpApp(setting, pubSub, restApp))
 | 
				
			||||||
                )
 | 
					                    .withHttp2
 | 
				
			||||||
                .serve
 | 
					                    .build
 | 
				
			||||||
                .drain
 | 
					                else
 | 
				
			||||||
 | 
					                  EmberServerBuilder
 | 
				
			||||||
 | 
					                    .default[F]
 | 
				
			||||||
 | 
					                    .withHost(cfg.bind.address)
 | 
				
			||||||
 | 
					                    .withPort(cfg.bind.port)
 | 
				
			||||||
 | 
					                    .withMaxConnections(cfg.serverOptions.maxConnections)
 | 
				
			||||||
 | 
					                    .withHttpWebSocketApp(createHttpApp(setting, pubSub, restApp))
 | 
				
			||||||
 | 
					                    .build
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					 | 
				
			||||||
      exit <-
 | 
					      exit <-
 | 
				
			||||||
        (server ++ Stream(keepAlive)).parJoinUnbounded.compile.drain.as(ExitCode.Success)
 | 
					        (server ++ Stream(keepAlive)).parJoinUnbounded.compile.drain.as(ExitCode.Success)
 | 
				
			||||||
    } yield exit
 | 
					    } yield exit
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ import org.typelevel.ci.CIString
 | 
				
			|||||||
object ClientRequestInfo {
 | 
					object ClientRequestInfo {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def getBaseUrl[F[_]](cfg: Config, req: Request[F]): LenientUri =
 | 
					  def getBaseUrl[F[_]](cfg: Config, req: Request[F]): LenientUri =
 | 
				
			||||||
    if (cfg.baseUrl.isLocal) getBaseUrl(req, cfg.bind.port).getOrElse(cfg.baseUrl)
 | 
					    if (cfg.baseUrl.isLocal) getBaseUrl(req, cfg.bind.port.value).getOrElse(cfg.baseUrl)
 | 
				
			||||||
    else cfg.baseUrl
 | 
					    else cfg.baseUrl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private def getBaseUrl[F[_]](req: Request[F], serverPort: Int): Option[LenientUri] =
 | 
					  private def getBaseUrl[F[_]](req: Request[F], serverPort: Int): Option[LenientUri] =
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -251,7 +251,7 @@ object Dependencies {
 | 
				
			|||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val http4sServer = Seq(
 | 
					  val http4sServer = Seq(
 | 
				
			||||||
    "org.http4s" %% "http4s-blaze-server" % "0.23.14"
 | 
					    "org.http4s" %% "http4s-ember-server" % Http4sVersion
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val circeCore = Seq(
 | 
					  val circeCore = Seq(
 | 
				
			||||||
@@ -277,6 +277,10 @@ object Dependencies {
 | 
				
			|||||||
    "com.github.pureconfig" %% "pureconfig" % PureConfigVersion
 | 
					    "com.github.pureconfig" %% "pureconfig" % PureConfigVersion
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  val pureconfigIp4s = Seq(
 | 
				
			||||||
 | 
					    "com.github.pureconfig" %% "pureconfig-ip4s" % PureConfigVersion
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // https://github.com/h2database/h2database
 | 
					  // https://github.com/h2database/h2database
 | 
				
			||||||
  // MPL 2.0 or EPL 1.0
 | 
					  // MPL 2.0 or EPL 1.0
 | 
				
			||||||
  val h2 = Seq(
 | 
					  val h2 = Seq(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user