Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ object server extends CommonSettings {
Deps.bittorrent.dht,
Deps.`cats-effect`,
Deps.`fs2-io`,
Deps.http4s.core,
Deps.http4s.dsl,
Deps.http4s.server,
Deps.http4s.client,
Deps.`zio-http`,
Deps.`zio-interop-cats`,
Deps.`ip4s-core`,
Deps.`woof-core`,
Deps.`woof-slf4j`,
Deps.`cats-effect-cps`,
Expand Down Expand Up @@ -59,7 +58,10 @@ object Deps {
val fs2 = "3.12.2"
val `scodec-bits` = "1.2.4"
val upickle = "2.0.0"
val http4s = "1.0.0-M40"
val `zio-http` = "3.11.2"
val zio = "2.1.26"
val `zio-interop-cats` = "23.1.0.14"
val `ip4s-core` = "3.8.0"
val `cats-effect-cps` = "0.9.21"
val woof = "0.9.0"
}
Expand All @@ -73,12 +75,9 @@ object Deps {
val `fs2-io` = mvn"co.fs2::fs2-io::${Versions.fs2}"
val `scodec-bits` = mvn"org.scodec::scodec-bits::${Versions.`scodec-bits`}"
val upickle = mvn"com.lihaoyi::upickle::${Versions.upickle}"
object http4s {
val core = mvn"org.http4s::http4s-core::${Versions.http4s}"
val dsl = mvn"org.http4s::http4s-dsl::${Versions.http4s}"
val server = mvn"org.http4s::http4s-ember-server::${Versions.http4s}"
val client = mvn"org.http4s::http4s-ember-client::${Versions.http4s}"
}
val `zio-http` = mvn"dev.zio::zio-http::${Versions.`zio-http`}"
val `zio-interop-cats` = mvn"dev.zio::zio-interop-cats::${Versions.`zio-interop-cats`}"
val `ip4s-core` = mvn"com.comcast::ip4s-core::${Versions.`ip4s-core`}"
val `cats-effect-cps` = mvn"com.github.rssh::cps-async-connect-cats-effect::${Versions.`cats-effect-cps`}"
val `woof-core` = mvn"org.legogroup::woof-core::${Versions.woof}"
val `woof-slf4j` = mvn"org.legogroup::woof-slf4j::${Versions.woof}"
Expand Down
18 changes: 18 additions & 0 deletions server/src/main/scala/Interop.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import cats.arrow.FunctionK
import cats.effect.{IO, Resource}
import cats.effect.std.Dispatcher
import zio.interop.fromEffect
import zio.{RIO, Scope, ZIO}

object Interop {

def ioToRIO(using Dispatcher[IO]): FunctionK[IO, RIO[Any, _]] =
new FunctionK[IO, RIO[Any, _]] {
def apply[A](fa: IO[A]): RIO[Any, A] = fromEffect(fa)
}

def acquireCats[A](resource: Resource[IO, A])(using Dispatcher[IO]): ZIO[Scope, Throwable, A] =
fromEffect(resource.allocated).flatMap { (value, release) =>
ZIO.addFinalizer(fromEffect(release).orDie).as(value)
}
}
Loading
Loading