Skip to content

v1.1.0 — Rate limiting and intelligent retry

Latest

Choose a tag to compare

@jordanpartridge jordanpartridge released this 19 May 23:20
852e1ae

Adds opt-in GitHub API rate limiting with configurable retry and exponential backoff. Fully backward-compatible — no changes to existing consumers.

New public API

  • `ConduitUi\GitHubConnector\RateLimit\RateLimitConfig` — readonly value object configuring retry attempts, delay, exponential backoff, and throw behavior.
  • `ConduitUi\GitHubConnector\RateLimit\RateLimitState` — tracks GitHub rate limit headers (`X-RateLimit-Limit`, `Remaining`, `Reset`, `Used`) across every response.
  • `ConduitUi\GitHubConnector\RateLimit\HasRateLimiting` — trait providing retry logic integrated with Saloon's `HasTries`.
  • `Connector::withRateLimiting()` fluent enabler, plus an optional second constructor argument.

Behavior

  • State tracking is always on — `$connector->rateLimitState()` reflects the latest response headers regardless of whether retry is enabled.
  • Automatic retry is opt-in — pass a `RateLimitConfig` to the constructor or call `withRateLimiting()`.
  • Retries on rate-limit exhaustion (403 + `X-RateLimit-Remaining: 0`) and 5xx server errors.
  • Non-retryable errors (401, 404, 422, plain 403) throw immediately.

Usage

```php
use ConduitUi\GitHubConnector\Connector;
use ConduitUi\GitHubConnector\RateLimit\RateLimitConfig;

// Opt-in via constructor
$connector = new Connector($token, new RateLimitConfig(
retryAttempts: 3,
retryDelay: 1000,
useExponentialBackoff: true,
));

// Or fluently
$connector = (new Connector($token))->withRateLimiting();

// State is always available
$state = $connector->rateLimitState();
$state->getRemaining();
$state->isExceeded();
```

Downstream impact

Zero for existing consumers. `conduit-ui/pr` and other `^1.0` consumers automatically receive the new API but use none of it unless they call into it explicitly.

Closes #3.