A structured concurrency response to https://twitter.com/alexelcu/status/1710305127729438994
I am using Ox and JDK 21 in this gist.
First run:
docker run --name test-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
Then:
scala-cli run ox-jdbc.scala
Alternatively just run (if you're brave enough to run gists from intarwebz):
scala-cli run https://gist.github.com/lbialy/320b28dba6575cef3af8173e390abe54
One minor improvement: once you do
stmt.cancel()
in the extended version, it should be enough to let the scope close - any running forks will be interrupted (cancelled) anyway. Unless there is something very wrong with exception handling, then please report an issue :)