Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object DoobieHikariModule {
metricsTrackerFactory: Option[MetricsTrackerFactory] = None
)(implicit cs: ContextShift[F]): Resource[F, HikariTransactor[F]] = {
for {
hikariConfig <- Resource.liftF(makeHikariConfig(config, metricsTrackerFactory))
hikariConfig <- Resource.eval(makeHikariConfig(config, metricsTrackerFactory))
transactor <- HikariTransactor.fromHikariConfig(hikariConfig, boundedConnectExecutionContext, blocker)
} yield transactor
}
Expand Down
14 changes: 7 additions & 7 deletions example/src/main/scala/com/avast/sst/example/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ object Main extends ZioServerApp {

def program: Resource[Task, Server[Task]] = {
for {
configuration <- Resource.liftF(PureConfigModule.makeOrRaise[Task, Configuration])
configuration <- Resource.eval(PureConfigModule.makeOrRaise[Task, Configuration])
executorModule <- ExecutorModule.makeFromExecutionContext[Task](runtime.platform.executor.asEC)
clock = Clock.create[Task]
currentTime <- Resource.liftF(clock.realTime(TimeUnit.MILLISECONDS))
currentTime <- Resource.eval(clock.realTime(TimeUnit.MILLISECONDS))
console <- Resource.pure[Task, Console[Task]](ConsoleModule.make[Task])
_ <- Resource.liftF(
_ <- Resource.eval(
console.printLine(s"The current Unix epoch time is $currentTime. This system has ${executorModule.numOfCpus} CPUs.")
)
meterRegistry <- MicrometerJmxModule.make[Task](configuration.jmx)
_ <- Resource.liftF(MicrometerJvmModule.make[Task](meterRegistry))
serverMetricsModule <- Resource.liftF(MicrometerHttp4sServerMetricsModule.make[Task](meterRegistry, clock))
_ <- Resource.eval(MicrometerJvmModule.make[Task](meterRegistry))
serverMetricsModule <- Resource.eval(MicrometerHttp4sServerMetricsModule.make[Task](meterRegistry, clock))
boundedConnectExecutionContext <-
executorModule
.makeThreadPoolExecutor(
Expand All @@ -56,8 +56,8 @@ object Main extends ZioServerApp {
.make[Task](configuration.database, boundedConnectExecutionContext, executorModule.blocker, Some(hikariMetricsFactory))
randomService = RandomService(doobieTransactor)
httpClient <- Http4sBlazeClientModule.make[Task](configuration.client, executorModule.executionContext)
circuitBreakerMetrics <- Resource.liftF(MicrometerCircuitBreakerMetricsModule.make[Task]("test-http-client", meterRegistry))
circuitBreaker <- Resource.liftF(CircuitBreakerModule[Task].make(configuration.circuitBreaker, clock))
circuitBreakerMetrics <- Resource.eval(MicrometerCircuitBreakerMetricsModule.make[Task]("test-http-client", meterRegistry))
circuitBreaker <- Resource.eval(CircuitBreakerModule[Task].make(configuration.circuitBreaker, clock))
enrichedCircuitBreaker = withLogging("test-http-client", withMetrics(circuitBreakerMetrics, circuitBreaker))
client = Http4sClientCircuitBreakerModule.make[Task](httpClient, enrichedCircuitBreaker)
routingModule = new Http4sRoutingModule(randomService, client, serverMetricsModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Fs2KafkaModuleTest extends AsyncFunSuite with ForAllTestContainer {
consumer <- Fs2KafkaModule.makeConsumer[IO, String, String](
ConsumerConfig(List(container.bootstrapServers), groupId = "test", autoOffsetReset = AutoOffsetReset.Earliest)
)
_ <- Resource.liftF(consumer.subscribeTo("test"))
_ <- Resource.liftF(producer.produce(ProducerRecords.one(ProducerRecord("test", "key", "value"))).flatten)
event <- Resource.liftF(consumer.stream.head.compile.toList)
_ <- Resource.eval(consumer.subscribeTo("test"))
_ <- Resource.eval(producer.produce(ProducerRecords.one(ProducerRecord("test", "key", "value"))).flatten)
event <- Resource.eval(consumer.stream.head.compile.toList)
} yield assert(event.head.record.key === "key" && event.head.record.value === "value")

io.use(IO.pure).unsafeToFuture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Http4SBlazeClientTest extends AsyncFunSuite {
),
ExecutionContext.global
)
response <- Resource.liftF(client.expect[String]("https://httpbin.org/user-agent"))
response <- Resource.eval(client.expect[String]("https://httpbin.org/user-agent"))
} yield assert(response === expected)

test.use(IO.pure).unsafeToFuture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Http4sBlazeServerModule {
executionContext: ExecutionContext
): Resource[F, Server[F]] = {
for {
inetSocketAddress <- Resource.liftF(
inetSocketAddress <- Resource.eval(
ConcurrentEffect[F].delay(
InetSocketAddress.createUnresolved(config.listenAddress, config.listenPort)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CorrelationIdMiddlewareTest extends AsyncFunSuite with Http4sDsl[IO] {

test("CorrelationIdMiddleware fills Request attributes and HTTP response header") {
val test = for {
middleware <- Resource.liftF(CorrelationIdMiddleware.default[IO])
middleware <- Resource.eval(CorrelationIdMiddleware.default[IO])
routes = Http4sRouting.make {
middleware.wrap {
HttpRoutes.of[IO] { case req @ GET -> Root / "test" =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object ExecutorModule {
*/
def makeDefault[F[_]: Sync]: Resource[F, ExecutorModule[F]] = {
for {
numOfCpus <- Resource.liftF(Sync[F].delay(Runtime.getRuntime.availableProcessors))
numOfCpus <- Resource.eval(Sync[F].delay(Runtime.getRuntime.availableProcessors))
coreSize = numOfCpus * 2
executor <- makeThreadPoolExecutor(ThreadPoolExecutorConfig(coreSize, coreSize), toolkitThreadFactory, new LinkedBlockingQueue)
.map(ExecutionContext.fromExecutorService)
Expand All @@ -71,7 +71,7 @@ object ExecutorModule {
*/
def makeFromExecutionContext[F[_]: Sync](executor: ExecutionContext): Resource[F, ExecutorModule[F]] = {
for {
numOfCpus <- Resource.liftF(Sync[F].delay(Runtime.getRuntime.availableProcessors))
numOfCpus <- Resource.eval(Sync[F].delay(Runtime.getRuntime.availableProcessors))
blockingExecutor <- makeBlockingExecutor.map(ExecutionContext.fromExecutorService)
} yield new ExecutorModule[F](numOfCpus, executor, blockingExecutor)
}
Expand All @@ -81,7 +81,7 @@ object ExecutorModule {
*/
def makeFromConfig[F[_]: Sync](executorConfig: ThreadPoolExecutorConfig): Resource[F, ExecutorModule[F]] = {
for {
numOfCpus <- Resource.liftF(Sync[F].delay(Runtime.getRuntime.availableProcessors))
numOfCpus <- Resource.eval(Sync[F].delay(Runtime.getRuntime.availableProcessors))
executor <- makeThreadPoolExecutor(executorConfig, toolkitThreadFactory, new LinkedBlockingQueue)
.map(ExecutionContext.fromExecutorService)
blockingExecutor <- makeBlockingExecutor.map(ExecutionContext.fromExecutorService)
Expand All @@ -93,7 +93,7 @@ object ExecutorModule {
*/
def makeForkJoinFromConfig[F[_]: Sync](executorConfig: ForkJoinPoolConfig): Resource[F, ExecutorModule[F]] = {
for {
numOfCpus <- Resource.liftF(Sync[F].delay(Runtime.getRuntime.availableProcessors))
numOfCpus <- Resource.eval(Sync[F].delay(Runtime.getRuntime.availableProcessors))
executor <- makeForkJoinPool(executorConfig, numOfCpus, toolkitThreadFactory)
.map(ExecutionContext.fromExecutorService)
blockingExecutor <- makeBlockingExecutor.map(ExecutionContext.fromExecutorService)
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._

object Dependencies {

val catsEffect = "org.typelevel" %% "cats-effect" % "2.3.3"
val catsEffect = "org.typelevel" %% "cats-effect" % "2.4.0"
val datastaxJavaDriverCore = "com.datastax.oss" % "java-driver-core" % Versions.datastaxJavaDriverCore
val doobie = "org.tpolecat" %% "doobie-core" % Versions.doobie
val doobieHikari = "org.tpolecat" %% "doobie-hikari" % Versions.doobie
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SentryModule {
*/
def makeWithReleaseFromPackage[F[_]: Sync, Main: ClassTag](config: SentryConfig): Resource[F, Unit] = {
for {
customizedConfig <- Resource.liftF {
customizedConfig <- Resource.eval {
Sync[F].delay {
for {
pkg <- Option(implicitly[ClassTag[Main]].runtimeClass.getPackage)
Expand Down