feat(11-01): run job workers in serve and queue:work, add queue:clear
- Manager gains the apparatus JobManager surface: StartJob, UpdateJobState, UpdateMetadata, FailJob, CancelJob (is_canceled + STOPPED + River JobCancel), StopJob (STOPPED only), CheckIfCanceled and GetMetadata, all raw column writes so updated_at is untouched - serve starts the in-process worker unless queue.work_in_serve is false and stops it on shutdown; an app without jobs gets an idle worker - queue:work runs a foreground worker with repeatable --queue filters; queue:clear deletes available, scheduled and retryable jobs of one queue - the generated main appends conga.RuntimeCommands; summer delegates queue:work and queue:clear; make:job scaffolds a conga.Job
This commit is contained in:
@@ -66,8 +66,8 @@ package jobs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/conga"
|
||||
"git.golem15.com/golem15/summercms/modules/pact"
|
||||
)
|
||||
|
||||
@@ -76,17 +76,12 @@ type {{.Ident}}Args struct{}
|
||||
|
||||
func ({{.Ident}}Args) Kind() string { return {{printf "%q" .Kind}} }
|
||||
|
||||
type {{.Worker}} struct{}
|
||||
|
||||
func ({{.Worker}}) Work(ctx context.Context, args pact.JobArgs) error {
|
||||
if _, ok := args.({{.Ident}}Args); !ok {
|
||||
return fmt.Errorf("jobs: unexpected args type %T", args)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// {{.Func}} returns the {{.Kind}} job.
|
||||
func {{.Func}}() pact.Job { return {{.Worker}}{} }
|
||||
func {{.Func}}() pact.Job {
|
||||
return conga.Job(func(ctx context.Context, args {{.Ident}}Args) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{define "admin_controller.go"}}// Code generated by summer make. DO NOT EDIT.
|
||||
|
||||
Reference in New Issue
Block a user