Example #1
0
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
	}
}
Example #2
0
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)
		}
	}
}