Documentation
¶
Index ¶
- type NFSConfig
- type Runtime
- type RuntimePersister
- type S3Config
- type Service
- func (s *Service) GetStorageInfo(ctx context.Context) (*StorageInfo, error)
- func (s *Service) SetPersister(p RuntimePersister)
- func (s *Service) SetRuntime(rt Runtime)
- func (s *Service) SwitchStorage(ctx context.Context, storageType string) error
- func (s *Service) TestStorageConnection(ctx context.Context, storageType string) error
- func (s *Service) UpdateStorageConfig(ctx context.Context, req *UpdateConfigRequest) error
- type StorageConfig
- type StorageDetail
- type StorageInfo
- type UpdateConfigRequest
- type WebDAVConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NFSConfig ¶
type NFSConfig struct {
Server string `json:"server"`
Path string `json:"path"`
MountPoint string `json:"mount_point"`
Version string `json:"version"`
Options string `json:"options"`
Timeout int32 `json:"timeout"`
AutoMount int32 `json:"auto_mount"`
RetryCount int32 `json:"retry_count"`
SubPath string `json:"sub_path"`
}
type Runtime ¶
type Runtime interface {
Reload(cfg *corestorage.StorageConfig) error
EffectiveType() corestorage.StorageType
}
Runtime 存储运行时接口(bootstrap 注入单例 *storage.StorageService)。
type RuntimePersister ¶
type RuntimePersister interface {
LoadRuntimeStorage(ctx context.Context) *conf.StorageConfig
SaveRuntimeStorage(ctx context.Context, cfg *conf.StorageConfig) error
}
RuntimePersister 运行时存储配置持久化(admin 域实现,bootstrap 装配; 存储域不直接碰 system_configs,保持域间零耦合)。
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 存储服务
func (*Service) GetStorageInfo ¶
func (s *Service) GetStorageInfo(ctx context.Context) (*StorageInfo, error)
GetStorageInfo 获取存储信息
func (*Service) SetPersister ¶
func (s *Service) SetPersister(p RuntimePersister)
SetPersister 注入持久化(在线切换写穿 DB,重启不丢)
func (*Service) SwitchStorage ¶
SwitchStorage 切换存储类型:校验 → 认证级 Probe → 热重载(新写入立即走新后端) → 更新全局配置 → 持久化到 system_configs(重启不丢)。
func (*Service) TestStorageConnection ¶
TestStorageConnection 测试存储连接。 local:路径存在可写;s3/webdav:端点 URL 校验(scheme 白名单 + 私网策略) 后做真实 HTTP 探测(不要求认证通过,能建立连接即可)。
func (*Service) UpdateStorageConfig ¶
func (s *Service) UpdateStorageConfig(ctx context.Context, req *UpdateConfigRequest) error
UpdateStorageConfig 更新存储配置。 流程与 SwitchStorage 一致:SSRF 校验 → 认证级 Probe → 热重载 → 更新内存 → 持久化到 system_configs(管理端配置记录,重启后由 bootstrap 恢复)。 注:use_ssl/path_style 未随请求传入时保留现值(use_ssl 缺省 true,与管理端历史行为一致)。
type StorageConfig ¶
type StorageConfig struct {
Type string `json:"type"`
StoragePath string `json:"storage_path"`
WebDAV *WebDAVConfig `json:"webdav,omitempty"`
S3 *S3Config `json:"s3,omitempty"`
NFS *NFSConfig `json:"nfs,omitempty"`
}
type StorageDetail ¶
type StorageInfo ¶
type StorageInfo struct {
Current string `json:"current"`
Effective string `json:"effective"` // 实际生效后端(降级时与 current 不同)
Available []string `json:"available"`
StorageDetails map[string]*StorageDetail `json:"storage_details"`
StorageConfig *StorageConfig `json:"storage_config"`
}
type UpdateConfigRequest ¶
type UpdateConfigRequest struct {
Type string `json:"type"`
Config struct {
StoragePath string `json:"storage_path"`
WebDAV *WebDAVConfig `json:"webdav"`
S3 *S3Config `json:"s3"`
NFS *NFSConfig `json:"nfs"`
} `json:"config"`
// 扁平形态(新):内嵌 conf.StorageConfig,JSON 字段同名绑定
conf.StorageConfig
}
UpdateConfigRequest 更新配置请求 UpdateConfigRequest 存储配置更新请求。 新形态(扁平):直接给 conf.StorageConfig 同构 JSON(type/storage_path/quota/ s3/webdav/ftp/sftp/azureblob/hdfs/onedrive/oss..obs),后端整体校验+Probe+切换; 旧嵌套形态 {type, config:{storage_path/webdav/s3}} 仍兼容(走既有局部更新逻辑)。