Throttle

org.http4s.server.middleware.Throttle
object Throttle

Transform a service to reject any calls the go over a given rate.

Attributes

Source
Throttle.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Throttle.type

Members list

Type members

Classlikes

sealed abstract class TokenAvailability extends Product, Serializable

Attributes

Source
Throttle.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
object TokenAvailable.type
case object TokenAvailable extends TokenAvailability

Attributes

Source
Throttle.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
object TokenBucket

Attributes

Companion
trait
Source
Throttle.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait TokenBucket[F[_]]

A token bucket for use with the Throttle middleware.

A token bucket for use with the Throttle middleware. Consumers can take tokens which will be refilled over time. Implementations are required to provide their own refill mechanism.

Possible implementations include a remote TokenBucket service to coordinate between different application instances.

Attributes

Companion
object
Source
Throttle.scala
Supertypes
class Object
trait Matchable
class Any
final case class TokenUnavailable(retryAfter: Option[FiniteDuration]) extends TokenAvailability

Attributes

Source
Throttle.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def apply[F[_], G[_]](amount: Int, per: FiniteDuration)(http: Http[F, G])(implicit F: Temporal[F]): F[Http[F, G]]

Limits the supplied service to a given rate of calls using an in-memory TokenBucket

Limits the supplied service to a given rate of calls using an in-memory TokenBucket

Value parameters

amount

the number of calls to the service to permit within the given time period.

http

the service to transform.

per

the time period over which a given number of calls is permitted.

Attributes

Returns

a task containing the transformed service.

Source
Throttle.scala
def apply[F[_], G[_]](bucket: TokenBucket[F], throttleResponse: Option[FiniteDuration] => Response[G])(http: Http[F, G])(implicit F: Monad[F]): Http[F, G]

Limits the supplied service using a provided TokenBucket

Limits the supplied service using a provided TokenBucket

Value parameters

bucket

a TokenBucket to use to track the rate of incoming requests.

http

the service to transform.

throttleResponse

a function that defines the response when throttled, may be supplied a suggested retry time depending on bucket implementation.

Attributes

Returns

a task containing the transformed service.

Source
Throttle.scala
def defaultResponse[F[_]](retryAfter: Option[FiniteDuration]): Response[F]

Attributes

Source
Throttle.scala
def httpApp[F[_]](amount: Int, per: FiniteDuration)(httpApp: HttpApp[F])(implicit F: Temporal[F]): F[HttpApp[F]]

As apply(amount,per), but for HttpApp[F]

As apply(amount,per), but for HttpApp[F]

Attributes

Source
Throttle.scala
def httpApp[F[_] : Monad](bucket: TokenBucket[F], throttleResponse: Option[FiniteDuration] => Response[F])(httpApp: HttpApp[F]): HttpApp[F]

As apply(bucket,throttleResponse), but for HttpApp[F]

As apply(bucket,throttleResponse), but for HttpApp[F]

Attributes

Source
Throttle.scala
def httpRoutes[F[_]](amount: Int, per: FiniteDuration)(httpRoutes: HttpRoutes[F])(implicit F: Temporal[F]): F[HttpRoutes[F]]

As apply(amount,per), but for HttpRoutes[F]

As apply(amount,per), but for HttpRoutes[F]

Attributes

Source
Throttle.scala
def httpRoutes[F[_] : Monad](bucket: TokenBucket[F], throttleResponse: Option[FiniteDuration] => Response[F])(httpRoutes: HttpRoutes[F]): HttpRoutes[F]

As apply(bucket,throttleResponse), but for HttpRoutes[F]

As apply(bucket,throttleResponse), but for HttpRoutes[F]

Attributes

Source
Throttle.scala

Deprecated methods

def httpAapp[F[_]](amount: Int, per: FiniteDuration)(httpApp: HttpApp[F])(implicit F: Temporal[F]): F[HttpApp[F]]

Attributes

Deprecated
true
Source
Throttle.scala