feat(11-01): add the conga job framework on River with transactional dispatch
- Pin River v0.47.0 (riverdatabasesql, rivertype) and tidy the example modules - lagoon.Migrate runs the summercms.conga set: River schema v7 and summer_jobs with the apparatus columns plus an internal river_job_id link - conga.Manager.Dispatch writes the summer_jobs row (status IN_PROGRESS) and the River job on the caller's *sql.Tx; a rollback leaves neither - conga.Job wraps typed job functions so plugins never import River - conga.StartWorker runs one client on riverdatabasesql.NewWithPgxListener with a single-connection LISTEN pool; the final failed attempt sets ERROR - TestListenPickupLatency: 30s poll, pickup under 1s; poll-only control 2s miss
This commit is contained in:
45
modules/conga/record.go
Normal file
45
modules/conga/record.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package conga
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/lagoon"
|
||||
)
|
||||
|
||||
// Status is the summer_jobs status column. The values match the WinterCMS
|
||||
// apparatus JobStatus constants.
|
||||
type Status int
|
||||
|
||||
const (
|
||||
// StatusInQueue is defined for parity; Dispatch never writes it.
|
||||
StatusInQueue Status = 0
|
||||
// StatusInProgress is written by Dispatch and kept while River retries.
|
||||
StatusInProgress Status = 1
|
||||
// StatusComplete is written by CompleteJob, including skipped work.
|
||||
StatusComplete Status = 2
|
||||
// StatusError is written by FailJob and by the final failed attempt.
|
||||
StatusError Status = 3
|
||||
// StatusStopped is written by CancelJob and StopJob.
|
||||
StatusStopped Status = 4
|
||||
)
|
||||
|
||||
// Record is one summer_jobs row: the queryable outcome of a dispatched job.
|
||||
// River only executes the work; API responses, progress and cancellation
|
||||
// read this row.
|
||||
type Record struct {
|
||||
ID uint `gorm:"column:id;primaryKey"`
|
||||
Label string `gorm:"column:label"`
|
||||
Status Status `gorm:"column:status"`
|
||||
Progress int `gorm:"column:progress"`
|
||||
ProgressMax int `gorm:"column:progress_max"`
|
||||
UserID *uint `gorm:"column:user_id"`
|
||||
IsAdmin bool `gorm:"column:is_admin"`
|
||||
IsCanceled bool `gorm:"column:is_canceled"`
|
||||
Metadata string `gorm:"column:metadata"`
|
||||
RiverJobID *int64 `gorm:"column:river_job_id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at"`
|
||||
}
|
||||
|
||||
// TableName returns lagoon.JobsTable.
|
||||
func (Record) TableName() string { return lagoon.JobsTable }
|
||||
Reference in New Issue
Block a user