add a global rate limiter for WFS requests to avoid overloading upstream services#111
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable WFS request throttling in the structured WFS execution layer to reduce pressure on the upstream Géoplateforme service. It adds a reusable rate-limiter helper, wires it into the shared WFS execution paths, and documents the new runtime setting.
Changes:
- Added a reusable
RateLimiterhelper with dedicated unit tests. - Applied WFS rate limiting in
src/helpers/wfs_engine/execution.tsusingGPF_WFS_RATE_LIMIT. - Documented the new configuration option in the README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
test/helpers/RateLimiter.test.ts |
Adds unit tests for limiter construction, limits, and boundary behavior. |
src/helpers/wfs_engine/execution.ts |
Creates the global WFS limiter and applies it before shared WFS POST execution paths. |
src/helpers/RateLimiter.ts |
Introduces the reusable rate limiter implementation and factory helper. |
README.md |
Documents GPF_WFS_RATE_LIMIT in the configuration table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
(closes #94)
What changed
RateLimiterhelper inspired by Python ratelimiterGPF_WFS_RATE_LIMITto configure the max number of WFS requests per secondDefault behavior
By default, WFS calls are limited to
30 requests/second, aligned with GPF usage limits.Why
Some tools can trigger multiple WFS calls in a short time. This change makes request bursts safer and keeps the server within expected upstream usage constraints (even in whitelisted runtime environments)
Tests
Limitation
The use of free function (instead of method in WfsClient) lead to use a global rate limiter variable. A note is added to suggest the add of getFeatureCollection / getFeatureCollections / getFeatureCount in a further refactoring ( issue #33 )