Phase 4 (认证+预算+限流): - AuthMiddleware: Bearer Key (API) / Cookie+Nonce (管理端) - BudgetMiddleware: 月度预算检查 (api_key_usage 表) - QuotaMiddleware: RPM/TPM 双维度限流 - RateLimit 子系统: Redis 滑动窗口 + Transient 降级 Phase 5 (路由+转换): - ModelMapper: 18 模型映射 + 别名 + auto 路由 - RequestTransformer: OpenAI → WPMind (体积/token 上限) - ResponseTransformer: WPMind → OpenAI 格式 - RouteMiddleware: 分发到 PublicAPI - RequestTransformMiddleware / ResponseTransformMiddleware Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Rate Store Result DTO
|
|
*
|
|
* Immutable result from a rate-limit consume operation.
|
|
*
|
|
* @package WPMind\Modules\ApiGateway\RateLimit
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace WPMind\Modules\ApiGateway\RateLimit;
|
|
|
|
/**
|
|
* Class RateStoreResult
|
|
*
|
|
* Read-only value object returned by rate store operations.
|
|
*/
|
|
final class RateStoreResult {
|
|
|
|
/**
|
|
* Whether the request is allowed under the rate limit.
|
|
*
|
|
* @var bool
|
|
*/
|
|
public readonly bool $allowed;
|
|
|
|
/**
|
|
* Number of remaining requests in the current window.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $remaining;
|
|
|
|
/**
|
|
* Unix epoch timestamp when the current window resets.
|
|
*
|
|
* @var int
|
|
*/
|
|
public readonly int $reset_epoch;
|
|
|
|
/**
|
|
* @param bool $allowed Whether the request is allowed.
|
|
* @param int $remaining Remaining capacity in the window.
|
|
* @param int $reset_epoch Unix timestamp when the window resets.
|
|
*/
|
|
public function __construct( bool $allowed, int $remaining, int $reset_epoch ) {
|
|
$this->allowed = $allowed;
|
|
$this->remaining = $remaining;
|
|
$this->reset_epoch = $reset_epoch;
|
|
}
|
|
}
|