-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: split backends into packages, add metadb #149
Conversation
Alright, here's v1 of the huge refactor. One test is still being picky, I'll figure that out tomorrow. Otherwise this should all work - thoughts welcome. It should go without saying that this is a big breaking change, but updating the users shouldn't be too hard. It should really be just replacing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ great work @mvdan
return buf | ||
} | ||
|
||
func Bytes2Int64(buf []byte) int64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godoc is missing
Looks like some tests are failing:
|
Yeah, I realise some godocs are missing and the tests aren't passing - I was hoping to get an early review before I spend more time polishing it. The overall refactor sounds good, then? I don't think it's worth adding godocs to the internal test funcs, though. They didn't have it before, and they are still internal test APIs. |
Does it make sense to remove the name of the db from the file name? It's already in the respective folder. Badgerdb/badger_db.go could be badgerdb/db.go. |
Or it can be just |
yep |
I actually named the packages I agree with reducing repetition with filenames, though. I thought about doing the same with types, renaming |
The old structure was a single huge package with all the DB backends in it. Since tm-db users often want just one or two DB backends, and building plus linking all of them is very heavy, build tags were used to opt into some of the backends. This same mechanism is now in metadb, for those who want it; it allows opting into DB backends via build tags, without having to edit the code directly. Note that the old package included the memdb and goleveldb backends by default. The new metadb does not include any by default, to make backends explicit and more consistent. This required using more build tags in CI. Most users will want to statically use one DB implementation, without metadb. Each separate sub-package does just that. They are direct moves of the old code; the only major change is that constructors like db.NewBadgerDB are now called badger.NewDB, to avoid the repetition of badger.NewBadgerDB. The root package error types are also exported now, to allow being used by all separate packages. Note that this means they're now part of the public API too; this should be fine. Some test code also had to be shuffled around. All the tests which dealt with backends were moved to metadb. The shared test helper code had to be moved to an internal package, to remain reachable. Finally, note that we consistently use "tmdb" as the imported package name for the root package, since "db" is often used as a variable name. This prevents confusion and common build errors. Fixes #113.
Alright, all tests should pass now. I've also updated CI and the makefile with the new memdb and goleveldb build tags. |
I'm not sure what to do about the CI failures. The test failures are |
It seems to error within the docker image. I was able to reproduce the issue with this command
|
I see. I can't fix that as I don't own the image. Maybe I should revert the CI changes and let one of you do that after this PR is merged. Or feel free to push follow-up commits on this same PR if you want to fix it here. |
The docker file is located in I would have to do some testing, I'm unsure why its failing. |
It's odd that I need to download rocksdb to run the linter. |
this PR fixes it: #151 not sure how linting fixed the tests. |
(see commit message, which is updated with pushes)