AFAIRE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### jw ####### Copyright (c) 2021 losyme ####################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package jw
import (
"time"
"forge.chapril.org/losyme/errors"
)
const ErrStorage = errors.Sentinel("storage error")
type JobsRunning map[string]int
type JobsToRun interface {
Next() (*Job, error)
}
type SelectNextJob func(jr JobsRunning, jtr JobsToRun) (*Job, error)
type Dashboard struct {
Jobs struct {
Todo int
Pending int
Running int
Succeeded int
Failed int
Total int
}
Workflows struct {
Running int
Succeeded int
Failed int
Total int
}
}
type Storage interface {
ValidateJob(job *Job) error
InsertJob(job *Job) (bool, error)
UpdateJob(job *Job) error
NotifyJob(id string, data interface{}) error
SetJobPriority(id string, priority Priority) error
SetJobRunAfter(id string, duration time.Duration) error
NextJob(namespace string, fn SelectNextJob) (*Job, error)
ValidateWorkflow(wf *Workflow) error
InsertWorkflow(wf *Workflow, job *Job) error
Workflow(id string, mustExist bool) (*Workflow, error)
UpdateWorkflow(wf *Workflow, job, nextJob *Job) error
SetWorkflowPriority(id string, priority Priority) error
Dashboard() (*Dashboard, error)
}
/*
######################################################################################################## @(°_°)@ #######
*/