Cancel use HTTP services and WebSockets

This commit is contained in:
2025-06-19 10:43:43 +08:00
parent 3c880199ae
commit a62ea251cd
9 changed files with 75 additions and 931 deletions

View File

@@ -32,12 +32,11 @@ type MigrationProgress struct {
// MigrationService 迁移服务
type MigrationService struct {
logger *log.LoggerService
mu sync.RWMutex
currentProgress MigrationProgress
cancelFunc context.CancelFunc
ctx context.Context
progressBroadcaster func(MigrationProgress) // WebSocket广播函数
logger *log.LoggerService
mu sync.RWMutex
currentProgress MigrationProgress
cancelFunc context.CancelFunc
ctx context.Context
}
// NewMigrationService 创建迁移服务
@@ -67,11 +66,6 @@ func (ms *MigrationService) updateProgress(progress MigrationProgress) {
ms.mu.Lock()
ms.currentProgress = progress
ms.mu.Unlock()
// 通过WebSocket广播进度
if ms.progressBroadcaster != nil {
ms.progressBroadcaster(progress)
}
}
// MigrateDirectory 迁移目录
@@ -407,13 +401,6 @@ func (ms *MigrationService) CancelMigration() error {
return fmt.Errorf("No active migration to cancel")
}
// SetProgressBroadcaster 设置进度广播函数
func (ms *MigrationService) SetProgressBroadcaster(broadcaster func(MigrationProgress)) {
ms.mu.Lock()
defer ms.mu.Unlock()
ms.progressBroadcaster = broadcaster
}
// ServiceShutdown 服务关闭
func (ms *MigrationService) ServiceShutdown() error {
ms.logger.Info("Migration: Service is shutting down...")