All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Public Attributes | List of all members
aegis::ratelimit::bucket Class Reference

Buckets store ratelimit data per major parameter. More...

#include <bucket.hpp>

Public Member Functions

 bucket (rest_call &call, asio::io_context &_io_context, std::atomic< int64_t > &global_limit)
bool is_global () const noexcept
 Check if globally ratelimited. More...
bool can_perform () const noexcept
 Check if bucket can send a message without hitting the ratelimit. More...
rest::rest_reply perform (rest::request_params params)

Public Attributes

std::atomic< int64_t > limit
std::atomic< int64_t > remaining
std::atomic< int64_t > reset
bool ignore_rates = false
std::mutex m
rest_call & _call
std::queue< std::tuple
< std::string, std::string,
std::string, std::function
< void(rest::rest_reply)> > > 
int32_t reset_bypass = 0

Detailed Description

Buckets store ratelimit data per major parameter.

Bucket class for tracking the ratelimits per snowflake per major parameter. Each bucket tracks a single major parameter and a single snowflake Current major parameters are GUILD, CHANNEL, and EMOJI

Constructor & Destructor Documentation

aegis::ratelimit::bucket::bucket ( rest_call &  call,
asio::io_context &  _io_context,
std::atomic< int64_t > &  global_limit 

Construct a bucket object for tracking ratelimits per major parameter of the REST API (guild/channel/emoji)

Member Function Documentation

bool aegis::ratelimit::bucket::can_perform ( ) const

Check if bucket can send a message without hitting the ratelimit.

true if bucket ratelimits permit a message to be sent
bool aegis::ratelimit::bucket::is_global ( ) const

Check if globally ratelimited.

true if globally ratelimited

Member Data Documentation

std::atomic<int64_t> aegis::ratelimit::bucket::limit

Rate limit current endpoint call limit

std::atomic<int64_t> aegis::ratelimit::bucket::remaining

Rate limit remaining count

std::atomic<int64_t> aegis::ratelimit::bucket::reset

Rate limit reset time

The documentation for this class was generated from the following file: