From 814335646881afa022205d5e43b6062597999354 Mon Sep 17 00:00:00 2001 From: Kai <450507+neko-kai@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:08:30 +0100 Subject: [PATCH] Update to http4s 1.0 milestone --- build.sbt | 472 +----------------- .../runtime/rpc/http4s/HttpServer.scala | 10 +- .../http4s/clients/HttpRpcDispatcher.scala | 6 +- .../clients/HttpRpcDispatcherFactory.scala | 78 ++- .../rpc/http4s/Http4sTransportTest.scala | 2 + project/Deps.sc | 7 +- project/Versions.scala | 4 +- version.sbt | 2 +- 8 files changed, 104 insertions(+), 477 deletions(-) diff --git a/build.sbt b/build.sbt index 70bf0db1..3f1bafbc 100644 --- a/build.sbt +++ b/build.sbt @@ -77,49 +77,6 @@ lazy val `idealingua-v1-model` = crossProject(JVMPlatform, JSPlatform).crossType }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -168,16 +125,14 @@ lazy val `idealingua-v1-model` = crossProject(JVMPlatform, JSPlatform).crossType .jvmSettings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head ) .jsSettings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, coverageEnabled := false, @@ -252,49 +207,6 @@ lazy val `idealingua-v1-core` = crossProject(JVMPlatform, JSPlatform).crossType( }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -342,15 +254,13 @@ lazy val `idealingua-v1-core` = crossProject(JVMPlatform, JSPlatform).crossType( ) .jvmSettings( crossScalaVersions := Seq( - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head ) .jsSettings( crossScalaVersions := Seq( - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, coverageEnabled := false, @@ -440,49 +350,6 @@ lazy val `idealingua-v1-runtime-rpc-scala` = crossProject(JVMPlatform, JSPlatfor }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -531,16 +398,14 @@ lazy val `idealingua-v1-runtime-rpc-scala` = crossProject(JVMPlatform, JSPlatfor .jvmSettings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head ) .jsSettings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, coverageEnabled := false, @@ -579,8 +444,7 @@ lazy val `idealingua-v1-runtime-rpc-http4s` = project.in(file("idealingua-v1/ide .settings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -633,49 +497,6 @@ lazy val `idealingua-v1-runtime-rpc-http4s` = project.in(file("idealingua-v1/ide }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -802,49 +623,6 @@ lazy val `idealingua-v1-transpilers` = crossProject(JVMPlatform, JSPlatform).cro }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -892,16 +670,14 @@ lazy val `idealingua-v1-transpilers` = crossProject(JVMPlatform, JSPlatform).cro ) .jvmSettings( crossScalaVersions := Seq( - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, Test / fork := true ) .jsSettings( crossScalaVersions := Seq( - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, coverageEnabled := false, @@ -940,8 +716,7 @@ lazy val `idealingua-v1-test-defs` = project.in(file("idealingua-v1/idealingua-v .settings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -994,49 +769,6 @@ lazy val `idealingua-v1-test-defs` = project.in(file("idealingua-v1/idealingua-v }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -1096,8 +828,7 @@ lazy val `idealingua-v1-runtime-rpc-typescript` = project.in(file("idealingua-v1 .settings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -1150,49 +881,6 @@ lazy val `idealingua-v1-runtime-rpc-typescript` = project.in(file("idealingua-v1 }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -1252,8 +940,7 @@ lazy val `idealingua-v1-runtime-rpc-go` = project.in(file("idealingua-v1/idealin .settings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -1306,49 +993,6 @@ lazy val `idealingua-v1-runtime-rpc-go` = project.in(file("idealingua-v1/idealin }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -1408,8 +1052,7 @@ lazy val `idealingua-v1-runtime-rpc-csharp` = project.in(file("idealingua-v1/ide .settings( crossScalaVersions := Seq( "3.4.2", - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -1462,49 +1105,6 @@ lazy val `idealingua-v1-runtime-rpc-csharp` = project.in(file("idealingua-v1/ide }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", @@ -1572,8 +1172,7 @@ lazy val `idealingua-v1-compiler` = project.in(file("idealingua-v1/idealingua-v1 ) .settings( crossScalaVersions := Seq( - "2.13.14", - "2.12.19" + "2.13.14" ), scalaVersion := crossScalaVersions.value.head, organization := "io.7mind.izumi", @@ -1626,49 +1225,6 @@ lazy val `idealingua-v1-compiler` = project.in(file("idealingua-v1/idealingua-v1 }, Test / testOptions += Tests.Argument("-oDF"), scalacOptions ++= { (isSnapshot.value, scalaVersion.value) match { - case (_, "2.12.19") => Seq( - "-release:8", - "-explaintypes", - "-Xsource:3", - "-P:kind-projector:underscore-placeholders", - "-Ypartial-unification", - if (insideCI.value) "-Wconf:any:error" else "-Wconf:any:warning", - "-Wconf:cat=optimizer:warning", - "-Wconf:cat=other-match-analysis:error", - "-Ybackend-parallelism", - math.min(16, math.max(1, sys.runtime.availableProcessors() - 1)).toString, - "-Xlint:adapted-args", - "-Xlint:by-name-right-associative", - "-Xlint:constant", - "-Xlint:delayedinit-select", - "-Xlint:doc-detached", - "-Xlint:inaccessible", - "-Xlint:infer-any", - "-Xlint:missing-interpolator", - "-Xlint:nullary-override", - "-Xlint:nullary-unit", - "-Xlint:option-implicit", - "-Xlint:package-object-classes", - "-Xlint:poly-implicit-overload", - "-Xlint:private-shadow", - "-Xlint:stars-align", - "-Xlint:type-parameter-shadow", - "-Xlint:unsound-match", - "-opt-warnings:_", - "-Ywarn-extra-implicit", - "-Ywarn-unused:_", - "-Ywarn-adapted-args", - "-Ywarn-dead-code", - "-Ywarn-inaccessible", - "-Ywarn-infer-any", - "-Ywarn-nullary-override", - "-Ywarn-nullary-unit", - "-Ywarn-numeric-widen", - "-Ywarn-unused-import", - "-Ywarn-value-discard", - "-Ycache-plugin-class-loader:always", - "-Ycache-macro-class-loader:last-modified" - ) case (_, "2.13.14") => Seq( "-release:8", "-explaintypes", diff --git a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/HttpServer.scala b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/HttpServer.scala index e9471df7..b430f0b3 100644 --- a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/HttpServer.scala +++ b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/HttpServer.scala @@ -18,7 +18,7 @@ import izumi.idealingua.runtime.rpc.http4s.ws.* import logstage.LogIO2 import org.http4s.* import org.http4s.dsl.Http4sDsl -import org.http4s.server.websocket.WebSocketBuilder2 +import org.http4s.server.websocket.WebSocketBuilder import org.http4s.websocket.WebSocketFrame import org.typelevel.ci.CIString import org.typelevel.vault.Key @@ -46,20 +46,20 @@ class HttpServer[F[+_, +_]: IO2: Temporal2: Primitives2: UnsafeRun2, AuthCtx]( protected val wsHeartbeatTimeout: FiniteDuration = 1.minute protected val wsHeartbeatInterval: FiniteDuration = 10.seconds - def service(ws: WebSocketBuilder2[F[Throwable, _]]): HttpRoutes[F[Throwable, _]] = { + def service(ws: WebSocketBuilder[F[Throwable, _]]): HttpRoutes[F[Throwable, _]] = { val svc = HttpRoutes.of(router(ws)) loggingMiddle(svc) } - protected def router(ws: WebSocketBuilder2[F[Throwable, _]]): PartialFunction[Request[F[Throwable, _]], F[Throwable, Response[F[Throwable, _]]]] = { + protected def router(ws: WebSocketBuilder[F[Throwable, _]]): PartialFunction[Request[F[Throwable, _]], F[Throwable, Response[F[Throwable, _]]]] = { case request @ GET -> Root / "ws" => setupWs(request, ws) case request @ GET -> Root / service / method => processHttpRequest(request, service, method)("{}") - case request @ POST -> Root / service / method => request.decode[String](processHttpRequest(request, service, method)) + case request @ POST -> Root / service / method => request.decode(processHttpRequest(request, service, method)) } protected def setupWs( request: Request[F[Throwable, _]], - ws: WebSocketBuilder2[F[Throwable, _]], + ws: WebSocketBuilder[F[Throwable, _]], ): F[Throwable, Response[F[Throwable, _]]] = { Quirks.discard(request) def pingStream(clientSession: WsClientSession[F, AuthCtx]): Stream[F[Throwable, _], WebSocketFrame] = { diff --git a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcher.scala b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcher.scala index eefd1b91..e2842c29 100644 --- a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcher.scala +++ b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcher.scala @@ -1,7 +1,6 @@ package izumi.idealingua.runtime.rpc.http4s.clients import cats.effect.Async -import fs2.Stream import io.circe import io.circe.parser.parse import izumi.functional.bio.{Exit, F, IO2} @@ -10,7 +9,8 @@ import izumi.idealingua.runtime.rpc.http4s.IRTUnexpectedHttpStatus import izumi.idealingua.runtime.rpc.http4s.clients.HttpRpcDispatcher.IRTDispatcherRaw import logstage.LogIO2 import org.http4s.client.Client -import org.http4s.{Request, Response, Status, Uri} +import org.http4s.{Entity, Request, Response, Status, Uri} +import scodec.bits.ByteVector class HttpRpcDispatcher[F[+_, +_]: IO2]( client: Client[F[Throwable, _]], @@ -92,7 +92,7 @@ class HttpRpcDispatcher[F[+_, +_]: IO2]( ): Request[F[Throwable, _]] = { val uri = baseUri / method.service.value / method.methodId.value if (body.nonEmpty) { - Request[F[Throwable, _]](org.http4s.Method.POST, uri, body = Stream.emits[F[Throwable, _], Byte](body)) + Request[F[Throwable, _]](org.http4s.Method.POST, uri, entity = Entity.strict(ByteVector.view(body))) } else { Request[F[Throwable, _]](org.http4s.Method.GET, uri) } diff --git a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcherFactory.scala b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcherFactory.scala index 7247fac6..8dd3513d 100644 --- a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcherFactory.scala +++ b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/main/scala/izumi/idealingua/runtime/rpc/http4s/clients/HttpRpcDispatcherFactory.scala @@ -2,16 +2,17 @@ package izumi.idealingua.runtime.rpc.http4s.clients import cats.effect.Async import io.circe -import izumi.functional.bio.{F, IO2} +import izumi.functional.bio.{Applicative2, F, IO2} import izumi.functional.lifecycle.Lifecycle import izumi.fundamentals.platform.language.Quirks.Discarder -import izumi.idealingua.runtime.rpc.http4s.HttpExecutionContext import izumi.idealingua.runtime.rpc.{IRTClientMultiplexor, IRTMethodId, IRTMuxRequest, IRTMuxResponse} -import logstage.LogIO2 +import izumi.logstage.api.rendering.AnyEncoded +import logstage.{Log, LogIO2} import org.http4s.client.Client import org.http4s.ember.client.EmberClientBuilder import org.http4s.{Header, Headers, Request, Uri} import org.typelevel.ci.CIString +import org.typelevel.log4cats.{LoggerFactory, SelfAwareStructuredLogger} class HttpRpcDispatcherFactory[F[+_, +_]: IO2]( codec: IRTClientMultiplexor[F], @@ -64,6 +65,8 @@ class HttpRpcDispatcherFactory[F[+_, +_]: IO2]( protected def emberClient: Lifecycle[F[Throwable, _], Client[F[Throwable, _]]] = { Lifecycle.fromCats { emberClientBuilder { + implicit def _logger: LogIO2[F] = logger + import HttpRpcDispatcherFactory._hacky_loggerFactory EmberClientBuilder.default[F[Throwable, _]] }.build } @@ -74,3 +77,72 @@ class HttpRpcDispatcherFactory[F[+_, +_]: IO2]( } } + +object HttpRpcDispatcherFactory { + + implicit def _hacky_loggerFactory[F[+_, +_]: Applicative2](implicit logger: LogIO2[F]): LoggerFactory[F[Throwable, _]] = new LoggerFactory[F[Throwable, _]] { + override def getLoggerFromName(name: String): SelfAwareStructuredLogger[F[Throwable, _]] = new SelfAwareStructuredLogger[F[Throwable, _]] { + override def isTraceEnabled: F[Throwable, Boolean] = F.pure(true) + override def isDebugEnabled: F[Throwable, Boolean] = F.pure(true) + override def isInfoEnabled: F[Throwable, Boolean] = F.pure(true) + override def isWarnEnabled: F[Throwable, Boolean] = F.pure(true) + override def isErrorEnabled: F[Throwable, Boolean] = F.pure(true) + + override def trace(ctx: Map[String, String])(msg: => String): F[Throwable, Unit] = + log(Log.Level.Trace, msg, ctx) + override def trace(ctx: Map[String, String], t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Trace, msg, ctx, t) + override def trace(t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Trace, msg, t = t) + override def trace(msg: => String): F[Throwable, Unit] = + log(Log.Level.Trace, msg) + + override def debug(ctx: Map[String, String])(msg: => String): F[Throwable, Unit] = + log(Log.Level.Debug, msg, ctx) + override def debug(ctx: Map[String, String], t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Debug, msg, ctx, t) + override def debug(t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Debug, msg, t = t) + override def debug(msg: => String): F[Throwable, Unit] = + log(Log.Level.Debug, msg) + + override def info(ctx: Map[String, String])(msg: => String): F[Throwable, Unit] = + log(Log.Level.Info, msg, ctx) + override def info(ctx: Map[String, String], t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Info, msg, ctx, t) + override def info(t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Info, msg, t = t) + override def info(msg: => String): F[Throwable, Unit] = + log(Log.Level.Info, msg) + + override def warn(ctx: Map[String, String])(msg: => String): F[Throwable, Unit] = + log(Log.Level.Warn, msg, ctx) + override def warn(ctx: Map[String, String], t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Warn, msg, ctx, t) + override def warn(t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Warn, msg, t = t) + override def warn(msg: => String): F[Throwable, Unit] = + log(Log.Level.Warn, msg) + + override def error(ctx: Map[String, String])(msg: => String): F[Throwable, Unit] = + log(Log.Level.Error, msg, ctx) + override def error(ctx: Map[String, String], t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Error, msg, ctx, t) + override def error(t: Throwable)(msg: => String): F[Throwable, Unit] = + log(Log.Level.Error, msg, t = t) + override def error(msg: => String): F[Throwable, Unit] = + log(Log.Level.Error, msg) + + private[this] def log(level: Log.Level, msg: => String, ctx: Map[String, String] = null, t: Throwable = null): F[Nothing, Unit] = { + import scala.util.chaining.* + logger + .pipe(l => Option(ctx).fold(l)(c => l.withCustomContextMap(c.view.mapValues(AnyEncoded.to).toMap))) + .pipe(l => Option(t).fold(l)(t => l.withCustomContext("error" -> t))) + .log(level)(Log.Message.raw(msg)) + } + } + + override def fromName(name: String): F[Throwable, SelfAwareStructuredLogger[F[Throwable, _]]] = F.pure(getLoggerFromName(name)) + } + +} diff --git a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/test/scala/izumi/idealingua/runtime/rpc/http4s/Http4sTransportTest.scala b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/test/scala/izumi/idealingua/runtime/rpc/http4s/Http4sTransportTest.scala index ffe47ba6..cac9b3a6 100644 --- a/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/test/scala/izumi/idealingua/runtime/rpc/http4s/Http4sTransportTest.scala +++ b/idealingua-v1/idealingua-v1-runtime-rpc-http4s/src/test/scala/izumi/idealingua/runtime/rpc/http4s/Http4sTransportTest.scala @@ -84,6 +84,8 @@ object Http4sTransportTest { port = addr.getPort host = addr.getHostName _ <- Lifecycle.fromCats { + implicit def _logger: LogIO2[F] = logger + import HttpRpcDispatcherFactory._hacky_loggerFactory EmberServerBuilder .default[F[Throwable, _]] .withPort(Port.fromInt(port).get) diff --git a/project/Deps.sc b/project/Deps.sc index b44d7f70..e9501822 100644 --- a/project/Deps.sc +++ b/project/Deps.sc @@ -135,7 +135,6 @@ object Idealingua { import Deps._ // DON'T REMOVE, these variables are read from CI build (build.sh) - final val scala212 = ScalaVersion("2.12.19") final val scala213 = ScalaVersion("2.13.14") final val scala300 = ScalaVersion("3.4.2") @@ -145,9 +144,8 @@ object Idealingua { object Targets { // switch order to use 2.13 in IDEA -// val targetScala = Seq(scala212, scala213) - val targetScala2 = Seq(scala213, scala212) - val targetScala3 = Seq(scala300, scala213, scala212) + val targetScala2 = Seq(scala213) + val targetScala3 = Seq(scala300, scala213) private val jvmPlatform2 = PlatformEnv( platform = Platform.Jvm, language = targetScala2, @@ -265,7 +263,6 @@ object Idealingua { "testOptions" in SettingScope.Test += """Tests.Argument("-oDF")""".raw, // "testOptions" in (SettingScope.Test, Platform.Jvm) ++= s"""Seq(Tests.Argument("-u"), Tests.Argument(s"$${target.value}/junit-xml-$${scalaVersion.value}"))""".raw, "scalacOptions" ++= Seq( - SettingKey(Some(scala212), None) := Defaults.Scala212Options, SettingKey(Some(scala213), None) := Defaults.Scala213Options, SettingKey(Some(scala300), None) := Defaults.Scala3Options, SettingKey.Default := Const.EmptySeq, diff --git a/project/Versions.scala b/project/Versions.scala index b468e48d..fe44bcd8 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -3,8 +3,8 @@ object V { val scalatest = "3.2.18" - val http4s = "0.23.27" - val http4s_ember = "0.23.27" + val http4s = "1.0.0-M41" + val http4s_ember = "1.0.0-M41" val scalameta = "4.9.5" // Not available for Scala 3 yet val fastparse = "3.1.0" // 3.0.0 is available for Scala 3 diff --git a/version.sbt b/version.sbt index 7ca5419b..226d8c20 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "1.3.13-SNAPSHOT" +ThisBuild / version := "1.3.14-SNAPSHOT"