优化结构
This commit is contained in:
@@ -50,10 +50,11 @@ type TaskReloader interface {
|
||||
type SystemConfigUsecase struct {
|
||||
repo InitializationRepo
|
||||
tasks TaskReloader
|
||||
info SystemInfoProvider
|
||||
}
|
||||
|
||||
func NewSystemConfigUsecase(repo InitializationRepo, tasks TaskReloader) *SystemConfigUsecase {
|
||||
return &SystemConfigUsecase{repo: repo, tasks: tasks}
|
||||
func NewSystemConfigUsecase(repo InitializationRepo, tasks TaskReloader, info SystemInfoProvider) *SystemConfigUsecase {
|
||||
return &SystemConfigUsecase{repo: repo, tasks: tasks, info: info}
|
||||
}
|
||||
|
||||
func (uc *SystemConfigUsecase) IsInitialized(ctx context.Context) (bool, error) {
|
||||
@@ -128,3 +129,10 @@ func (uc *SystemConfigUsecase) DiskMountPoints() []string {
|
||||
}
|
||||
return uc.repo.DiskMountPoints()
|
||||
}
|
||||
|
||||
func (uc *SystemConfigUsecase) ServerInfo(ctx context.Context) (*ServerInfo, error) {
|
||||
if uc == nil || uc.repo == nil || uc.info == nil {
|
||||
return nil, errors.New("系统信息服务未就绪")
|
||||
}
|
||||
return uc.info.Collect(ctx, uc.repo.DiskMountPoints())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user