refactor: 移除 Ops 监控模块
移除未完成的运维监控功能,简化系统架构: - 删除 ops_handler, ops_service, ops_repo 等后端代码 - 删除 ops 相关数据库迁移文件 - 删除前端 OpsDashboard 页面和 API
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/internal/service"
|
||||
)
|
||||
|
||||
const (
|
||||
opsAuthErrorLogWorkerCount = 10
|
||||
opsAuthErrorLogQueueSize = 256
|
||||
opsAuthErrorLogTimeout = 2 * time.Second
|
||||
)
|
||||
|
||||
type opsAuthErrorLogJob struct {
|
||||
ops *service.OpsService
|
||||
entry *service.OpsErrorLog
|
||||
}
|
||||
|
||||
var (
|
||||
opsAuthErrorLogOnce sync.Once
|
||||
opsAuthErrorLogQueue chan opsAuthErrorLogJob
|
||||
)
|
||||
|
||||
func startOpsAuthErrorLogWorkers() {
|
||||
opsAuthErrorLogQueue = make(chan opsAuthErrorLogJob, opsAuthErrorLogQueueSize)
|
||||
for i := 0; i < opsAuthErrorLogWorkerCount; i++ {
|
||||
go func() {
|
||||
for job := range opsAuthErrorLogQueue {
|
||||
if job.ops == nil || job.entry == nil {
|
||||
continue
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), opsAuthErrorLogTimeout)
|
||||
_ = job.ops.RecordError(ctx, job.entry)
|
||||
cancel()
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func enqueueOpsAuthErrorLog(ops *service.OpsService, entry *service.OpsErrorLog) {
|
||||
if ops == nil || entry == nil {
|
||||
return
|
||||
}
|
||||
|
||||
opsAuthErrorLogOnce.Do(startOpsAuthErrorLogWorkers)
|
||||
|
||||
select {
|
||||
case opsAuthErrorLogQueue <- opsAuthErrorLogJob{ops: ops, entry: entry}:
|
||||
default:
|
||||
// Queue is full; drop to avoid blocking request handling.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user