Selfishly, I'd love a documentation review if you (or anyone else) has the time to take a try out some golang projects I've been working on.
The code is frankly not very polished and not worth reviewing, but I'm curious to hear feedback on the documentation / README and whether or not you clearly understand what these libraries are for and how to use them.
If that's not polished code, then I'm really curious what you consider to be polished!
* It follows Go conventions, has helpful comments and readme file.
* Given it's not user facing prod code, I'm assuming high-performance isn't critical, and the nature of what it's doing means using `once.*` is worth the trade-off with concurrency.
* It also makes sense not to actual test against a database, given that's the whole point of this package.
* The code is well-structured, with "internal" code separated.
I don't think I'm good enough at Go to be able to provide any more useful feedback than that.*
Thank you! Just saw this — kind of you to take the time, and I appreciate the compliments.
> Given it's not user facing prod code, I'm assuming high-performance isn't critical, and the nature of what it's doing means using `once.*` is worth the trade-off with concurrency.
I'm impressed you noticed this. I don't do a good job of explaining this in code comments or docstrings, but the linearization / contention is necessary for correctness. Basically, each time someone asks for a new testdb, the code needs to make sure the relevant user exists, and the relevant template exists, and has the migrations run on it. If these things don't exist, the test will need to create them. With many tests running in parallel, they need some way to contend and make sure that the user/template is only created once.
Because golang runs the tests of separate packages as totally separate processes, the code does the contention with "advisory locks" inside the Postgres server. When two tests are contending on these advisory locks, they have to hold a connection open to the server. As a result, server speed and max simultaneous connections are the primary limiters of how many tests can be operating in parallel and how fast your test suite runs.
I added the `once.*` helpers to move the contention "left" where possible, to the memory of the packages that are being tested. Within a package, tests can (and should) also run in parallel. The `once.*` helpers force the different tests to contend in the shared process memory, the theory being that it's faster and that it reduces the number of server queries/connections held open just waiting around on a server-side lock.
I haven't actually tested the code with and without this, and thanks to your comment I will try to do this at some point!
* It follows Go conventions, has helpful comments and readme file.
* Given it's not user facing prod code, I'm assuming high-performance isn't critical, and the nature of what it's doing means using `once.*` is worth the trade-off with concurrency.
* It also makes sense not to actual test against a database, given that's the whole point of this package.
* The code is well-structured, with "internal" code separated.
I don't think I'm good enough at Go to be able to provide any more useful feedback than that.*