wpmind/modules/api-gateway/includes/Stream/SseSlot.php
LinuxJoy 29459364a8 feat: API Gateway Phase 6+7 — SSE 流式处理 + 错误处理 + 审计日志
Phase 6 (SSE 流式处理):
- CancellationToken: 客户端断开检测
- SseConcurrencyGuard: 全局+Key 并发槽位管理
- UpstreamStreamClient: 上游 Provider 流式代理
- SseStreamController: SSE 生命周期编排
- RouteMiddleware: 集成 SSE 流式分支

Phase 7 (错误处理+审计):
- ErrorMapper: WP_Error → OpenAI 错误格式映射 (14种)
- ErrorMiddleware: 异常捕获 + OpenAI 兼容错误响应
- LogMiddleware: 审计日志写入 + 用量统计 upsert

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-08 20:37:10 +08:00

56 lines
1.1 KiB
PHP

<?php
/**
* SSE Slot DTO
*
* Immutable data transfer object representing an acquired SSE concurrency slot.
*
* @package WPMind\Modules\ApiGateway\Stream
* @since 1.0.0
*/
declare(strict_types=1);
namespace WPMind\Modules\ApiGateway\Stream;
/**
* Class SseSlot
*
* Read-only value object returned when a concurrency slot is
* successfully acquired. Used to heartbeat and release the slot.
*/
final class SseSlot {
/**
* The API key identifier that owns this slot.
*
* @var string
*/
public readonly string $key_id;
/**
* The unique request ID for this SSE connection.
*
* @var string
*/
public readonly string $request_id;
/**
* Composite key used for slot tracking in transients.
*
* @var string
*/
public readonly string $slot_key;
/**
* Constructor.
*
* @param string $key_id API key identifier.
* @param string $request_id Unique request ID.
* @param string $slot_key Composite slot tracking key.
*/
public function __construct( string $key_id, string $request_id, string $slot_key ) {
$this->key_id = $key_id;
$this->request_id = $request_id;
$this->slot_key = $slot_key;
}
}