func ReloadStorage(storageType int) error { switch storageType { default: return errors.New("Not supported type") case configuration.StorageTypeDefault: // If not indicated, use default storageTypeDefault, err := configuration.GetStorageTypeDefault() if err != nil { log.Error(err) return ReloadStorage(configuration.StorageTypeDummy) } else { return ReloadStorage(storageTypeDefault) } case configuration.StorageTypeDummy: newStorage := &StorageDummy{} err := newStorage.initialize() if err == nil { storage = newStorage } return err case configuration.StorageTypeCassandra: return errors.New("Not supported type") case configuration.StorageTypeEtcd: newStorage := &StorageEtcd{} err := newStorage.initialize() if err == nil { storage = newStorage } return err } }
func init() { storageTypeDefault, err := configuration.GetStorageTypeDefault() if err != nil { log.Critical("Unable to load the storage type so it can't decide to use this or not with error %s", err) panic(err) } if storageTypeDefault == configuration.StorageTypeEtcd { err := Reload() if err != nil { panic(err) } } }