github.com/cockroachdb/pebble@v1.1.2/objstorage/remote/factory.go (about) 1 // Copyright 2023 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 package remote 6 7 import "github.com/pkg/errors" 8 9 // MakeSimpleFactory returns a StorageFactory implementation that produces the given 10 // Storage objects. 11 func MakeSimpleFactory(m map[Locator]Storage) StorageFactory { 12 return simpleFactory(m) 13 } 14 15 type simpleFactory map[Locator]Storage 16 17 var _ StorageFactory = simpleFactory{} 18 19 // CreateStorage is part of the StorageFactory interface. 20 func (sf simpleFactory) CreateStorage(locator Locator) (Storage, error) { 21 if s, ok := sf[locator]; ok { 22 return s, nil 23 } 24 return nil, errors.Errorf("unknown locator '%s'", locator) 25 }