Documentation
¶
Index ¶
- func AppConfigCacheKey(app string) string
- type AppConfig
- func (r AppConfig) CreateAppConfig(ctx core.Context, ent *entity.AppConfig) (uint32, error)
- func (r AppConfig) GetAppConfig(ctx core.Context, app string) (*entity.AppConfig, error)
- func (r AppConfig) ListAppConfig(ctx core.Context, req *types.ListAppConfigRequest) ([]*entity.AppConfig, uint32, error)
- func (r AppConfig) RecalcUsage(ctx core.Context, app string) (uint64, error)
- func (r AppConfig) ReleaseQuota(ctx core.Context, app string, size uint64) error
- func (r AppConfig) ReserveQuota(ctx core.Context, app string, size uint64) (bool, error)
- func (r AppConfig) UpdateAppConfig(ctx core.Context, ent *entity.AppConfig) error
- type Directory
- func (r Directory) CreateDirectoryIgnore(ctx core.Context, ent *entity.Directory) (*entity.Directory, error)
- func (r Directory) DeleteDirectoryTree(ctx core.Context, app string, id uint32, path string) error
- func (r Directory) GetDirectory(ctx core.Context, app string, id uint32) (*entity.Directory, error)
- func (r Directory) GetDirectoryById(ctx core.Context, id uint32) (*entity.Directory, error)
- func (r Directory) GetDirectoryByPath(ctx core.Context, app, path string) (*entity.Directory, error)
- func (r Directory) ListDirectory(ctx core.Context, app string) ([]*entity.Directory, error)
- func (r Directory) ListDirectoryInPaths(ctx core.Context, app string, paths []string) ([]*entity.Directory, error)
- func (r Directory) MoveDirectory(ctx core.Context, p *types.MoveDirectoryParams) error
- func (r Directory) UpdateDirectory(ctx core.Context, ent *entity.Directory) error
- type File
- func (r File) CreateFile(ctx core.Context, ent *entity.File) (uint32, error)
- func (r File) DeleteFile(ctx core.Context, id uint32) error
- func (r File) DeleteFilesByStatus(ctx core.Context, status uint8, limit int) (int64, error)
- func (r File) GetFile(ctx core.Context, id uint32) (*entity.File, error)
- func (r File) GetFileByUploadId(ctx core.Context, uploadID string) (*entity.File, error)
- func (r File) ListFileByDirectory(ctx core.Context, app string, directoryID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)
- func (r File) ListFileByUser(ctx core.Context, app string, userID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)
- func (r File) MarkDeleteInSubtree(ctx core.Context, app string, id uint32, path string) (int64, error)
- func (r File) UpdateFile(ctx core.Context, ent *entity.File) error
- type Object
- func (r Object) CreateObject(ctx core.Context, ent *entity.Object) (*entity.Object, error)
- func (r Object) DeleteObject(ctx core.Context, id uint32) error
- func (r Object) DeleteObjectIfUnreferenced(ctx core.Context, objectID uint32) (bool, error)
- func (r Object) ExistsObject(ctx core.Context, storeKeyword, md5 string) (bool, error)
- func (r Object) GetObject(ctx core.Context, id uint32) (*entity.Object, error)
- func (r Object) GetObjectByMd5(ctx core.Context, storeKeyword, md5 string) (*entity.Object, error)
- func (r Object) GetObjectByMd5Any(ctx core.Context, md5 string) (*entity.Object, error)
- func (r Object) IsReferenced(ctx core.Context, objectID uint32) (bool, error)
- func (r Object) ListObjectByIDs(ctx core.Context, ids []uint32) ([]*entity.Object, error)
- func (r Object) ScanUnreferenced(ctx core.Context, afterID uint32, limit int) ([]*entity.Object, error)
- type Store
- func (r Store) CreateStore(ctx core.Context, ent *entity.Store) (uint32, error)
- func (r Store) GetClient(keyword string) (repository.Client, bool)
- func (r Store) GetStore(ctx core.Context, id uint32) (*entity.Store, error)
- func (r Store) GetStoreByKeyword(ctx core.Context, keyword string) (*entity.Store, error)
- func (r Store) ListClients() []repository.Client
- func (r Store) ListStore(ctx core.Context, req *types.ListStoreRequest) ([]*entity.Store, uint32, error)
- func (r Store) UpdateStore(ctx core.Context, ent *entity.Store) error
- type Upload
- func (r Upload) CreateUpload(ctx core.Context, ent *entity.Upload) (uint32, error)
- func (r Upload) DeleteUpload(ctx core.Context, id uint32) error
- func (r Upload) GetUpload(ctx core.Context, uploadID string, userID uint32) (*entity.Upload, error)
- func (r Upload) GetUploadByKey(ctx core.Context, key *types.UploadKey) (*entity.Upload, error)
- func (r Upload) ListExpiredUpload(ctx core.Context, before int64, limit int) ([]*entity.Upload, error)
- func (r Upload) TouchUpload(ctx core.Context, id uint32) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppConfigCacheKey ¶ added in v1.2.4
AppConfigCacheKey 返回某 app 的配置缓存键(正/负缓存共用)
Types ¶
type AppConfig ¶ added in v1.2.4
type AppConfig struct{}
AppConfig 应用配置仓储实现(Redis 缓存 + 延迟双删)
func (AppConfig) CreateAppConfig ¶ added in v1.2.4
CreateAppConfig 创建应用配置。
func (AppConfig) GetAppConfig ¶ added in v1.2.4
GetAppConfig 读配置:Redis 优先;miss 时抢重建锁回源并回填。
func (AppConfig) ListAppConfig ¶ added in v1.2.4
func (r AppConfig) ListAppConfig(ctx core.Context, req *types.ListAppConfigRequest) ([]*entity.AppConfig, uint32, error)
ListAppConfig 分页查询应用配置
func (AppConfig) RecalcUsage ¶ added in v1.2.4
RecalcUsage 按逻辑口径重算 used_bytes(Σ 该 app 每个 file 行引用 object 的 size),失效缓存后回查。
func (AppConfig) ReleaseQuota ¶ added in v1.2.4
ReleaseQuota 归还配额:used_bytes -= size,IF 夹 0 防无符号下溢。
func (AppConfig) ReserveQuota ¶ added in v1.2.4
ReserveQuota 原子占用配额:单条 CAS 既校验又自增(防并发绕过)。rowsAffected==1 即占用成功。
type Directory ¶
type Directory struct{}
Directory 目录仓储实现(物化路径)
func (Directory) CreateDirectoryIgnore ¶ added in v1.2.4
func (r Directory) CreateDirectoryIgnore(ctx core.Context, ent *entity.Directory) (*entity.Directory, error)
CreateDirectoryIgnore 幂等新建,返回最终行。
func (Directory) DeleteDirectoryTree ¶ added in v1.2.4
DeleteDirectoryTree 删子树:一条语句删掉自己与全部后代
func (Directory) GetDirectory ¶
GetDirectory 按主键查询目录(必须带 app 限定)
func (Directory) GetDirectoryById ¶ added in v1.2.4
GetDirectoryById 按主键查询目录(不限定 app,用于从目录派生 app 等读场景)
func (Directory) GetDirectoryByPath ¶ added in v1.2.4
func (r Directory) GetDirectoryByPath(ctx core.Context, app, path string) (*entity.Directory, error)
GetDirectoryByPath 按路径查询目录
func (Directory) ListDirectory ¶
ListDirectory 全量取回某 app 的目录
func (Directory) ListDirectoryInPaths ¶ added in v1.2.4
func (r Directory) ListDirectoryInPaths(ctx core.Context, app string, paths []string) ([]*entity.Directory, error)
ListDirectoryInPaths 按路径集合批量查询
func (Directory) MoveDirectory ¶ added in v1.2.4
MoveDirectory 移动子树:一条 UPDATE 重写整棵子树 path,并把 updated_at/updated_by 刷到本次操作。
type File ¶
type File struct{}
File 业务文件条目仓储实现
func (File) CreateFile ¶
CreateFile 新建文件
func (File) DeleteFile ¶
DeleteFile 删除文件行
func (File) DeleteFilesByStatus ¶ added in v1.2.4
DeleteFilesByStatus 后台回收:按状态分批硬删 file 行(ORDER BY id LIMIT limit),返回删除行数。
func (File) GetFileByUploadId ¶
GetFileByUploadId 按 upload_id 查文件(幂等收口 / 召回复用)。
func (File) ListFileByDirectory ¶ added in v1.2.4
func (r File) ListFileByDirectory(ctx core.Context, app string, directoryID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)
ListFileByDirectory 目录内分页(仅 status=1,走 idx_file_app_directory)。
func (File) ListFileByUser ¶ added in v1.2.4
func (r File) ListFileByUser(ctx core.Context, app string, userID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)
ListFileByUser "我的文件"分页(仅 status=1,走 idx_file_app_user)。
type Object ¶ added in v1.2.4
type Object struct{}
Object 物理对象(内容寻址)仓储实现
func (Object) CreateObject ¶ added in v1.2.4
CreateObject 幂等新建;撞 uidx_object_store_md5 时重查复用赢家,返回最终行。
func (Object) DeleteObject ¶ added in v1.2.4
DeleteObject 删除对象行(桶对象由调用方另行处理)。
func (Object) DeleteObjectIfUnreferenced ¶ added in v1.2.4
DeleteObjectIfUnreferenced 零引用才删行;返回 true 表示已删除。
func (Object) ExistsObject ¶ added in v1.2.4
ExistsObject 存在性判断(按 store_keyword + md5)。
func (Object) GetObjectByMd5 ¶ added in v1.2.4
GetObjectByMd5 按 (store_keyword, md5) 查对象;查不到即 gorm.ErrRecordNotFound。
func (Object) GetObjectByMd5Any ¶ added in v1.2.4
GetObjectByMd5Any 按 md5 全局查对象(不限定存储,取最早入库一条;内容寻址,同 md5 内容一致)。
func (Object) IsReferenced ¶ added in v1.2.4
IsReferenced 引用判定:file 表是否仍存在指向该对象的行。
func (Object) ListObjectByIDs ¶ added in v1.2.4
ListObjectByIDs 主键批量查对象(列表出 URL 用,不入逐行点查)。
type Store ¶ added in v1.2.4
type Store struct {
// contains filtered or unexported fields
}
Store 存储后端仓储实现(store 行走 pkg/cache:内存读 + Redis 跨节点同步)。
func NewStore ¶ added in v1.2.4
func NewStore() *Store
NewStore 取存储后端仓储单例(首次调用注册 BeforeStart 钩子,启动前全量灌入 store 缓存)。
func (Store) CreateStore ¶ added in v1.2.4
CreateStore 新建存储后端(DB 写入与缓存 Put 同事务)。
func (Store) GetClient ¶ added in v1.2.4
func (r Store) GetClient(keyword string) (repository.Client, bool)
GetClient 取厂商客户端(缓存读行→按行指针记忆化构造,读路径零网络跳)。
func (Store) GetStoreByKeyword ¶ added in v1.2.4
GetStoreByKeyword 按 keyword 取存储后端(含 status,用于启用态判定)
func (Store) ListClients ¶ added in v1.2.4
func (r Store) ListClients() []repository.Client
ListClients 取全部客户端(GC / 离线核对遍历用)。
type Upload ¶ added in v1.2.4
type Upload struct{}
Upload 分片上传会话仓储实现
func (Upload) CreateUpload ¶ added in v1.2.4
CreateUpload 建会话
func (Upload) DeleteUpload ¶ added in v1.2.4
DeleteUpload 删会话
func (Upload) GetUploadByKey ¶ added in v1.2.4
GetUploadByKey 按会话身份 (store_keyword, md5, user_id, directory_id) 召回在飞会话。