feat: Add proactive rate limiting implementation#1
Open
yannrouillard wants to merge 1 commit intomainfrom
Open
feat: Add proactive rate limiting implementation#1yannrouillard wants to merge 1 commit intomainfrom
yannrouillard wants to merge 1 commit intomainfrom
Conversation
This implementation mirrors the rate limiting approach used in the Okta Terraform Provider, providing proactive throttling to prevent hitting Auth0 API rate limits. Key features: - Configurable max_api_capacity parameter (1-100%) with default 100% - Proactive request throttling when approaching rate limit thresholds - Support for Auth0's x-ratelimit-* headers and alternative formats - Comprehensive endpoint mapping based on Auth0's rate limit policy - Regex-based ID normalization for consistent bucket classification - Context-aware request cancellation and timeout handling - Extensive test coverage (98.1% ratelimit, 93.5% transport) The rate limiting is disabled by default (100% capacity) and can be enabled by setting max_api_capacity to a lower percentage or using the AUTH0_MAX_API_CAPACITY environment variable. Components added: - internal/ratelimit: Core rate limit management and status tracking - internal/transport: HTTP transport wrapper with throttling logic - Provider configuration: max_api_capacity parameter - Configuration integration: Rate-limited HTTP client setup - Comprehensive test suites for both packages - Usage example and documentation updates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements proactive rate limiting for the Auth0 Terraform Provider, mirroring the approach used in the Okta Terraform Provider. The implementation provides intelligent throttling to prevent hitting Auth0 API rate limits by monitoring usage and proactively sleeping when approaching capacity thresholds.
Key Features
max_api_capacityparameter (1-100%) with environment variable supportx-ratelimit-*headers and rate limit policyConfiguration
Or via environment variable:
export AUTH0_MAX_API_CAPACITY=70Implementation Details
internal/ratelimit): Tracks API usage per endpoint and bucketinternal/transport): HTTP transport wrapper with throttling logicPerformance Impact
Test Plan
Testing Commands
Manual Testing
The implementation can be tested by:
max_api_capacityto a low value (e.g., 10%)This implementation follows Auth0's rate limit policy documentation and provides a robust foundation for preventing API limit violations in large-scale Terraform deployments.