FailureRateLimitFunction

com.digitaltangible.playguard.FailureRateLimitFunction
abstract class FailureRateLimitFunction[R <: (Request)](rateLimiter: RateLimiter, resultCheck: Result => Boolean)(implicit val executionContext: ExecutionContext) extends ActionFunction[R, R]

ActionFunction which holds a RateLimiter with a bucket for each key returned by method keyFromRequest. Tokens are consumed only by failures determined by function resultCheck. If no tokens remain, requests with this key are rejected. Can be used with any Request type. Useful if you want to use content from a wrapped request, e.g. User ID

Attributes

Graph
Supertypes
trait ActionFunction[R, R]
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def keyFromRequest[A](implicit request: R[A]): Any
def rejectResponse[A](implicit request: R[A]): Future[Result]

Concrete methods

def bypass[A](implicit request: R[A]): Boolean
def invokeBlock[A](request: R[A], block: R[A] => Future[Result]): Future[Result]

Invoke the block. This is the main method that an ActionBuilder has to implement, at this stage it can wrap it in any other actions, modify the request object or potentially use a different class to represent the request.

Invoke the block. This is the main method that an ActionBuilder has to implement, at this stage it can wrap it in any other actions, modify the request object or potentially use a different class to represent the request.

Value parameters

block

The block of code to invoke

request

The request

Attributes

Returns

A future of the result

Inherited methods

def andThen[Q[_]](other: ActionFunction[R, Q]): ActionFunction[R, Q]

Compose this ActionFunction with another, with this one applied first.

Compose this ActionFunction with another, with this one applied first.

Value parameters

other

ActionFunction with which to compose

Attributes

Returns

The new ActionFunction

Inherited from:
ActionFunction
def compose[B](other: ActionBuilder[R, B]): ActionBuilder[P, B]

Attributes

Inherited from:
ActionFunction
def compose[Q[_]](other: ActionFunction[Q, R]): ActionFunction[Q, P]

Compose another ActionFunction with this one, with this one applied last.

Compose another ActionFunction with this one, with this one applied last.

Value parameters

other

ActionFunction with which to compose

Attributes

Returns

The new ActionFunction

Inherited from:
ActionFunction

Implicits

Implicits

implicit val executionContext: ExecutionContext

Attributes

Returns

The execution context to run the request in.