You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

4 years ago
4 years ago
  1. package nova.monadic_sfx
  2. import _root_.monix.bio.BIOApp
  3. import _root_.monix.bio.Task
  4. import _root_.monix.bio.UIO
  5. import _root_.monix.execution.Scheduler
  6. import cats.effect.ExitCode
  7. import cats.effect.Resource
  8. import com.softwaremill.macwire._
  9. import io.odin._
  10. import nova.monadic_sfx.executors._
  11. // import nova.monadic_sfx.util.IOUtils._
  12. // import sttp.client.httpclient.monix.HttpClientMonixBackend
  13. object Main extends MainModule with BIOApp {
  14. lazy val schedulers = new Schedulers()
  15. override def scheduler: Scheduler = schedulers.async
  16. def appResource(startTime: Long) =
  17. for {
  18. implicit0(logger: Logger[Task]) <- makeLogger
  19. // backend and actorsystem are for future use
  20. // backend <- Resource.make(
  21. // toIO(HttpClientMonixBackend()(schedulers.async))
  22. // )(c => toIO(c.close()))
  23. // actorSystem <- actorSystemResource(logger)
  24. _ <- Resource.liftF(wire[MainApp].program)
  25. } yield ()
  26. override def run(args: List[String]): UIO[ExitCode] =
  27. appResource(System.currentTimeMillis())
  28. .use(_ => Task.unit)
  29. .onErrorHandleWith(ex => UIO(ex.printStackTrace()))
  30. .as(ExitCode.Success)
  31. }