Adding concurrency control in our updateMovieHandler and documenting it.
All checks were successful
Deploy Greenlight API / deploy (push) Successful in 57s

This commit is contained in:
Maxime Delporte
2025-11-08 10:41:44 +01:00
parent b76496e096
commit f8f78c3eec
5 changed files with 36 additions and 4 deletions

View File

@@ -44,6 +44,14 @@ There are two comon approaches to doing this :
From an HTTP semantics point of view, using headers to convey the API version is the 'purer' approach. But from a user-experience point of view, using a URL prefix is arguably better. It makes it possible for developers to see which version of the API is being used at a glance, and it also means that the API can still be explored using a regular web browser (which is harder if custom headers are required).
## Concurrent request to test data race
In our 'updateMovieHandler' we prevent data race. To test if everything is going as we want, we can try multiple request at the same time with this command :
```bash
xargs -I % -P8 curl -X PATCH -d '{"runtime": "97 mins"}' "localhost:4000/v1/movies/4" < <(printf '%s\n' {1..8})
```
## SQL Migrations
The first thing we need to do is generate a pair of _migration files_ using the **migrate create** command :