← 返回
未分类 中文

Idempotency

Deep idempotency workflow—identifying retry surfaces, idempotency keys, storage and TTL, exactly-once pitfalls, and testing duplicate delivery. Use when desi...
深度幂等工作流——识别重试面、幂等键、存储与TTL、仅一次陷阱及重复投递测试。适用于追求健壮分布式系统的场景。
codenova58 codenova58 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 366
下载
💾 0
安装
1
版本
#latest

概述

Idempotency (Deep Workflow)

Most distributed systems deliver work at least once. Idempotency makes duplicate processing safe—critical for payments, inventory, and message consumers.

When to Offer This Workflow

Trigger conditions:

  • Retries on HTTP, queues, or background jobs
  • Double charges, duplicate records, or “at-least-once” confusion
  • Product asks for “exactly-once” semantics

Initial offer:

Use six stages: (1) identify side effects, (2) choose keys, (3) storage & scope, (4) API patterns, (5) worker patterns, (6) testing). Confirm storage (Redis, SQL) and retention window.


Stage 1: Identify Side Effects

Goal: Classify operations: reads vs creates vs monetary transfers vs state transitions.

Exit condition: List of mutations that must be idempotent under retries.


Stage 2: Choose Keys

Goal: Client-supplied Idempotency-Key header (Stripe-style) vs deterministic hash of normalized payload—trade UX vs collision risk.


Stage 3: Storage & Scope

Goal: Store key → outcome or result reference with TTL covering retry window; scope keys per tenant/user when needed.


Stage 4: API Patterns

Goal: Same key + same body → same outcome; reject or conflict if same key with different body.


Stage 5: Worker Patterns

Goal: Natural unique constraints in DB; dedupe table keyed by event_id or business idempotency key for consumers.


Stage 6: Testing

Goal: Chaos or integration tests that deliver duplicate messages; property tests for key behavior.


Final Review Checklist

  • [ ] Mutating paths classified
  • [ ] Key strategy and scope documented
  • [ ] Storage, TTL, conflict rules defined
  • [ ] HTTP and async consumers aligned
  • [ ] Duplicate delivery tests

Tips for Effective Guidance

  • True exactly-once end-to-end is rare—design for at-least-once + idempotent effects.
  • Pair with message-queues and rest-best-practices for HTTP idempotency keys.

Handling Deviations

  • Financial flows: require stronger audit and longer key retention.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-31 09:43 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 42,184
professional

Eastmoney

codenova58
访问并总结来自东方财富的公开市场数据、新闻和行业趋势,不包括交易或批量数据提取。
★ 1 📥 6,130
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 198 📥 68,330