func New(path string, opts ...Option) (*BoltBackend, error) {
	path, err := filepath.Abs(path)
	if err != nil {
		return nil, trace.Wrap(err, "failed to convert path")
	}
	dir := filepath.Dir(path)
	s, err := os.Stat(dir)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if !s.IsDir() {
		return nil, trace.BadParameter("path '%v' should be a valid directory", dir)
	}
	b := &BoltBackend{
		locks: make(map[string]time.Time),
	}
	for _, option := range opts {
		if err := option(b); err != nil {
			return nil, trace.Wrap(err)
		}
	}
	if b.clock == nil {
		b.clock = &timetools.RealTime{}
	}
	db, err := bolt.Open(path, 0600, &bolt.Options{Timeout: 5 * time.Second})
	if err != nil {
		if err == bolt.ErrTimeout {
			return nil, trace.Errorf("Local storage is locked. Another instance is running? (%v)", path)
		}
		return nil, trace.Wrap(err)
	}
	b.db = db
	return b, nil
}
// New returns a new isntance of bolt backend
New returns a new isntance of bolt backend
// New returns a new isntance of bolt backend
func New(path string, opts ...Option) (*BoltBackend, error) {
	path, err := filepath.Abs(path)
	if err != nil {
		return nil, trace.Wrap(err, "failed to convert path")
	}
	dir := filepath.Dir(path)
	s, err := os.Stat(dir)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if !s.IsDir() {
		return nil, trace.BadParameter("path '%v' should be a valid directory", dir)
	}
	b := &BoltBackend{
		locks: make(map[string]time.Time),
	}
	for _, option := range opts {
		if err := option(b); err != nil {
			return nil, trace.Wrap(err)
		}
	}
	if b.clock == nil {
		b.clock = &timetools.RealTime{}
	}
	db, err := bolt.Open(path, 0600, &bolt.Options{Timeout: 5 * time.Second})
	if err != nil {
		if err == bolt.ErrTimeout {
			return nil, trace.Errorf("Local storage is locked. Another instance is running? (%v)", path)
		}
		return nil, trace.Wrap(err)
	}
	b.db = db
	return b, nil
}
func New ( path string , opts ... Option ) ( * BoltBackend , error ) { path , err := filepath . Abs ( path ) if err != nil { return nil , trace . Wrap ( err , " " ) } dir := filepath . Dir ( path ) s , err := os . Stat ( dir ) if err != nil { return nil , trace . Wrap ( err ) } if ! s . IsDir ( ) { return nil , trace . BadParameter ( " " , dir ) } b := & BoltBackend { locks : make ( map [ string ] time . Time ) , } for _ , option := range opts { if err := option ( b ) ; err != nil { return nil , trace . Wrap ( err ) } } if b . clock == nil { b . clock = & timetools . RealTime { } } db , err := bolt . Open ( path , 0600 , & bolt . Options { Timeout : 5 * time . Second } ) if err != nil { if err == bolt . ErrTimeout { return nil , trace . Errorf ( " " , path ) } return nil , trace . Wrap ( err ) } b . db = db return b , nil }
New returns a new isntance of bolt backend
New returns a new isntance of bolt backend