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.

36 lines
1.2 KiB

4 years ago
4 years ago
  1. package nova.monadic_sfx
  2. import monix.eval.Task
  3. // import sttp.client.asynchttpclient.monix.AsyncHttpClientMonixBackend
  4. // import sttp.client._
  5. // import sttp.client.circe._
  6. // import io.circe.generic.auto._
  7. import nova.monadic_sfx.executors._
  8. import cats.effect.Resource
  9. import sttp.client.asynchttpclient.monix.AsyncHttpClientMonixBackend
  10. import io.odin.syntax._
  11. import io.odin.monix._
  12. import monix.eval.TaskApp
  13. import cats.effect.ExitCode
  14. import cats.implicits._
  15. object Main extends MainModule with TaskApp {
  16. override def run(args: List[String]): Task[ExitCode] = {
  17. // val startTime = Task.clock
  18. // .monotonic(scala.concurrent.duration.MILLISECONDS)
  19. // .map(Duration.fromNanos(_))
  20. lazy val appResource = for {
  21. // clock <- Resource.liftF(Task(Task.clock))
  22. logger <- consoleLogger().withAsync()
  23. backend <- AsyncHttpClientMonixBackend.resource()
  24. actorSystem <- actorResource(logger)
  25. reqs <- Resource.liftF(Task(requesters(backend, actorSystem)))
  26. schedulers <- Resource.liftF(Task(new Schedulers()))
  27. fxApp <- fxAppResource(logger, backend, actorSystem, reqs, schedulers)
  28. } yield (fxApp)
  29. appResource
  30. .use(fxApp => Task(fxApp.main(args.toArray)))
  31. .as(ExitCode.Success)
  32. }
  33. }