Update metadata plugin initialization
Updates metadata plugin to require content and snapshotter plugins be loaded and initializes with those plugins, keeping the metadata database structure static after initialization. Service plugins now only require metadata plugin access snapshotter or content stores through metadata, which was already required behavior of the services. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -19,26 +19,17 @@ import (
|
||||
type snapshotter struct {
|
||||
snapshot.Snapshotter
|
||||
name string
|
||||
db *DB
|
||||
db transactor
|
||||
}
|
||||
|
||||
// NewSnapshotter returns a new Snapshotter which namespaces the given snapshot
|
||||
// using the provided name and metadata store.
|
||||
func NewSnapshotter(db *DB, name string, sn snapshot.Snapshotter) snapshot.Snapshotter {
|
||||
db.storeL.Lock()
|
||||
defer db.storeL.Unlock()
|
||||
|
||||
ss, ok := db.ss[name]
|
||||
if !ok {
|
||||
ss = &snapshotter{
|
||||
Snapshotter: sn,
|
||||
name: name,
|
||||
db: db,
|
||||
}
|
||||
db.ss[name] = ss
|
||||
// newSnapshotter returns a new Snapshotter which namespaces the given snapshot
|
||||
// using the provided name and database.
|
||||
func newSnapshotter(db transactor, name string, sn snapshot.Snapshotter) snapshot.Snapshotter {
|
||||
return &snapshotter{
|
||||
Snapshotter: sn,
|
||||
name: name,
|
||||
db: db,
|
||||
}
|
||||
|
||||
return ss
|
||||
}
|
||||
|
||||
func createKey(id uint64, namespace, key string) string {
|
||||
@@ -466,11 +457,7 @@ func (s *snapshotter) Remove(ctx context.Context, key string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := bkt.DeleteBucket([]byte(key)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return bkt.DeleteBucket([]byte(key))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user