Refactor codeintel db package
Created by: efritz
The codeintel db package was doing something a bit contrary to Go idioms and the way other stores are currently implemented. Instead of defining a TxCloser and passing around a reference, stores use as Transact
method that will promote the entire store to work in the context of a transaction.
This is a big (lines of code) change, but very little behavior is actually different except for two callsites in the api-server and worker where transactions really matter. A lot of the changes are due to dropping support for queryRow and exec, so scanning results is a bit different now.
Overview of changes:
- Add Transact and Done methods to Database interface
- Ensure all non-trivial methods take a context
- Use dbutil.DB over sql.DB/Tx
- Regenerate mocks
- Update usage (including new txn technique)
Recommended review order:
- db.go
- tx.go
- one of the methods that no longer take a Tx parameter
- skim the remainder of the db package changes
- skip the tests
- skim over usage changes in cmd/