metadb: split backends into packages, add metadb#151
Merged
tac0turtle merged 3 commits intomasterfrom Feb 11, 2021
Merged
Conversation
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.
Codecov Report
@@ Coverage Diff @@
## master #151 +/- ##
===========================================
- Coverage 68.78% 11.38% -57.41%
===========================================
Files 27 31 +4
Lines 1448 1309 -139
===========================================
- Hits 996 149 -847
- Misses 377 1127 +750
+ Partials 75 33 -42
|
melekes
approved these changes
Feb 11, 2021
Contributor
Author
|
So the tests pass here but not on master, will dig into it |
Contributor
|
I think this change should have tag v0.7.0 |
Contributor
Author
|
you are correct! ill see if the tag is still around |
creachadair
added a commit
that referenced
this pull request
Nov 8, 2021
This reverts commit 71bc5d8.
creachadair
pushed a commit
that referenced
this pull request
Nov 9, 2021
authored-by: Daniel Martí <mvdan@mvdan.cc>
creachadair
added a commit
that referenced
this pull request
Nov 9, 2021
This reverts commit 71bc5d8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Thank you @mvdan for the contribution.