Optimistic Concurrency in an HTTP API with ETags & Hypermedia

Optimistic Concurrency in an HTTP API with ETags & Hypermedia

How do you implement optimistic concurrency in an HTTP API? There are a couple of different ways, regardless of what datastore you're using in the backend. You can leverage the ETag header in the HTTP Response to return a "version" of the resource that was accessed. When a client then needs to perform some operation on the resource, they send an If-Match header apart of the request with the value being the result of ETag from the initial GET request. Another option is to leverage hypermedia by returning URIs for actions relevant to a resource that include the version apart of the URI. This enables concurrency to be completely transparent and does not require any knowledge from the client.

🔗 EventStoreDB
https://eventsto.re/codeopinion

🔔 Subscribe: https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw?sub_confirmation=1

💥 Join this channel to get access to source code & demos!
https://www.youtube.com/channel/UC3RKA4vunFAfrfxiJhPEplw/join

🔥 Don't have the JOIN button? Support me on Patreon!
https://www.patreon.com/codeopinion

📝 Blog: https://codeopinion.com
👋 Twitter: https://twitter.com/codeopinion
✨ LinkedIn: https://www.linkedin.com/in/dcomartin/

Node & Express Example by Oskar Dudycz
https://event-driven.io/pl/how_to_use_etag_header_for_optimistic_concurrency/

0:00 Intro
0:33 Optimistic Concurrency
2:45 Cosmos Document Store Example
5:40 EventStore Event Stream Example
8:58 Hypermedia

#softwarearchitecture #softwaredesign #httpapi

Optimistic Concurrencysoftware architecturesoftware design

Post a Comment

0 Comments