Skip to content

Instantly share code, notes, and snippets.

@kaveenr
Created April 19, 2019 16:25
Show Gist options
  • Save kaveenr/c86f995e421afab035587aa936392f77 to your computer and use it in GitHub Desktop.
Save kaveenr/c86f995e421afab035587aa936392f77 to your computer and use it in GitHub Desktop.
participant User
participant Application
participant Network Gateway
participant Server
User->+Application: Make Payment for $20
# Request 1
note left of Application
Client sends
payment request
end note
Application->+Network Gateway:POST /payment[Idempotency-Key:1001]
Network Gateway->+Server:POST /payment[Idempotency-Key:1001]
note right of Server
REQUEST IS NON-IDEMPOTENT
Process Payment
Respond with Confirmation
end note
Server->-Network Gateway: 200 Payment Confirmation
note left of Network Gateway
Technical difficulty unable to respond
end note
Network Gateway->-Application: 502: Bad Gateway
note left of Application
Unable to get response
try again
end note
Application->Application:Retry Request
Application->+Network Gateway:POST /payment[Idempotency-Key:1001]
Network Gateway->+Server:POST /payment[Idempotency-Key:1001]
note right of Server
{Server has already seen
Idempotency-Key:1001}
REQUEST IS IDEMPOTENT
DO NOT process payment
Repond with payment confirmation
end note
Server->-Network Gateway: 200 Payment Confirmation
Network Gateway->-Application: 200 Payment Confirmation
Application->User: Payment Successful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment