feat(api): integrate TLS certificate renewal into async task framework

Replace native goroutines in RenewCertificate logic with Asynq task dispatching to support queue execution, retry capability, and detailed task execution logs.
This commit is contained in:
ryan
2026-06-22 10:54:15 +08:00
parent df3bcd3d19
commit 3a2878d070
10 changed files with 303 additions and 4 deletions
+10 -4
View File
@@ -13,6 +13,7 @@ import (
"strings"
"github.com/Rain-kl/Wavelet/internal/model"
"github.com/Rain-kl/Wavelet/internal/task"
)
// CertificateInput TLS 证书创建/更新请求。
@@ -282,10 +283,15 @@ func RenewCertificate(ctx context.Context, id uint) (*model.TLSCertificate, erro
return nil, errors.New(errCertificateOnlyACMERenew)
}
go func(c *model.TLSCertificate) {
asyncCtx := context.WithoutCancel(ctx)
_ = obtainTLSCertificate(asyncCtx, c)
}(cert)
payload, err := json.Marshal(SSLSingleRenewPayload{ID: id})
if err != nil {
return nil, err
}
_, err = task.DispatchTask(ctx, TaskTypeSSLSingleRenew, payload, "manual")
if err != nil {
return nil, err
}
cert.ApplyStatus = tlsApplyStatusApplying
cert.ApplyMessage = ""