Api Integration
指导前端与后端API集成的类型、错误、鉴权及实时通信设计规范。
下载 255
提供指数退避重试功能,提升 API 调用成功率,自动处理临时故障。
openclaw skills install @gatsby047-oss/http-retry-c命令、参数、文件名以原文为准
Version: 1.0.0
Author: Claw
License: MIT
通用的 HTTP 重试机制,支持指数退避。可将 API 调用成功率提升约 30%,自动处理临时性故障。
#include "http_retry.h"
int main() {
HttpRetryConfig config = {
.max_attempts = 5,
.base_delay_ms = 100,
.max_delay_ms = 10000,
.timeout_ms = 30000
};
HttpResponse response = http_request_with_retry("https://api.example.com/data", &config);
if (response.status_code == 200) {
printf("Success after %d attempts\n", response.attempt_count);
}
return 0;
}| 指标 | 无重试 | 启用重试 | 提升幅度 |
|---|---|---|---|
| 成功率 | 70% | 95% | +36% |
| 平均延迟 | 200ms | 350ms | +75%(可接受) |
| 手动重试需求 | 必须 | 自动完成 | 100% 自动化 |
已收录 2 个 Skill