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

sttp.client4.httpclient.cats.CatsSequencer.scala Maven / Gradle / Ivy

There is a newer version: 4.0.0-M18
Show newest version
package sttp.client4.httpclient.cats

import cats.effect.kernel.{Async, MonadCancel}
import cats.effect.std.Semaphore
import cats.syntax.all._
import sttp.client4.internal.httpclient.Sequencer

private[cats] class CatsSequencer[F[_]](s: Semaphore[F])(implicit m: MonadCancel[F, Throwable]) extends Sequencer[F] {
  override def apply[T](t: => F[T]): F[T] = s.permit.use(_ => t)
}

private[cats] object CatsSequencer {
  def create[F[_]: Async]: F[Sequencer[F]] = Semaphore(1).map(new CatsSequencer(_))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy