glimit/actor

The rate limiter actor.

Types

The messages that the actor can receive.

pub type Message(id) {
  Shutdown
  Hit(identifier: id, reply_with: Subject(Result(Nil, Nil)))
}

Constructors

  • Shutdown

    Stop the actor.

  • Hit(identifier: id, reply_with: Subject(Result(Nil, Nil)))

    Mark a hit for a given identifier.

Functions

pub fn hit(
  subject: Subject(Message(a)),
  identifier: a,
) -> Result(Nil, Nil)

Log a hit for a given identifier.

pub fn new(
  per_second: Option(Int),
  per_minute: Option(Int),
  per_hour: Option(Int),
) -> Result(Subject(Message(a)), Nil)

Create a new rate limiter actor.

pub fn stop(subject: Subject(Message(a))) -> Nil

Stop the actor.

Search Document