2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PR: JISOU | Reactプログラミングコーチング
AIで不安を感じたら!    JISOUメンバー募集中

クライアント側で冪等性担保されていることの確認

2
Posted at

はじめに

前回までタイムアウトしたときの冪等性担保をまとめましたが、今回はクライアント側での対応を載せます。

内容

クライアント側で冪等性担保されていることの確認対応ですが、単純な方法として、
エラーコードが23505のときにエラーメッセージを出力するようにします。

route
        if (error.code === "23505") {
            console.log("重複エラー: すでに同じIdempotency-Keyが存在します");
            return Response.json(
                { error: "重複エラー: すでに同じIdempotency-Keyが存在します" },
                { status: 409 }
            );
        }

重複エラー: すでに同じIdempotency-Keyが存在します

おわりに

場合によっては、Retry回数や同時に同じ処理が走った場合はどうするのかを考慮する必要があります。

参考文献

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?