2026-09-23·by Sijie Wang#standmeet#architecture#design

idempotent-booking

幂等预订,只写重试

上级:connector

Calendar 的 events.insert 并非幂等:如果连接在 Google 已经创建好事件、但响应还没送达之前断开,盲目重试就会造成重复预订。因此幂等键在任何重试循环开始之前只生成一次,并在 401 刷新 + 重试的整个周期内复用;写入重试策略只重试发送前的传输错误,绝不重试 5xx(5xx 可能服务端已经成功执行了)——遇到这种情况就优雅地失败,而不是硬重试(connector/openapi_adapter.go —— newIdempotencyKey,每次 InsertEvent 调用生成一个;protocol_caldav.go 把同一个键复用为 VEVENT 的 UID;retrypolicy.gocalendarWritePolicy。旧的 connector/calendar.go 已于 2026-06-27 删除,bca9b1c69)。

相关:预订是一个只追加的配额账本(ephemeral-over-stateful);被撤销的 OAuth 授权是一次软断连(清空 token,保留 client id/secret,让所有者不需要重新走一遍设置流程就能重新授权)。

about this entry

One of sijie's wiki entries. The AI on this site is grounded in the same corpus and answers in sijie's voice, with citations back to entries like this one — answering costs sijie money, so it waits behind a code: enter an access code →

idempotent-booking