All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.tapir.server.armeria.cats.CatsMonadAsyncError.scala Maven / Gradle / Ivy

There is a newer version: 1.11.4
Show newest version
package sttp.tapir.server.armeria.cats

import cats.effect.Async
import cats.syntax.functor._
import sttp.monad.{Canceler, MonadAsyncError}
import sttp.tapir.integ.cats.effect.CatsMonadError

// Forked from sttp.client3.impl.cats.CatsMonadAsyncError
private class CatsMonadAsyncError[F[_]](implicit F: Async[F]) extends CatsMonadError[F] with MonadAsyncError[F] {
  override def async[T](register: ((Either[Throwable, T]) => Unit) => Canceler): F[T] =
    F.async(cb => F.delay(register(cb)).map(c => Some(F.delay(c.cancel()))))

  override def blocking[T](t: => T): F[T] =
    F.blocking(t)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy