失败请求,其中包含模拟错误的文件中随机选择的错误。
配置示例
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/rc.schema.json",
"plugins": [
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "genericRandomErrorPlugin"
}
],
"urlsToWatch": [
"https://api.openai.com/*"
],
"genericRandomErrorPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/genericrandomerrorplugin.schema.json",
"errorsFile": "errors.json"
}
}
配置属性
| 财产 | 描述 | 违约 |
|---|---|---|
errorsFile |
包含错误响应的文件的路径。 | 无默认值 |
rate |
失败的请求百分比,并出现随机错误。 介于 0 和 100 之间的值。 | 50 |
retryAfterInSeconds |
重试请求之前等待的秒数。 包含在动态限制的 Retry-After 响应标头中。 |
5 |
命令行选项
| 名称 | 描述 | 违约 |
|---|---|---|
-f, --failure-rate <failure rate> |
失败的请求百分比,并出现随机错误。 介于 0 和 100 之间的值。 | 50 |
注解
每个响应 Retry-After 值
默认情况下, Retry-After 标头使用全局 retryAfterInSeconds 值。 可以使用错误响应文件中的语法(即N重试前等待的秒数)基于@dynamic=N每个响应重写此值。
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.2.0/genericrandomerrorplugin.errorsfile.schema.json",
"errors": [
{
"request": {
"url": "https://api.openai.com/*"
},
"responses": [
{
"statusCode": 429,
"headers": [
{
"name": "Retry-After",
"value": "@dynamic=17"
}
],
"body": {
"error": {
"message": "Rate limit exceeded. Wait 17 seconds."
}
}
}
]
}
]
}
在此示例中, Retry-After 标头对此响应使用 17 秒,而不考虑全局 retryAfterInSeconds 设置。 该值在每个后续限制请求上递增,就像使用纯 @dynamic 令牌一样。