forked from TrueCloudLab/frostfs-node
[#189] metabase: Implement DumpInfo method
Implement method to get the information about the metabase. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
eaa7068e3c
commit
24cf86e269
3 changed files with 19 additions and 10 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// DB represents local metabase of storage node.
|
||||
type DB struct {
|
||||
path string
|
||||
info Info
|
||||
|
||||
*cfg
|
||||
|
||||
|
@ -41,7 +41,9 @@ func NewDB(opts ...Option) *DB {
|
|||
}
|
||||
|
||||
return &DB{
|
||||
path: c.boltDB.Path(),
|
||||
info: Info{
|
||||
Path: c.boltDB.Path(),
|
||||
},
|
||||
cfg: c,
|
||||
matchers: map[object.SearchMatchType]func(string, string, string) bool{
|
||||
object.MatchUnknown: unknownMatcher,
|
||||
|
@ -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:
|
||||
|
|
|
@ -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) {
|
||||
|
|
12
pkg/local_object_storage/metabase/info.go
Normal file
12
pkg/local_object_storage/metabase/info.go
Normal 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
|
||||
}
|
Loading…
Reference in a new issue