[#189] metabase: Implement DumpInfo method

Implement method to get the information about the metabase.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2020-11-19 16:53:22 +03:00 committed by Alex Vanin
parent eaa7068e3c
commit 24cf86e269
3 changed files with 19 additions and 10 deletions

View File

@ -10,7 +10,7 @@ import (
// DB represents local metabase of storage node.
type DB struct {
path string
info Info
*cfg
@ -41,8 +41,10 @@ func NewDB(opts ...Option) *DB {
}
return &DB{
path: c.boltDB.Path(),
cfg: c,
info: Info{
Path: c.boltDB.Path(),
},
cfg: c,
matchers: map[object.SearchMatchType]func(string, string, string) bool{
object.MatchUnknown: unknownMatcher,
object.MatchStringEqual: stringEqualMatcher,
@ -54,11 +56,6 @@ func (db *DB) Close() error {
return db.boltDB.Close()
}
// Path returns the path to meta database.
func (db *DB) Path() string {
return db.path
}
func stringEqualMatcher(key, objVal, filterVal string) bool {
switch key {
default:

View File

@ -186,7 +186,7 @@ func TestDB_Path(t *testing.T) {
defer releaseDB(db)
require.Equal(t, path, db.Path())
require.Equal(t, path, db.DumpInfo().Path)
}
func newDB(t testing.TB) *DB {
@ -200,7 +200,7 @@ func newDB(t testing.TB) *DB {
func releaseDB(db *DB) {
db.Close()
os.Remove(db.Path())
os.Remove(db.DumpInfo().Path)
}
func TestSelectNonExistentAttributes(t *testing.T) {

View File

@ -0,0 +1,12 @@
package meta
// Info groups the information about DB.
type Info struct {
// Full path to the metabase.
Path string
}
// DumpInfo returns information about the DB.
func (db *DB) DumpInfo() Info {
return db.info
}