fix(task): execute dispatched jobs and persist run records

Asynq func handlers now go through ProcessTask so admin execution
rows leave pending. The in-process worker resolves admin type
identifiers and writes the same w_task_executions table. Remove
the no-op admin system_cleanup that shadowed the upload handler.
This commit is contained in:
ryan
2026-09-02 16:11:45 +08:00
parent 33f28ad671
commit 30bbe965bf
14 changed files with 530 additions and 82 deletions
@@ -8,6 +8,7 @@ import (
"Wavelet/core"
"Wavelet/core/contracts"
"context"
"errors"
"sync"
"time"
)
@@ -24,15 +25,15 @@ var (
)
// DispatchTask enqueues a background task to the active in-process worker queue.
func DispatchTask(_ context.Context, taskType string, payload []byte, source string) (string, error) {
func DispatchTask(ctx context.Context, taskType string, payload []byte, source string) (string, error) {
globalMu.RLock()
q := globalQueue
globalMu.RUnlock()
if q == nil {
return "", nil
return "", errors.New("driver_inproc_worker: queue is not running")
}
return q.Enqueue(taskType, payload, source)
return q.Enqueue(ctx, taskType, payload, source)
}
// Option configures the in-process worker driver plugin.
@@ -118,10 +119,19 @@ func (p *Plugin) ConfigEnabled(view core.ConfigView) bool {
func (p *Plugin) Apply(ctx *core.Context) error {
p.coreCtx = ctx
if db, err := core.Inject[contracts.DBService](ctx); err == nil && db != nil {
setDBService(db)
} else {
core.When[contracts.DBService](ctx, func(db contracts.DBService) {
setDBService(db)
})
}
taskSvc := newInprocTaskService(ctx.Tasks())
core.Provide[contracts.TaskService](ctx, taskSvc)
ctx.OnDispose(func() error {
setDBService(nil)
shutdownCtx, cancel := context.WithTimeout(context.Background(), p.shutdownTimeout)
defer cancel()
return p.Stop(shutdownCtx)