``` [build] kill_delay = "1s" send_interrupt = true ``` ## Get Movie ```bash curl -i http://0.0.0.0:5002/v1/movies/1 ``` ## Creating a movie ```bash curl -i -X POST -d '{"title":"Passengers","year":2016,"runtime":"120 mins", "genres":["comedy","adventure"]}' http://0.0.0.0:5002/v1/movies ``` ```bash curl -i -X POST -d '{"title":"The Batman","year":2022,"runtime":"177 mins", "genres":["action","adventure"]}' http://0.0.0.0:5002/v1/movies ``` ```bash curl -i -X POST -d '{"title":"Death of a Unicorn","year":2025,"runtime":"126 mins", "genres":["comedy","satire"]}' http://0.0.0.0:5002/v1/movies ``` ```bash BODY='{"title":"Black Panther","year":2018,"runtime":"134 mins","genres":["sci-fi","action","adventure"]}' curl -X PUT -d "$BODY" http://0.0.0.0:5002/v1/movies/1 ``` ## Generating an Update Conflict We can try to use the xargs tool to submit multiple requests to our webserver. Hopefully this results in the 409 that we are looking to create. ```bash xargs -I % -P8 curl -X PATCH -d '{"runtime": "97 mins"}' "localhost:5002/v1/movies/4" < <(printf '%s\n' {1..8}) ``` ## Adding Time Taken To You Curl Request Use the `-w` to anotate the response `https://blog.josephscott.org/2011/10/14/timing-details-with-curl/` ```bash curl -w '\nTime: %{time_total}s \n' localhost:5002/v1/movies/4 { "movie": { "id": 4, "title": "The Batman", "year": 2021, "Runtime": "97 mins", "genres": [ "action", "adventure" ], "version": 5 } } Time: 8.009385s ``` ## Timeout a Curl Request We can timeout our curl request like so ```bash curl --max-time 2 localhost:5002/v1/movies/4 ``` ## Migrations Don't forget that the migrate tool can be used to create the stub of your index files. ```bash migrate create -seq -ext .sql -dir ./migrations add_movies_indexes ``` To run migrations from the cmdline you need to have the pgx5 installed ```bash go install -tags 'pgx5' github.com/golang-migrate/migrate/v4/cmd/migrate@latest ``` Then you need to specify a database uri ```bash migrate -dir ./migrations -database "pgx://pulley:pulley@localhost:5434/pulley" goto 2 ``` ## Postgres en.wikipedia.org/wiki/Stemming We are using the postgres simple type for full text search but we could use some of the more advanced options for this like english. This will perform stemming for us and resulting in common words like "a" or "the" from appearing in the lexemes it generates. Check out `\dF` for all the available configurations. See the docs for more about full text search. https://www.postgresql.org/docs/current/textsearch.html ### Other Resources - https://niallburkley.com/blog/index-columns-for-like-in-postgres/