Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
upgraded to 0.3.0-RC9 (#724)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Fuhrman <[email protected]>
  • Loading branch information
kfuhrman and Kevin Fuhrman authored Jul 1, 2022
1 parent 18a1ca8 commit b9d29ea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import scala.concurrent.Future
import scala.util.control.NonFatal
import zio.json._
import zio.stream.ZStream
import zio.Unsafe

object ZioJsonSupport extends ZioJsonSupport

Expand Down Expand Up @@ -95,12 +96,13 @@ trait ZioJsonSupport {
* @return
*/
implicit final def fromByteStringUnmarshaller[A](implicit
jd: JsonDecoder[A]
jd: JsonDecoder[A],
rt: zio.Runtime[Any]
): Unmarshaller[ByteString, A] =
Unmarshaller(_ =>
bs => {
val decoded = jd.decodeJsonStreamInput(ZStream.fromIterable(bs))
zio.Runtime.default.unsafeRunToFuture(decoded)
Unsafe.unsafeCompat(implicit u => rt.unsafe.runToFuture(decoded))
}
)

Expand All @@ -127,7 +129,7 @@ trait ZioJsonSupport {
* @return
* unmarshaller for `A`
*/
implicit final def unmarshaller[A: JsonDecoder]: FromEntityUnmarshaller[A] =
implicit final def unmarshaller[A: JsonDecoder, RT: zio.Runtime]: FromEntityUnmarshaller[A] =
Unmarshaller.byteStringUnmarshaller
.forContentTypes(unmarshallerContentTypes: _*)
.flatMap { implicit ec => implicit m =>
Expand All @@ -147,7 +149,7 @@ trait ZioJsonSupport {
* @return
* unmarshaller from `Source[A, _]`
*/
implicit final def sourceUnmarshaller[A: JsonDecoder](implicit
implicit final def sourceUnmarshaller[A: JsonDecoder, RT: zio.Runtime](implicit
support: JsonEntityStreamingSupport = EntityStreamingSupport.json()
): FromEntityUnmarshaller[SourceOf[A]] =
Unmarshaller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ object ExampleApp {
implicit val fooDecoder: JsonDecoder[Foo] = DeriveJsonDecoder.gen
}

private implicit val rt: zio.Runtime[Any] = zio.Runtime.default

def main(args: Array[String]): Unit = {
implicit val system = ActorSystem()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ object ZioJsonSupportSpec {
implicit val fooDecoder: JsonDecoder[Foo] = DeriveJsonDecoder.gen
implicit val multiFooDecoder: JsonDecoder[MultiFoo] = DeriveJsonDecoder.gen
implicit val optionFooDecoder: JsonDecoder[OptionFoo] = DeriveJsonDecoder.gen

implicit val rt: zio.Runtime[Any] = zio.Runtime.default
}

final class ZioJsonSupportSpec
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ lazy val library =
val play = "2.9.2"
val scalaTest = "3.2.11"
val upickle = "1.5.0"
val zioJson = "0.3.0-RC6"
val zioJson = "0.3.0-RC9"
}
// format: off
val akkaHttp = "com.typesafe.akka" %% "akka-http" % Version.akkaHttp
Expand Down

0 comments on commit b9d29ea

Please sign in to comment.