完善提取处理流程,解决提取并发问题

This commit is contained in:
2026-05-13 16:17:57 +08:00
parent d273731e31
commit ccbc6f0b67
6 changed files with 361 additions and 287 deletions

View File

@@ -2,7 +2,6 @@ package services
import (
"context"
"fmt"
"net/netip"
"platform/pkg/u"
"platform/web/core"
@@ -19,10 +18,6 @@ var Proxy = &proxyService{}
type proxyService struct{}
func proxyStatusLockKey(id int32) string {
return fmt.Sprintf("platform:proxy:status:%d", id)
}
func hasUsedChans(proxyID int32) (bool, error) {
ctx := context.Background()
pattern := usedChansKey(proxyID, "*")
@@ -191,7 +186,7 @@ type UpdateProxyStatus struct {
}
func (s *proxyService) UpdateStatus(update *UpdateProxyStatus) error {
return g.Redsync.WithLock(proxyStatusLockKey(update.ID), func() error {
return q.Q.Transaction(func(tx *q.Query) error {
proxy, err := q.Proxy.Where(q.Proxy.ID.Eq(update.ID)).Take()
if err != nil {
return err