or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
議程8 - Use API Gateway and Go service to achieve HTTP idempotencier - Gaston Chiu
tags:
GopherDay2024
Agenda
Slido 連結
[投影片連結]
key question: 解決 server/client behavior 不一致導致重複操作
案例:
client 請求下單扣款,server 已經完成扣款,responce 時封包丟失等等,導致 client 認為 request failed,嘗試重送,導致重複扣款。
解決方法:
透故前後端約定好的 unique key 作為交易 idempotencier,當 server 收到同樣的 idempotencier 且 payload hash 相同,直接回 success(2xx)。
POST 比較需要 idenpotency key,GET, PUT, DELETE 不需要因為可以多執行幾次
實作上參考 RFC
如果 body/header hash 跟上一次同一個 idempotency key 對應的 body/header hash 不同,就回 422 Unprocessable
Solution
不同 microservice 的統一
Idempotency service
Lock Storage
最終決定是採用 Redis replication,且可能會 migrate 到 MemoryDB for Redis