Documentation
¶
Index ¶
- Constants
- Variables
- func MarkIncompleteJobsHandler(ctx context.Context, args *MarkIncompleteJobs) (string, error)
- func ProcessTriggersHandler(ctx context.Context, args *ProcessTriggers) (string, error)
- func RegisterHandler[T JobData](h Handler[T])
- type GoRunService
- type Handler
- type JobData
- type MarkIncompleteJobs
- type Option
- func DisableLogging() Option
- func OnJobComplete(...) Option
- func OnJobInit(f func(ctx context.Context, jobType string, jobId string) context.Context) Option
- func WithArgProcessor(f func(ctx context.Context, jobType string, jobId string, args any) error) Option
- func WithBatchFreq(freq time.Duration) Option
- func WithBatchSize(size int) Option
- func WithJobTimeout(jobTimeout time.Duration) Option
- type ProcessTriggers
- type Trigger
- type Validateable
Constants ¶
View Source
const ( StatusScheduled = "scheduled" StatusRunning = "running" StatusCompleted = "completed" StatusFailed = "failed" )
Variables ¶
View Source
var ErrGorunInternalError = errors.Sentinel("internal gorun job service error")
View Source
var ErrUnregisteredJobType = errors.Sentinel("unregistered job type")
Functions ¶
func MarkIncompleteJobsHandler ¶
func MarkIncompleteJobsHandler(ctx context.Context, args *MarkIncompleteJobs) (string, error)
func ProcessTriggersHandler ¶
func ProcessTriggersHandler(ctx context.Context, args *ProcessTriggers) (string, error)
func RegisterHandler ¶
Types ¶
type GoRunService ¶
type GoRunService interface {
ScheduleImmediately(ctx context.Context, job JobData) (jobId string, err error)
ScheduleAfter(ctx context.Context, delay time.Duration, job JobData) (jobId string, err error)
ScheduleCron(ctx context.Context, cronExpr string, loc *time.Location, job JobData) (triggerId string, err error)
ScheduleRepeated(ctx context.Context, interval time.Duration, job JobData) (triggerId string, err error)
ScheduleCronWithKey(ctx context.Context, triggerId string, cronExpr string, loc *time.Location, job JobData) error
ScheduleRepeatedWithKey(ctx context.Context, triggerId string, interval time.Duration, job JobData) error
GetJob(ctx context.Context, jobId string) (*gorundb.JobData, error)
ListJobs(ctx context.Context, start, end time.Time) ([]*gorundb.JobData, error)
ListTriggers(ctx context.Context) ([]*gorundb.JobTrigger, error)
DeleteTrigger(ctx context.Context, triggerId string) error
Start(ctx context.Context) error
Close()
}
func NewFromEnv ¶
func NewFromEnv(opts ...Option) (GoRunService, error)
type JobData ¶
type JobData interface {
// Return a constant name for the job that will process the request - this is used to uniquely identify the job handler
JobType() string
}
type MarkIncompleteJobs ¶
type MarkIncompleteJobs struct{}
func (MarkIncompleteJobs) JobType ¶
func (a MarkIncompleteJobs) JobType() string
type Option ¶
type Option func(*options)
func DisableLogging ¶
func DisableLogging() Option
func OnJobComplete ¶ added in v0.3.0
func WithArgProcessor ¶ added in v0.3.0
func WithBatchFreq ¶
How often each job server will check for new jobs to run
func WithBatchSize ¶
How many new jobs to run in each batch. Currently there is no limit on the number of concurrent jobs.
func WithJobTimeout ¶
The maximum amount of time a job can run before it is considered to have timed out
type ProcessTriggers ¶
type ProcessTriggers struct{}
func (ProcessTriggers) JobType ¶
func (a ProcessTriggers) JobType() string
type Validateable ¶
type Validateable interface {
Validate() error
}
Click to show internal directories.
Click to hide internal directories.