cdule

package
v0.0.0-...-b60e286 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JobRegistry = make(map[string]reflect.Type)

JobRegistry job registry

View Source
var ScheduleParser cron.Parser

ScheduleParser cron parser

View Source
var WorkerID string

WorkerID string

Functions

func CancelJob

func CancelJob(jobName string, subName string) error

CancelJob to delete schedules for a job in the database by jobName and subName

func RegisterType

func RegisterType(job Job)

Types

type AbstractJob

type AbstractJob struct {
	Job     Job
	JobData map[string]string
	SubName string
}

AbstractJob for holding job and jobdata

func NewJob

func NewJob(job Job, jobData map[string]string, subName ...string) *AbstractJob

NewJob to create new abstract job

func (*AbstractJob) Build

func (j *AbstractJob) Build(cronExpression string) (*model.Job, error)

Build to build job and store in the database

func (*AbstractJob) BuildToRunAt

func (j *AbstractJob) BuildToRunAt(t time.Time) (*model.Job, error)

BuildToRunAt to build job to run only once and store in the database

func (*AbstractJob) BuildToRunIn

func (j *AbstractJob) BuildToRunIn(n time.Duration) (*model.Job, error)

BuildToRunIn to build job to run only once and store in the database

func (*AbstractJob) BuildToRunNow

func (j *AbstractJob) BuildToRunNow() (*model.Job, error)

BuildToRunNow to build job to run immediately only once and store in the database

type Cdule

type Cdule struct {
	*WorkerWatcher
	*ScheduleWatcher
	PastScheduleWatcher *PastScheduleWatcher
}

Cdule holds watcher objects

func (*Cdule) NewCdule

func (cdule *Cdule) NewCdule(config ...*pkg.CduleConfig)

NewCdule to create new scheduler with default worker name as hostname

func (*Cdule) NewCduleWithWorker

func (cdule *Cdule) NewCduleWithWorker(workerName string, config ...*pkg.CduleConfig)

NewCduleWithWorker to create new scheduler with worker

func (Cdule) StopWatcher

func (cdule Cdule) StopWatcher()

StopWatcher to stop watchers

type Job

type Job interface {
	Execute(map[string]string)
	JobName() string
	GetJobData() map[string]string
}

Job interface

type JobSub

type JobSub interface {
	SubName() string
}

type PastScheduleWatcher

type PastScheduleWatcher struct {
	ScheduleWatcher
}

ScheduleWatcher struct

func (*PastScheduleWatcher) Run

func (t *PastScheduleWatcher) Run()

Run to run watcher in a continuous loop

type ScheduleWatcher

type ScheduleWatcher struct {
	Closed         chan struct{}
	WG             sync.WaitGroup
	TickDuration   time.Duration
	Ticker         *time.Ticker
	RunImmediately bool
}

ScheduleWatcher struct

func (*ScheduleWatcher) Run

func (t *ScheduleWatcher) Run()

Run to run watcher in a continuous loop

func (*ScheduleWatcher) Stop

func (t *ScheduleWatcher) Stop()

Stop to stop scheduler watcher

type WorkerJobCount

type WorkerJobCount struct {
	WorkerID string `json:"worker_id"`
	Count    int64  `json:"count"`
}

WorkerJobCount struct

type WorkerWatcher

type WorkerWatcher struct {
	Closed chan struct{}
	WG     sync.WaitGroup
	Ticker *time.Ticker
}

WorkerWatcher struct

func (*WorkerWatcher) Run

func (t *WorkerWatcher) Run()

Run to run watcher in a continuous loop

func (*WorkerWatcher) Stop

func (t *WorkerWatcher) Stop()

Stop to stop worker watcher

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL