D
Size: a a a
D
D
Oℕ
D
D
D
Zlayer
D
Zlayer
D
Oℕ
Oℕ
NV
NV
D
import java.sql.Connection
def makeConnection: UIO[Connection] = UIO(???)
val connectionLayer: Layer[Nothing, Has[Connection]] =
ZLayer.fromAcquireRelease(makeConnection)(c => UIO(c.close()))
val postgresLayer: ZLayer[Has[Connection], Nothing, UserRepo] =
ZLayer.fromFunction { hasC =>
new UserRepo.Service {
override def getUser(userId: UserId): IO[DBError, Option[User]] = UIO(???)
override def createUser(user: User): IO[DBError, Unit] = UIO(???)
}
}
val fullRepo: Layer[Nothing, UserRepo] = connectionLayer >>> postgresLayer
w
import java.sql.Connection
def makeConnection: UIO[Connection] = UIO(???)
val connectionLayer: Layer[Nothing, Has[Connection]] =
ZLayer.fromAcquireRelease(makeConnection)(c => UIO(c.close()))
val postgresLayer: ZLayer[Has[Connection], Nothing, UserRepo] =
ZLayer.fromFunction { hasC =>
new UserRepo.Service {
override def getUser(userId: UserId): IO[DBError, Option[User]] = UIO(???)
override def createUser(user: User): IO[DBError, Unit] = UIO(???)
}
}
val fullRepo: Layer[Nothing, UserRepo] = connectionLayer >>> postgresLayer
D
Oℕ
Oℕ
import java.sql.Connection
def makeConnection: UIO[Connection] = UIO(???)
val connectionLayer: Layer[Nothing, Has[Connection]] =
ZLayer.fromAcquireRelease(makeConnection)(c => UIO(c.close()))
val postgresLayer: ZLayer[Has[Connection], Nothing, UserRepo] =
ZLayer.fromFunction { hasC =>
new UserRepo.Service {
override def getUser(userId: UserId): IO[DBError, Option[User]] = UIO(???)
override def createUser(user: User): IO[DBError, Unit] = UIO(???)
}
}
val fullRepo: Layer[Nothing, UserRepo] = connectionLayer >>> postgresLayer
Oℕ
D
D