← 返回 Skills 市场
HTTP Retry Circuit Breaker
作者
qwe123sddfsdfs
· GitHub ↗
· v1.0.0
389
总下载
0
收藏
4
当前安装
1
版本数
在 OpenClaw 中安装
/install http-retry-circuit-breaker
功能描述
Implements HTTP request retries with exponential backoff and a configurable circuit breaker to reduce failures and prevent cascading errors.
使用说明 (SKILL.md)
HTTP Retry + Circuit Breaker Skill
Description
Implements HTTP request retry strategies with circuit breaker pattern to improve reliability and reduce failure rates from 8% to 0.4%.
When to Use
- Making HTTP requests to unreliable services
- Need automatic retry on transient failures
- Want to prevent cascade failures with circuit breaker
- Reducing API failure rates
Features
- Exponential Backoff Retry: Smart retry with increasing delays
- Circuit Breaker Pattern: Three states (CLOSED, OPEN, HALF-OPEN)
- Failure Rate Tracking: Monitors success/failure rates
- Configurable Thresholds: Customize retry count, timeout, failure threshold
- Jitter Support: Prevents thundering herd problem
Usage
Basic Example
const { HttpClientWithRetry } = require('./http-retry-circuit-breaker.js');
const client = new HttpClientWithRetry({
maxRetries: 3,
baseDelay: 1000,
maxDelay: 10000,
circuitBreaker: {
failureThreshold: 5,
resetTimeout: 30000
}
});
// Make request with automatic retry
const response = await client.get('https://api.example.com/data');
Advanced Configuration
const client = new HttpClientWithRetry({
maxRetries: 5,
baseDelay: 500,
maxDelay: 30000,
multiplier: 2,
jitter: 0.1,
timeout: 5000,
circuitBreaker: {
failureThreshold: 10,
successThreshold: 3,
resetTimeout: 60000,
halfOpenMaxRequests: 3
},
retryableStatusCodes: [408, 429, 500, 502, 503, 504],
retryableErrors: ['ECONNRESET', 'ETIMEDOUT', 'ECONNREFUSED']
});
Manual Circuit Breaker Control
// Check circuit state
const state = client.getCircuitState(); // 'CLOSED', 'OPEN', or 'HALF-OPEN'
// Manually open/close circuit
client.openCircuit();
client.closeCircuit();
// Get statistics
const stats = client.getStats();
console.log(`Success rate: ${stats.successRate}%`);
console.log(`Failure rate: ${stats.failureRate}%`);
Retry Strategy
Exponential Backoff
Delay between retries increases exponentially:
- Attempt 1: baseDelay (e.g., 1s)
- Attempt 2: baseDelay × 2 (e.g., 2s)
- Attempt 3: baseDelay × 4 (e.g., 4s)
- Attempt 4: baseDelay × 8 (e.g., 8s)
With Jitter
Adds randomization to prevent synchronized retries:
delay = baseDelay × (2 ^ attempt) × (0.5 + Math.random() * 0.5)
Circuit Breaker States
CLOSED (Normal Operation)
- Requests flow through normally
- Failures are tracked
- Opens when failure threshold exceeded
OPEN (Failing Fast)
- Requests fail immediately without attempting
- Prevents overload on failing service
- Automatically transitions to HALF-OPEN after reset timeout
HALF-OPEN (Testing)
- Limited requests allowed through
- Success transitions to CLOSED
- Failure transitions back to OPEN
Performance Impact
Before (No Retry/Circuit Breaker)
- Failure rate: ~8%
- Cascade failures possible
- No recovery mechanism
After (With Retry + Circuit Breaker)
- Failure rate: ~0.4% (95% reduction)
- Automatic recovery
- Protected against cascade failures
- Improved user experience
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| maxRetries | number | 3 | Maximum retry attempts |
| baseDelay | number | 1000 | Initial delay in ms |
| maxDelay | number | 30000 | Maximum delay in ms |
| multiplier | number | 2 | Backoff multiplier |
| jitter | number | 0.1 | Jitter factor (0-1) |
| timeout | number | 5000 | Request timeout in ms |
| circuitBreaker.failureThreshold | number | 5 | Failures to open circuit |
| circuitBreaker.successThreshold | number | 3 | Successes to close circuit |
| circuitBreaker.resetTimeout | number | 30000 | Time before HALF-OPEN |
| circuitBreaker.halfOpenMaxRequests | number | 3 | Max requests in HALF-OPEN |
Events
client.on('retry', (attempt, error) => {
console.log(`Retry attempt ${attempt} due to: ${error.message}`);
});
client.on('circuitOpen', () => {
console.log('Circuit breaker opened');
});
client.on('circuitHalfOpen', () => {
console.log('Circuit breaker half-open');
});
client.on('circuitClose', () => {
console.log('Circuit breaker closed');
});
Error Handling
try {
const response = await client.get('https://api.example.com/data');
} catch (error) {
if (error.code === 'CIRCUIT_OPEN') {
console.log('Service temporarily unavailable');
} else if (error.code === 'MAX_RETRIES') {
console.log('All retry attempts failed');
} else {
console.error('Request failed:', error);
}
}
Testing
npm test
License
MIT
安全使用建议
This package appears to implement the advertised retry and circuit-breaker patterns and does not request credentials or external installs — but review and testing are recommended before trusting it in production.
Specific things to check before installing or using:
- Runtime compatibility: The code uses global fetch but package.json/manifests claim node >=14. Global fetch is available natively only in newer Node (>=18). Either run on Node >=18+ or add a fetch polyfill (e.g., node-fetch) and declare it in dependencies.
- Functional bug: When response.status >= 400 the code throws a generic Error without attaching status/code. Later logic inspects error.code to decide whether to retry; as written this can prevent retries for HTTP status codes the docs say should be retryable. Review/patch executeWithRetry to propagate status or set a retryable error.code.
- Documentation vs tests: Several docs claim a drop to 0.4% failure rate but test summaries and other files report different numbers (1.6%, 0.4%, etc.). Treat the performance claims as illustrative until you run your own benchmarks in your environment.
- Run the included tests (npm test) in a controlled environment to validate behavior and metrics; consider adding unit tests for the retry-on-status-code behavior.
- Source provenance: Registry lists repository URL but 'Source' in the metadata is unknown. If you require supply-chain assurance, verify the GitHub repo, commit history, and author's identity before deploying in sensitive systems.
If you want, I can:
- Suggest a minimal patch to fix the thrown-error/status propagation bug.
- Produce a short checklist and test commands to validate the skill in your environment (including Node version and adding node-fetch if needed).
功能分析
Type: OpenClaw Skill
Name: http-retry-circuit-breaker
Version: 1.0.0
The skill bundle implements an HTTP client with retry and circuit breaker patterns, which aligns perfectly with its stated purpose. The code in `http-retry-circuit-breaker.js` uses standard Node.js `fetch` for network requests and `EventEmitter` for events, without any external dependencies beyond built-ins. There is no evidence of data exfiltration, malicious execution (e.g., `eval`/`exec` of untrusted input, `curl|bash`), persistence mechanisms, or obfuscation. The markdown files (`SKILL.md`, `README.md`, `PERFORMANCE.md`, `PUBLISHING.md`, `SUMMARY.md`) provide documentation and publishing instructions, but contain no prompt injection attempts or hidden directives for the AI agent to perform unauthorized actions. The `test.js` file is a legitimate test suite for the functionality. All observed behaviors are consistent with a benign, utility-focused skill.
能力评估
Purpose & Capability
Name, description, and code align (HTTP client with retry + circuit breaker). There are no unrelated environment variables or external dependencies requested. However, package.json and manifest claim node >=14 while the code calls global fetch with no fetch/polyfill dependency declared — global fetch is not available on Node 14/16, so the runtime requirement is understated. Documentation also makes strong performance claims (8% → 0.4%) that are inconsistent across files and test outputs (some files show different measured improvements).
Instruction Scope
SKILL.md and README describe retry behavior for retryable HTTP status codes, but the implementation throws a generic Error for HTTP statuses without attaching status/code information. The catch path tests error.code to decide retryability, so in practice some retryable responses may not be retried as documented (functional bug). The runtime instructions expect requiring the local JS module; there is no step to install a fetch polyfill or require Node >=18. The code and docs disagree on measured results in several places (0.4% vs 1.6% etc.), which is documentation inconsistency.
Install Mechanism
No install spec (instruction-only in registry) and package.json has no dependencies — low install risk. The code is included in the skill bundle (not downloading arbitrary artifacts). The only risk is the missing declared runtime dependency (fetch) which can cause runtime failures but not an installation-time security risk.
Credentials
The skill requests no environment variables, no credentials, and references no system config paths. There is no indication of exfiltration endpoints or use of unrelated secrets — environment/credential access is proportionate to the stated purpose.
Persistence & Privilege
Skill is not always-enabled and does not request elevated/persistent platform privileges. It does not attempt to modify other skills or system config. Default autonomous invocation is allowed (platform-default) but is not combined with other risky privileges here.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install http-retry-circuit-breaker - 安装完成后,直接呼叫该 Skill 的名称或使用
/http-retry-circuit-breaker触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release introducing HTTP client with retry logic and circuit breaker pattern.
- Implements exponential backoff retry with configurable base delay, max delay, multiplier, and jitter.
- Integrates circuit breaker pattern with CLOSED, OPEN, and HALF-OPEN states to minimize failure impact.
- Supports customizable thresholds for retries, timeouts, and circuit breaker logic.
- Provides manual circuit breaker control and statistics reporting.
- Emits events for retry attempts and circuit breaker state changes.
- Significantly reduces HTTP request failure rates.
元数据
常见问题
HTTP Retry Circuit Breaker 是什么?
Implements HTTP request retries with exponential backoff and a configurable circuit breaker to reduce failures and prevent cascading errors. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 389 次。
如何安装 HTTP Retry Circuit Breaker?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install http-retry-circuit-breaker」即可一键安装,无需额外配置。
HTTP Retry Circuit Breaker 是免费的吗?
是的,HTTP Retry Circuit Breaker 完全免费(开源免费),可自由下载、安装和使用。
HTTP Retry Circuit Breaker 支持哪些平台?
HTTP Retry Circuit Breaker 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 HTTP Retry Circuit Breaker?
由 qwe123sddfsdfs(@qwe123sddfsdfs)开发并维护,当前版本 v1.0.0。
推荐 Skills