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:
Derek McGowan
2017-10-03 15:48:05 -07:00
parent 2ab70f21ac
commit 8d892a651b
11 changed files with 84 additions and 95 deletions

View File

@@ -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))
})
}