github.com/GuanceCloud/cliutils@v1.1.21/pprofparser/service/storage/storage.go (about) 1 package storage 2 3 import ( 4 "fmt" 5 "io" 6 ) 7 8 type Type string 9 10 const ( 11 AliOSS Type = "oss" 12 LocalDisk Type = "disk" 13 ) 14 15 var DefaultDiskStorage = &Disk{} 16 17 type Storage interface { 18 IsFileExists(path string) (bool, error) 19 GetProfilePath(workspaceUUID string, profileID string, unixTimeNS int64, ossFilename string) string 20 GetProfileDir(workspaceUUID string, profileID string, unixTimeNS int64) string 21 GetProfilePathOld(workspaceUUID string, profileID string, unixTimeNS int64, ossFilename string) string 22 ReadFile(path string) (io.ReadCloser, error) 23 } 24 25 func GetStorage(typ Type) (Storage, error) { 26 switch typ { 27 case AliOSS: 28 return InitOSS() 29 case LocalDisk: 30 return DefaultDiskStorage, nil 31 } 32 return nil, fmt.Errorf("storage type [%s] not supported yet", typ) 33 }