не удалось создать маршруты http4s с таймаутом - PullRequest
0 голосов
/ 08 января 2019

Я пытаюсь создать маршруты http4s с функцией Timeout.

Я видел пример здесь в TimeoutSpec и создал маршрут таймаута здесь .

Когда я компилирую код, я получаю ошибку ниже -

    [info] Compiling 12 Scala sources to /Users/rajkumar.natarajan/Documents/Coding/OS/ciris-example/target/scala-2.12/classes ...
    [error] /Users/rajkumar.natarajan/Documents/Coding/OS/ciris-example/src/main/scala/is/cir/example/application/Http4sApi.scala:38:45: no type parameters for method apply: (http: cats.data.Kleisli[F,A,org.http4s.Response[G]])(implicit F: cats.effect.Concurrent[F], implicit T: cats.effect.Timer[F], implicit W: org.http4s.EntityEncoder[G,String])cats.data.Kleisli[F,A,org.http4s.Response[G]] in object Timeout exist so that it can be applied to arguments (org.http4s.HttpRoutes[cats.effect.IO])
    [error]  --- because ---
    [error] argument expression's type is not compatible with formal parameter type;
    [error]  found   : org.http4s.HttpRoutes[cats.effect.IO]
    [error]     (which expands to)  cats.data.Kleisli[[β$0$]cats.data.OptionT[cats.effect.IO,β$0$],org.http4s.Request[cats.effect.IO],org.http4s.Response[cats.effect.IO]]
    [error]  required: cats.data.Kleisli[?F,?A,org.http4s.Response[?G]]
    [error]      case finite: FiniteDuration => (Timeout(finite)(routes)).orNotFound
    [error]                                             ^
    [error] /Users/rajkumar.natarajan/Documents/Coding/OS/ciris-example/src/main/scala/is/cir/example/application/Http4sApi.scala:38:54: type mismatch;
    [error]  found   : org.http4s.HttpRoutes[cats.effect.IO]
    [error]     (which expands to)  cats.data.Kleisli[[β$0$]cats.data.OptionT[cats.effect.IO,β$0$],org.http4s.Request[cats.effect.IO],org.http4s.Response[cats.effect.IO]]
    [error]  required: cats.data.Kleisli[F,A,org.http4s.Response[G]]
    [error]      case finite: FiniteDuration => (Timeout(finite)(routes)).orNotFound
    [error]                                                      ^
    [error] /Users/rajkumar.natarajan/Documents/Coding/OS/ciris-example/src/main/scala/is/cir/example/application/Http4sApi.scala:38:53: Cannot find implicit value for Concurrent[F].
    [error] Building this implicit value might depend on having an implicit
    [error] s.c.ExecutionContext in scope, a Scheduler, a ContextShift[F]
    [error] or some equivalent type.
    [error]      case finite: FiniteDuration => (Timeout(finite)(routes)).orNotFound
    [error]                                                     ^
    [error] three errors found
    [error] (Compile / compileIncremental) Compilation failed
    [error] Total time: 17 s, completed Jan 7, 2019 6:51:48 PM

Типы в коде верны, но первые 2 ошибки связаны с третьей ошибкой Cannot find implicit value for Concurrent[F].

У меня Concurrent[IO] в области здесь , но я не уверен, почему я все еще получаю эту ошибку.

Я использую версию http4s 19.0. Другие подробности о версии можно найти здесь .

...