dpp::request_queue
queues.h
dpp::request_queue::completed_request
class friend class request_concurrency_queue request_concurrency_queue dpp::request_queue::request_concurrency_queue request_concurrency_queue

Required so request_concurrency_queue can access these member variables.

class cluster * class cluster* dpp::request_queue::creator creator dpp::request_queue::creator

The cluster that owns this request_queue.

time_t time_t dpp::request_queue::globally_limited_until globally_limited_until dpp::request_queue::globally_limited_until

When we are globally rate limited until (unix epoch).

Only valid if globally_rate limited is true. If we are globally rate limited, queues in this class will not process requests until the current unix epoch time is greater than this time.

std::atomic< bool > std::atomic<bool> dpp::request_queue::globally_ratelimited globally_ratelimited dpp::request_queue::globally_ratelimited

True if globally rate limited.

When globally rate limited the concurrency queues associated with this request queue will not process any requests in their timers until the global rate limit expires.

uint32_t uint32_t dpp::request_queue::in_queue_pool_size in_queue_pool_size dpp::request_queue::in_queue_pool_size

Number of request queues in the pool. This is the direct size of the requests_in vector.

std::vector< std::unique_ptr< request_concurrency_queue > > std::vector<std::unique_ptr<request_concurrency_queue> > dpp::request_queue::requests_in requests_in dpp::request_queue::requests_in

A vector of timers forming a pool.

There are a set number of these defined by a constant in cluster.cpp. A request is always placed on the same element in this vector, based upon its url, so that two conditions are satisfied:

1) Any requests for the same ratelimit bucket are handled by the same concurrency queue in the pool so that they do not create unnecessary 429 errors, 2) Requests for different endpoints go into different buckets, so that they may be requested in parallel A global ratelimit event pauses all timers in the pool. These are few and far between.

std::atomic< bool > std::atomic<bool> dpp::request_queue::terminating terminating dpp::request_queue::terminating

Set to true if the timers should terminate. When this is set to true no further requests are accepted to the queues.

dpp::request_queue::request_queue
(class cluster *owner, uint32_t request_concurrency=8)
request_queue
dpp::request_queue::request_queue
class cluster * owner
uint32_t request_concurrency 8

constructor

owner

The creating cluster.

request_concurrency

The number of http request queues to allocate. Each request queue is a dpp::timer which ticks every second looking for new requests to run. The timer will hold back requests if we are waiting as to comply with rate limits. Adding a request to this class will cause the queue it is placed in to run immediately but this cannot override rate limits. By default eight concurrency queues are allocated. Side effects: Creates timers for the queue

dpp::request_queue::~request_queue
()
~request_queue
dpp::request_queue::~request_queue

Destroy the request queue object. Side effects: Ends and deletes concurrency timers.

size_t size_t dpp::request_queue::get_active_request_count () const get_active_request_count dpp::request_queue::get_active_request_count

Returns the number of active requests on this queue.

Total number of active requests

uint32_t uint32_t dpp::request_queue::get_request_queue_count () const get_request_queue_count dpp::request_queue::get_request_queue_count

Get the request queue concurrency count.

uint32_t number of request queues that are active

bool bool dpp::request_queue::is_globally_ratelimited () const is_globally_ratelimited dpp::request_queue::is_globally_ratelimited

Returns true if the bot is currently globally rate limited.

true if globally rate limited

request_queue & request_queue & dpp::request_queue::post_request (std::unique_ptr< http_request > req) post_request dpp::request_queue::post_request std::unique_ptr< http_request > req

Put a http_request into the request queue.

Will use a simple hash function to determine which of the 'in queues' to place this request onto.

req

request to add

reference to self

The request_queue class manages rate limits and marshalls HTTP requests that have been built as http_request objects.

It ensures asynchronous delivery of events and queueing of requests.

It will spawn multiple timers to make outbound HTTP requests and then call the callbacks of those requests on completion within the dpp::thread_pool for the cluster. If the user decides to take a long time processing a reply in their callback it won't affect when other requests are sent, and if a HTTP request takes a long time due to latency, it won't hold up user processing.

There are usually two request_queue objects in each dpp::cluster, one of which is used internally for the various REST methods to Discord such as sending messages, and the other used to support user REST calls via dpp::cluster::request(). They are separated so that the one for user requests can be specifically configured to never ever send the Discord token unless it is explicitly placed into the request, for security reasons.

K
T
bool
cache_policy_setting_t
double
dpp::bucket_t
limit
remaining
reset_after
retry_after
timestamp
dpp::cache_policy_t
channel_policy
emoji_policy
guild_policy
role_policy
user_policy
dpp::cluster
token
last_identify
cluster_id
intents
maxclusters
numshards
rest_ping
me
cache_policy
ws_mode
terminating
request_timeout
socketengine
on_voice_channel_effect_send
on_voice_state_update
on_voice_client_platform
on_voice_client_disconnect
on_voice_client_speaking
on_log
on_socket_close
on_guild_join_request_delete
on_interaction_create
on_slashcommand
on_button_click
on_autocomplete
on_select_click
on_message_context_menu
on_user_context_menu
on_form_submit
on_guild_delete
on_channel_delete
on_channel_update
on_ready
on_message_delete
on_guild_member_remove
on_resumed
on_guild_role_create
on_typing_start
on_message_reaction_add
on_guild_members_chunk
on_message_reaction_remove
on_guild_create
on_channel_create
on_message_reaction_remove_emoji
on_message_delete_bulk
on_guild_role_update
on_guild_role_delete
on_channel_pins_update
on_message_reaction_remove_all
on_voice_server_update
on_guild_emojis_update
on_guild_stickers_update
on_presence_update
on_webhooks_update
on_automod_rule_create
on_automod_rule_update
on_automod_rule_delete
on_automod_rule_execute
on_guild_member_add
on_invite_delete
on_guild_update
on_guild_integrations_update
on_guild_member_update
on_invite_create
on_message_update
on_user_update
on_message_create
on_message_poll_vote_add
on_message_poll_vote_remove
on_guild_audit_log_entry_create
on_guild_ban_add
on_guild_ban_remove
on_integration_create
on_integration_update
on_integration_delete
on_thread_create
on_thread_update
on_thread_delete
on_thread_list_sync
on_thread_member_update
on_thread_members_update
on_guild_scheduled_event_create
on_guild_scheduled_event_update
on_guild_scheduled_event_delete
on_guild_scheduled_event_user_add
on_guild_scheduled_event_user_remove
on_voice_buffer_send
on_voice_ready
on_voice_receive
on_voice_receive_combined
on_voice_track_marker
on_stage_instance_create
on_stage_instance_update
on_stage_instance_delete
on_entitlement_create
on_entitlement_update
on_entitlement_delete
dpp::event_router_t< T >
dpp::event_router_t< dpp::autocomplete_t >
< dpp::autocomplete_t >
dpp::event_router_t< dpp::automod_rule_create_t >
< dpp::automod_rule_create_t >
dpp::event_router_t< dpp::automod_rule_delete_t >
< dpp::automod_rule_delete_t >
dpp::event_router_t< dpp::automod_rule_execute_t >
< dpp::automod_rule_execute_t >
dpp::event_router_t< dpp::automod_rule_update_t >
< dpp::automod_rule_update_t >
dpp::event_router_t< dpp::button_click_t >
< dpp::button_click_t >
dpp::event_router_t< dpp::channel_create_t >
< dpp::channel_create_t >
dpp::event_router_t< dpp::channel_delete_t >
< dpp::channel_delete_t >
dpp::event_router_t< dpp::channel_pins_update_t >
< dpp::channel_pins_update_t >
dpp::event_router_t< dpp::channel_update_t >
< dpp::channel_update_t >
dpp::event_router_t< dpp::entitlement_create_t >
< dpp::entitlement_create_t >
dpp::event_router_t< dpp::entitlement_delete_t >
< dpp::entitlement_delete_t >
dpp::event_router_t< dpp::entitlement_update_t >
< dpp::entitlement_update_t >
dpp::event_router_t< dpp::form_submit_t >
< dpp::form_submit_t >
dpp::event_router_t< dpp::guild_audit_log_entry_create_t >
< dpp::guild_audit_log_entry_create_t >
dpp::event_router_t< dpp::guild_ban_add_t >
< dpp::guild_ban_add_t >
dpp::event_router_t< dpp::guild_ban_remove_t >
< dpp::guild_ban_remove_t >
dpp::event_router_t< dpp::guild_create_t >
< dpp::guild_create_t >
dpp::event_router_t< dpp::guild_delete_t >
< dpp::guild_delete_t >
dpp::event_router_t< dpp::guild_emojis_update_t >
< dpp::guild_emojis_update_t >
dpp::event_router_t< dpp::guild_integrations_update_t >
< dpp::guild_integrations_update_t >
dpp::event_router_t< dpp::guild_join_request_delete_t >
< dpp::guild_join_request_delete_t >
dpp::event_router_t< dpp::guild_member_add_t >
< dpp::guild_member_add_t >
dpp::event_router_t< dpp::guild_member_remove_t >
< dpp::guild_member_remove_t >
dpp::event_router_t< dpp::guild_member_update_t >
< dpp::guild_member_update_t >
dpp::event_router_t< dpp::guild_members_chunk_t >
< dpp::guild_members_chunk_t >
dpp::event_router_t< dpp::guild_role_create_t >
< dpp::guild_role_create_t >
dpp::event_router_t< dpp::guild_role_delete_t >
< dpp::guild_role_delete_t >
dpp::event_router_t< dpp::guild_role_update_t >
< dpp::guild_role_update_t >
dpp::event_router_t< dpp::guild_scheduled_event_create_t >
< dpp::guild_scheduled_event_create_t >
dpp::event_router_t< dpp::guild_scheduled_event_delete_t >
< dpp::guild_scheduled_event_delete_t >
dpp::event_router_t< dpp::guild_scheduled_event_update_t >
< dpp::guild_scheduled_event_update_t >
dpp::event_router_t< dpp::guild_scheduled_event_user_add_t >
< dpp::guild_scheduled_event_user_add_t >
dpp::event_router_t< dpp::guild_scheduled_event_user_remove_t >
< dpp::guild_scheduled_event_user_remove_t >
dpp::event_router_t< dpp::guild_stickers_update_t >
< dpp::guild_stickers_update_t >
dpp::event_router_t< dpp::guild_update_t >
< dpp::guild_update_t >
dpp::event_router_t< dpp::integration_create_t >
< dpp::integration_create_t >
dpp::event_router_t< dpp::integration_delete_t >
< dpp::integration_delete_t >
dpp::event_router_t< dpp::integration_update_t >
< dpp::integration_update_t >
dpp::event_router_t< dpp::interaction_create_t >
< dpp::interaction_create_t >
dpp::event_router_t< dpp::invite_create_t >
< dpp::invite_create_t >
dpp::event_router_t< dpp::invite_delete_t >
< dpp::invite_delete_t >
dpp::event_router_t< dpp::log_t >
< dpp::log_t >
dpp::event_router_t< dpp::message_context_menu_t >
< dpp::message_context_menu_t >
dpp::event_router_t< dpp::message_create_t >
< dpp::message_create_t >
dpp::event_router_t< dpp::message_delete_bulk_t >
< dpp::message_delete_bulk_t >
dpp::event_router_t< dpp::message_delete_t >
< dpp::message_delete_t >
dpp::event_router_t< dpp::message_poll_vote_add_t >
< dpp::message_poll_vote_add_t >
dpp::event_router_t< dpp::message_poll_vote_remove_t >
< dpp::message_poll_vote_remove_t >
dpp::event_router_t< dpp::message_reaction_add_t >
< dpp::message_reaction_add_t >
dpp::event_router_t< dpp::message_reaction_remove_all_t >
< dpp::message_reaction_remove_all_t >
dpp::event_router_t< dpp::message_reaction_remove_emoji_t >
< dpp::message_reaction_remove_emoji_t >
dpp::event_router_t< dpp::message_reaction_remove_t >
< dpp::message_reaction_remove_t >
dpp::event_router_t< dpp::message_update_t >
< dpp::message_update_t >
dpp::event_router_t< dpp::presence_update_t >
< dpp::presence_update_t >
dpp::event_router_t< dpp::ready_t >
< dpp::ready_t >
dpp::event_router_t< dpp::resumed_t >
< dpp::resumed_t >
dpp::event_router_t< dpp::select_click_t >
< dpp::select_click_t >
dpp::event_router_t< dpp::slashcommand_t >
< dpp::slashcommand_t >
dpp::event_router_t< dpp::socket_close_t >
< dpp::socket_close_t >
dpp::event_router_t< dpp::stage_instance_create_t >
< dpp::stage_instance_create_t >
dpp::event_router_t< dpp::stage_instance_delete_t >
< dpp::stage_instance_delete_t >
dpp::event_router_t< dpp::stage_instance_update_t >
< dpp::stage_instance_update_t >
dpp::event_router_t< dpp::thread_create_t >
< dpp::thread_create_t >
dpp::event_router_t< dpp::thread_delete_t >
< dpp::thread_delete_t >
dpp::event_router_t< dpp::thread_list_sync_t >
< dpp::thread_list_sync_t >
dpp::event_router_t< dpp::thread_member_update_t >
< dpp::thread_member_update_t >
dpp::event_router_t< dpp::thread_members_update_t >
< dpp::thread_members_update_t >
dpp::event_router_t< dpp::thread_update_t >
< dpp::thread_update_t >
dpp::event_router_t< dpp::typing_start_t >
< dpp::typing_start_t >
dpp::event_router_t< dpp::user_context_menu_t >
< dpp::user_context_menu_t >
dpp::event_router_t< dpp::user_update_t >
< dpp::user_update_t >
dpp::event_router_t< dpp::voice_buffer_send_t >
< dpp::voice_buffer_send_t >
dpp::event_router_t< dpp::voice_channel_effect_send_t >
< dpp::voice_channel_effect_send_t >
dpp::event_router_t< dpp::voice_client_disconnect_t >
< dpp::voice_client_disconnect_t >
dpp::event_router_t< dpp::voice_client_platform_t >
< dpp::voice_client_platform_t >
dpp::event_router_t< dpp::voice_client_speaking_t >
< dpp::voice_client_speaking_t >
dpp::event_router_t< dpp::voice_ready_t >
< dpp::voice_ready_t >
dpp::event_router_t< dpp::voice_receive_t >
< dpp::voice_receive_t >
dpp::event_router_t< dpp::voice_server_update_t >
< dpp::voice_server_update_t >
dpp::event_router_t< dpp::voice_state_update_t >
< dpp::voice_state_update_t >
dpp::event_router_t< dpp::voice_track_marker_t >
< dpp::voice_track_marker_t >
dpp::event_router_t< dpp::webhooks_update_t >
< dpp::webhooks_update_t >
dpp::http_request
endpoint
mimetype
parameters
postdata
protocol
reason
method
file_content
file_mimetypes
file_name
req_headers
waiting
dpp::json_interface< T >
dpp::json_interface< user >
< user >
dpp::managed
id
dpp::request_concurrency_queue
in_index
terminating
requests
creator
in_mutex
rem_mutex
in_timer
buckets
removals
requests_in
dpp::request_queue
creator
requests_in
globally_ratelimited
terminating
globally_limited_until
in_queue_pool_size
dpp::snowflake
value
dpp::socket_engine_base
owner
fds_mutex
fds
stats
dpp::socket_stats
active_fds
deletions
errors
iterations
reads
updates
writes
engine_type
dpp::user
global_name
username
avatar
avatar_decoration
primary_guild
flags
discriminator
refcount
dpp::utility::iconhash
first
second
dpp::utility::primaryguild
id
enabled
tag
badge
http_method
int
size_t
std::atomic< T >
ptr
std::atomic< bool >
ptr
< bool >
atomic_bool
std::basic_string< Char >
std::basic_string_view< Char >
std::map< K, T >
keys
elements
std::map< std::string, dpp::bucket_t >
keys
elements
< std::string, dpp::bucket_t >
std::multimap< K, T >
keys
elements
std::multimap< std::string, std::string >
< std::string, std::string >
std::mutex
std::shared_mutex
std::string
std::string_view
std::unique_ptr< T >
ptr
std::unique_ptr< dpp::http_request >
ptr
< dpp::http_request >
std::unique_ptr< dpp::request_concurrency_queue >
ptr
< dpp::request_concurrency_queue >
std::unique_ptr< dpp::socket_engine_base >
ptr
< dpp::socket_engine_base >
std::unordered_map< K, T >
keys
elements
std::unordered_map< dpp::socket, std::unique_ptr< socket_events > >
< dpp::socket, std::unique_ptr< socket_events > >
std::vector< T >
elements
std::vector< std::string >
elements
< std::string >
std::vector< std::unique_ptr< dpp::http_request > >
elements
< std::unique_ptr< dpp::http_request > >
std::vector< std::unique_ptr< dpp::request_concurrency_queue > >
elements
< std::unique_ptr< dpp::request_concurrency_queue > >
time_t
uint16_t
uint32_t
uint64_t
uint8_t
websocket_protocol_t
- dpp::request_queue
  creator
- dpp::request_queue
  get_active_request_count
- dpp::request_queue
  get_request_queue_count
- dpp::request_queue
  globally_limited_until
- dpp::request_queue
  globally_ratelimited
- dpp::request_queue
  in_queue_pool_size
- dpp::request_queue
  is_globally_ratelimited
- dpp::request_queue
  post_request
- dpp::request_queue
  request_concurrency_queue
- dpp::request_queue
  request_queue
- dpp::request_queue
  requests_in
- dpp::request_queue
  terminating
- dpp::request_queue
  ~request_queue