func NewDBWrap(ldb *leveldb.DB) (db *DB, err error) {
	if ldb == nil {
		panic(errors.New("shed: NewDBWrap: nil ldb"))
	}
	db = &DB{
		ldb:     ldb,
		metrics: newMetrics(),
	}
	if _, err = db.getSchema(); err != nil {
		if errors.Is(err, leveldb.ErrNotFound) {
			if err = db.putSchema(schema{
				Fields:  make(map[string]fieldSpec),
				Indexes: make(map[byte]indexSpec),
			}); err != nil {
				return nil, err
			}
		} else {
			return nil, err
		}
	}
	db.quit = make(chan struct{})
	return db, nil
}
NewDBWrap returns new DB which uses the given ldb as its underlying storage.
The function will panics if the given ldb is nil.
package shed
import (
	"errors"
	"github.com/syndtr/goleveldb/leveldb"
	"github.com/syndtr/goleveldb/leveldb/iterator"
	"github.com/syndtr/goleveldb/leveldb/opt"
	"github.com/syndtr/goleveldb/leveldb/storage"
)
var (
	defaultOpenFilesLimit         = uint64(256)
	defaultBlockCacheCapacity     = uint64(32 * 1024 * 1024)
	defaultWriteBufferSize        = uint64(32 * 1024 * 1024)
	defaultDisableSeeksCompaction = false
)
type Options struct {
	BlockCacheCapacity     uint64
	WriteBufferSize        uint64
	OpenFilesLimit         uint64
	DisableSeeksCompaction bool
}
type DB struct {
	ldb     *leveldb.DB
	metrics metrics
	quit    chan struct{}  
}
func NewDB(path string, o *Options) (db *DB, err error) {
	if o == nil {
		o = &Options{
			OpenFilesLimit:         defaultOpenFilesLimit,
			BlockCacheCapacity:     defaultBlockCacheCapacity,
			WriteBufferSize:        defaultWriteBufferSize,
			DisableSeeksCompaction: defaultDisableSeeksCompaction,
		}
	}
	var ldb *leveldb.DB
	if path == "" {
		ldb, err = leveldb.Open(storage.NewMemStorage(), nil)
	} else {
		ldb, err = leveldb.OpenFile(path, &opt.Options{
			OpenFilesCacheCapacity: int(o.OpenFilesLimit),
			BlockCacheCapacity:     int(o.BlockCacheCapacity),
			WriteBuffer:            int(o.WriteBufferSize),
			DisableSeeksCompaction: o.DisableSeeksCompaction,
		})
	}
	if err != nil {
		return nil, err
	}
	return NewDBWrap(ldb)
}