HttpBucket constructor
- HttpHandler handler,
- {required String id,
- required int remaining,
- required DateTime resetAt}
Create a new HttpBucket.
Every response from Discord's API contains headers to handle rate limiting. This class keeps track of these headers in a single rate limit bucket (identified by the xRateLimitBucket header) and allows the client to anticipate rate limits.
Every HttpHandler stores a map of HttpRoute.rateLimitId to HttpBucket and implicitly checks each request before sending it, waiting if a rate limit would be exceeded.
External references:
- Discord API Reference: https://discord.com/developers/docs/topics/rate-limits#rate-limits
Implementation
HttpBucket(
this.handler, {
required this.id,
required int remaining,
required DateTime resetAt,
}) : _remaining = remaining,
_resetAt = resetAt;