39 namespace discord_core_internal {
41 struct rate_limit_data {
42 friend class https_connection_stack_holder;
43 friend class https_connection_manager;
44 friend class rate_limit_stack_holder;
45 friend class https_rnr_builder;
46 friend class rate_limit_queue;
47 friend class https_client;
50 std::unique_lock<std::mutex> lock{ accessMutex, std::defer_lock };
51 std::atomic<milliseconds> sampledTimeInMs{ milliseconds{} };
52 std::atomic<seconds> sRemain{ seconds{} };
53 std::atomic_int64_t getsRemaining{ 1 };
54 std::atomic_bool areWeASpecialBucket{};
55 std::atomic_bool didWeHitRateLimit{};
56 std::atomic_bool doWeWait{};
57 jsonifier::string bucket{};
58 std::mutex accessMutex{};
61 class rate_limit_queue {
63 friend class https_client;
65 DCA_INLINE rate_limit_queue() =
default;
67 DCA_INLINE
void initialize();
69 DCA_INLINE rate_limit_data* getEndpointAccess(https_workload_type workloadType);
71 DCA_INLINE
void releaseEndPointAccess(https_workload_type type);
74 unordered_map<jsonifier::string, unique_ptr<rate_limit_data>> rateLimits{};
75 unordered_map<https_workload_type, jsonifier::string> buckets{};
The main namespace for the forward-facing interfaces.