Skip to content

Commit ca09e24

Browse files
committed
Documentation tweaked
1 parent c11b844 commit ca09e24

6 files changed

Lines changed: 126 additions & 12 deletions

File tree

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,18 @@ Native `fetch`'s controversial behavior of not throwing errors for HTTP error st
289289

290290
## Documentation
291291

292-
| Topic | Description |
293-
| --------------------------------------------- | ------------------------------------------------------------------------- |
294-
| **[Complete Documentation](./docs/index.md)** | **Start here** - Documentation index and overview |
295-
| **[API Reference](./docs/api.md)** | Complete API documentation and configuration options |
296-
| **[Plugin Architecture](./docs/plugins.md)** | Plugin lifecycle, custom plugin authoring, and integration patterns |
297-
| **[Deduplication](./docs/deduplication.md)** | How deduplication works, hash config, optional TTL cleanup, limitations |
298-
| **[Error Handling](./docs/errorhandling.md)** | Strategies for managing errors, including `throwOnHttpError` |
299-
| **[Advanced Features](./docs/advanced.md)** | Per-request overrides, pending requests, circuit breakers, custom errors |
300-
| **[Hooks & Transformation](./docs/hooks.md)** | Lifecycle hooks, authentication, logging, request/response transformation |
301-
| **[Usage Examples](./docs/examples.md)** | Real-world patterns: REST clients, GraphQL, file uploads, microservices |
302-
| **[Compatibility](./docs/compatibility.md)** | Browser/Node.js support, polyfills, framework integration |
292+
| Topic | Description |
293+
| ------------------------------------------------------------ | ------------------------------------------------------------------------- |
294+
| **[Complete Documentation](./docs/index.md)** | **Start here** - Documentation index and overview |
295+
| **[API Reference](./docs/api.md)** | Complete API documentation and configuration options |
296+
| **[Plugin Architecture](./docs/plugins.md)** | Plugin lifecycle, custom plugin authoring, and integration patterns |
297+
| **[Deduplication](./docs/deduplication.md)** | How deduplication works, hash config, optional TTL cleanup, limitations |
298+
| **[Error Handling](./docs/errorhandling.md)** | Strategies for managing errors, including `throwOnHttpError` |
299+
| **[Advanced Features](./docs/advanced.md)** | Per-request overrides, pending requests, circuit breakers, custom errors |
300+
| **[Production Operations](./docs/production-operations.md)** | Pre-deploy checklist, alerting baseline, and incident playbook |
301+
| **[Hooks & Transformation](./docs/hooks.md)** | Lifecycle hooks, authentication, logging, request/response transformation |
302+
| **[Usage Examples](./docs/examples.md)** | Real-world patterns: REST clients, GraphQL, file uploads, microservices |
303+
| **[Compatibility](./docs/compatibility.md)** | Browser/Node.js support, polyfills, framework integration |
303304

304305
## Environment Requirements
305306

docs/advanced.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Advanced Features
22

3+
For deployment readiness, alerting, and incident response, use the canonical runbook in [production-operations.md](./production-operations.md).
4+
35
## Per-request Overrides
46

57
You can override any client option on a per-request basis by passing it in the `init` parameter:

docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
- Abort behavior for queued requests
5050
- Integration with dedupe, retries, and circuit breaker
5151

52+
- **[production-operations.md](./production-operations.md)** - Canonical production runbook and checklist
53+
- Pre-deployment configuration checklist
54+
- Metrics and alerting baseline
55+
- Incident playbook for circuit, latency, and rate-limit failures
56+
- Recommended baseline configurations
57+
5258
### **Hooks & Transformation**
5359

5460
- **[hooks.md](./hooks.md)** - Lifecycle hooks and request/response transformation
@@ -83,6 +89,7 @@
8389
6. **Read [api.md](./api.md)** for full option and plugin reference details
8490
7. **Read [plugins.md](./plugins.md)** to understand lifecycle, ordering, and custom plugins
8591
8. **Dive into [advanced.md](./advanced.md)** for retry strategy, circuit behavior, and production patterns
92+
9. **Use [production-operations.md](./production-operations.md)** when preparing rollout, alerts, and incident response
8693

8794
### **Alternative Learning Paths**
8895

@@ -116,6 +123,7 @@
116123
| Use `client(url).json()` style shortcuts | [api.md](./api.md#response-shortcuts-plugin) |
117124
| Reduce tail latency with parallel attempts | [hedging.md](./hedging.md) |
118125
| Cap concurrency with queue backpressure | [bulkhead.md](./bulkhead.md) |
126+
| Operate ffetch safely in production | [production-operations.md](./production-operations.md) |
119127

120128
## **Key Concepts**
121129

docs/plugins.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ const jsonShortcutPlugin: ClientPlugin<
298298
## App-Level Concerns
299299

300300
Plugins provide request-time mechanics, but some resilience concerns are best handled at application boundaries:
301+
For a deployment checklist, metrics baseline, and incident playbook, see [production-operations.md](./production-operations.md).
301302

302303
- **Graceful circuit recovery**: When a circuit closes, avoid sending all queued or waiting traffic at once. Recover gradually (for example, ramp request rate or release waiting callers in batches) to prevent thundering herd spikes.
303304
- **Bulkhead boundaries**: Decide bulkhead scope per dependency (service, host, or endpoint class). A single global bulkhead can cause unrelated traffic to compete for the same slots.

docs/production-operations.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Production Operations Guide
2+
3+
This guide is the canonical runbook for operating `@fetchkit/ffetch` in production.
4+
5+
## 1. Pre-Deployment Checklist
6+
7+
### Core configuration
8+
9+
- [ ] Set `timeout` per dependency SLA (avoid using one global value for everything).
10+
- [ ] Set `retries` conservatively (`1-3` in most systems).
11+
- [ ] Decide `throwOnHttpError` policy (`true` for strict exception flow, `false` for response-driven handling).
12+
- [ ] Use a runtime-appropriate `fetchHandler` for SSR/edge/custom environments.
13+
14+
### Resilience plugins
15+
16+
- [ ] Enable `circuitPlugin` for external dependencies.
17+
- [ ] Enable `bulkheadPlugin` for dependencies that can saturate under load.
18+
- [ ] Enable `dedupePlugin` on bursty read-heavy endpoints.
19+
- [ ] Enable `hedgePlugin` only for safe methods and latency-sensitive paths.
20+
- [ ] Validate plugin order assumptions when composing multiple plugins.
21+
22+
### Observability and hooks
23+
24+
- [ ] Instrument `before`/`after`/`onError` hooks for logs and metrics.
25+
- [ ] Track request latency (`p50/p95/p99`) and error-rate by endpoint.
26+
- [ ] Track resilience signals: circuit opens, bulkhead queue depth, retry counts.
27+
- [ ] Add request correlation IDs in `transformRequest`.
28+
29+
## 2. Operational Metrics
30+
31+
Minimum metrics to collect:
32+
33+
- Request count by endpoint/method/status
34+
- Latency histogram (`p50`, `p95`, `p99`)
35+
- Error count by error class (`TimeoutError`, `CircuitOpenError`, `NetworkError`, `RetryLimitError`, etc.)
36+
- Circuit breaker open events and duration
37+
- Bulkhead `activeCount`, `queueDepth`, rejection count
38+
- Retry attempts and eventual success-after-retry rate
39+
40+
## 3. Alerting Baseline
41+
42+
- Alert on sustained high error rate for a dependency.
43+
- Alert when circuit remains open beyond expected recovery windows.
44+
- Alert when bulkhead queue remains near capacity.
45+
- Alert when `p99` latency regresses significantly from baseline.
46+
47+
## 4. Incident Playbook
48+
49+
### Circuit open incidents
50+
51+
1. Check downstream dependency health first.
52+
2. Confirm `threshold`/`reset` values are aligned with failure patterns.
53+
3. Use fallback/degraded responses at app level while circuit is open.
54+
4. Avoid releasing queued traffic all at once during recovery.
55+
56+
### High latency incidents
57+
58+
1. Check bulkhead saturation (`activeCount`, `queueDepth`).
59+
2. Check retry inflation (too many retries amplifying load).
60+
3. If using hedging, verify `delay` and `maxHedges` are tuned for current latency distribution.
61+
62+
### Rate-limit incidents (429)
63+
64+
1. Ensure retry strategy honors `Retry-After` behavior.
65+
2. Reduce concurrency (`bulkhead`) and hedge aggressiveness.
66+
3. Add app-level backpressure or queueing upstream.
67+
68+
## 5. Recommended Baseline Configs
69+
70+
### Internal service-to-service client
71+
72+
```typescript
73+
createClient({
74+
timeout: 10_000,
75+
retries: 2,
76+
plugins: [
77+
circuitPlugin({ threshold: 5, reset: 30_000 }),
78+
bulkheadPlugin({ maxConcurrent: 20, maxQueue: 100 }),
79+
dedupePlugin({ ttl: 30_000 }),
80+
],
81+
})
82+
```
83+
84+
### Latency-sensitive read path
85+
86+
```typescript
87+
createClient({
88+
timeout: 5_000,
89+
retries: 1,
90+
plugins: [
91+
dedupePlugin({ ttl: 10_000 }),
92+
hedgePlugin({ delay: 75, maxHedges: 1 }),
93+
],
94+
})
95+
```
96+
97+
## 6. Related References
98+
99+
- [api.md](./api.md) for full option and plugin reference
100+
- [plugins.md](./plugins.md) for plugin lifecycle and ordering semantics
101+
- [advanced.md](./advanced.md) for retry, circuit, and operational patterns
102+
- [errorhandling.md](./errorhandling.md) for exact error behavior

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"homepage": "https://github.com/fetch-kit/ffetch#readme",
1818
"bugs": "https://github.com/fetch-kit/ffetch/issues",
19-
"author": "Your Name <you@example.com>",
19+
"author": "Gabor Koos <gabor@gaborkoos.com>",
2020
"license": "MIT",
2121
"main": "./dist/index.cjs",
2222
"module": "./dist/index.js",

0 commit comments

Comments
 (0)