Skip to content

add a global rate limiter for WFS requests to avoid overloading upstream services#111

Merged
esgn merged 5 commits into
masterfrom
94-rate-limiting
May 5, 2026
Merged

add a global rate limiter for WFS requests to avoid overloading upstream services#111
esgn merged 5 commits into
masterfrom
94-rate-limiting

Conversation

@mborne
Copy link
Copy Markdown
Contributor

@mborne mborne commented May 5, 2026

(closes #94)

What changed

  • added a reusable RateLimiter helper inspired by Python ratelimiter
  • applied rate limiting to WFS request execution paths
  • introduced GPF_WFS_RATE_LIMIT to configure the max number of WFS requests per second
  • documented the new setting in the README
  • added unit tests covering normal usage, limits, boundary cases, and invalid configuration

Default 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

  • added dedicated unit tests for the rate limiter
  • existing WFS execution behavior remains unchanged apart from throttling protection

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 )

@esgn esgn self-requested a review May 5, 2026 09:58
@esgn esgn self-assigned this May 5, 2026
@esgn esgn requested a review from Copilot May 5, 2026 10:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RateLimiter helper with dedicated unit tests.
  • Applied WFS rate limiting in src/helpers/wfs_engine/execution.ts using GPF_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.

Comment thread src/helpers/RateLimiter.ts
Comment thread src/helpers/RateLimiter.ts
Comment thread src/helpers/wfs_engine/execution.ts
Comment thread src/helpers/RateLimiter.ts Outdated
esgn and others added 3 commits May 5, 2026 12:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@esgn esgn merged commit 39352d3 into master May 5, 2026
3 checks passed
@esgn esgn deleted the 94-rate-limiting branch May 5, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate limiting

3 participants