承接 vectorifyai/guzzle-rate-limiter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vectorifyai/guzzle-rate-limiter

最新稳定版本:1.0.2

Composer 安装命令:

composer require vectorifyai/guzzle-rate-limiter

包简介

Guzzle middleware for preventive rate limiting with multi-store support, progressive delays, and cross-process coordination.

README 文档

README

Latest Version Total Downloads Tests License

A sophisticated Guzzle middleware for preventive rate limiting with multi-store support, progressive delays, and cross-process coordination. It works in accordance with the IETF standard by using the X-RateLimit-Remaining (number of requests remaining in the current rate limit window) and Retry-After (number of seconds to wait before retrying the request again) values available in the response headers.

Features

  • Intelligent Rate Limiting: Progressive delays based on remaining API quota
  • Multi-Store Support: InMemory, Laravel Cache, Symfony Cache, Filesystem, and more
  • Cross-Process Coordination: Share rate limit state across multiple processes (i.e. queue jobs)
  • Automatic Recovery: Handles 429 responses with exponential backoff
  • Flexible Configuration: Customizable thresholds and delays
  • PSR-3 Logging: Built-in logging with configurable levels

Installation

composer require vectorifyai/guzzle-rate-limiter

Quick Start

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Vectorify\GuzzleRateLimiter\RateLimiterMiddleware;
use Vectorify\GuzzleRateLimiter\Stores\InMemoryStore;

$stack = HandlerStack::create();
$stack->push(new RateLimiterMiddleware(new InMemoryStore));

$client = new Client([
    'handler' => $stack,
]);

Usage

Basic Usage

use Vectorify\GuzzleRateLimiter\RateLimiterMiddleware;
use Vectorify\GuzzleRateLimiter\Stores\InMemoryStore;

$middleware = new RateLimiterMiddleware(new InMemoryStore);

Laravel Integration

use Vectorify\GuzzleRateLimiter\Stores\LaravelStore;

$store = new LaravelStore(cache(), 'api:rate_limit');
$middleware = new RateLimiterMiddleware($store);

Symfony Integration

use Vectorify\GuzzleRateLimiter\Stores\SymfonyStore;
use Symfony\Component\Cache\Adapter\RedisAdapter;

$cache = new RedisAdapter(/* redis client */);
$store = new SymfonyStore($cache, 'api:rate_limit');
$middleware = new RateLimiterMiddleware($store);

Filesystem Integration

use Vectorify\GuzzleRateLimiter\Stores\FilesystemStore;
use League\Flysystem\Local\LocalFilesystemAdapter;

// Local filesystem
$adapter = new LocalFilesystemAdapter('/path/to/cache');
$store = new FilesystemStore($adapter);
$middleware = new RateLimiterMiddleware($store);

// AWS S3
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
$s3Adapter = new AwsS3V3Adapter($s3Client, $bucket, $prefix);
$store = new FilesystemStore($s3Adapter);

// SFTP
use League\Flysystem\PhpseclibV3\SftpAdapter;
$sftpAdapter = new SftpAdapter(/* SFTP connection settings */);
$store = new FilesystemStore($sftpAdapter);

Advanced Configuration

$middleware = new RateLimiterMiddleware(
    store: new InMemoryStore,
    cachePrefix: 'my_api:rate_limit',
    logger: $customLogger,
);

Changelog

Please see Releases for more information on what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 5.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-08