Files
WeatherTool/src/main/scala/app/Main.scala
T

26 lines
822 B
Scala
Raw Normal View History

package app
import cats.effect._
2023-05-17 01:20:01 +03:00
import cats.implicits.catsSyntaxTuple2Parallel
2023-12-17 22:48:24 +02:00
import db.{DBConnection, PostgresService}
import fetch.{FetchService, FileFetchScheduler}
import server.Server
object Main extends IOApp {
def run(args: List[String]): IO[ExitCode] = {
for {
transactor <- DBConnection.transactor[IO]
postgresService <- PostgresService.of(transactor)
_ <- postgresService.createWeatherTable // create table if it does not exists
2023-06-22 13:59:44 +03:00
fetch <- FetchService.of
2023-12-17 22:48:24 +02:00
fileFetchScheduler <- FileFetchScheduler.of(postgresService, fetch)
schedulerTask = fileFetchScheduler.run.compile.drain
2023-06-22 13:59:44 +03:00
2023-12-17 22:48:24 +02:00
server <- Server.of(postgresService, fetch)
serverTask = server.run
2023-06-22 13:59:44 +03:00
exitCode <- (serverTask, schedulerTask).parMapN((_, _) => ExitCode.Success)
} yield exitCode
}
}