storage: remove current registration process for new storages

This commit is contained in:
Eric Chiang 2016-08-02 20:00:35 -07:00
parent c7af2c4885
commit e716c14718
2 changed files with 0 additions and 44 deletions

View file

@ -8,10 +8,6 @@ import (
"github.com/coreos/poke/storage"
)
func init() {
storage.Register("memory", new(driver))
}
// New returns an in memory storage.
func New() storage.Storage {
return &memStorage{
@ -22,15 +18,6 @@ func New() storage.Storage {
}
}
type driver struct{}
func (f *driver) Open(config map[string]string) (storage.Storage, error) {
if len(config) != 0 {
return nil, errors.New("in memory storage does not take any arguments")
}
return New(), nil
}
type memStorage struct {
mu sync.Mutex

View file

@ -16,8 +16,6 @@ import (
)
var (
drivers = make(map[string]Driver)
// stubbed out for testing
now = time.Now
)
@ -40,35 +38,6 @@ func NewNonce() string {
return strings.TrimRight(encoding.EncodeToString(buff), "=")
}
// Driver is the interface implemented by storage drivers.
type Driver interface {
// Open returns a storage implementation. It should only validate its
// arguments and not return an error if the underlying storage is
// unavailable.
Open(config map[string]string) (Storage, error)
}
// Register makes a storage driver available by the provided name. If Register
// is called twice with the same name or if driver is nil, it panics.
func Register(name string, driver Driver) {
if driver == nil {
panic("driver cannot be nil")
}
if _, ok := drivers[name]; ok {
panic("driver " + name + " is already registered")
}
drivers[name] = driver
}
// Open returns a new storage object with a given key rotation strategy.
func Open(driverName string, config map[string]string) (Storage, error) {
driver, ok := drivers[driverName]
if !ok {
return nil, fmt.Errorf("no driver of type %s found", driverName)
}
return driver.Open(config)
}
// Storage is the storage interface used by the server. Implementations, at minimum
// require compare-and-swap atomic actions.
//