| 12345678910111213141516171819202122232425262728293031 |
- package storage
- import (
- "fmt"
- dbStorage "dbview/service/internal/common/manager/storage/db_storage"
- )
- // StorageType 存储类型
- type StorageType string
- const (
- FileStorage StorageType = "file"
- DBStorage StorageType = "db"
- )
- // NewDBStorage 创建数据库存储管理器
- func NewDBStorage(dbPath string) (StorageInterface, error) {
- return dbStorage.NewStorageManager(dbPath)
- }
- // GetStorage 根据类型创建存储管理器
- func GetStorage(storageType StorageType, configPath, dbPath string) (StorageInterface, error) {
- switch storageType {
- case DBStorage:
- return dbStorage.NewStorageManager(dbPath)
- default:
- return nil, fmt.Errorf("不支持的存储类型: %s", storageType)
- }
- }
|