Documentation ¶
Index ¶
- Variables
- type ErrJobNotFound
- type Job
- func (j Job) Bytes() ([]byte, error)
- func (j *Job) Delete(cache JobCache, db JobDB) error
- func (j *Job) DeleteFromDependentJobs(cache JobCache) error
- func (j *Job) DeleteFromParentJobs(cache JobCache) error
- func (j *Job) Disable()
- func (j *Job) Enable(cache JobCache)
- func (j *Job) GetWaitDuration() time.Duration
- func (j *Job) Init(cache JobCache) error
- func (j *Job) InitDelayDuration(checkTime bool) error
- func (j *Job) Run(cache JobCache)
- func (j *Job) StartWaiting(cache JobCache)
- func (j *Job) StopTimer()
- type JobCache
- type JobDB
- type JobRunner
- type JobStat
- type JobsMap
- type KalaStats
- type MemoryJobCache
- func (c *MemoryJobCache) Delete(id string) error
- func (c *MemoryJobCache) Get(id string) (*Job, error)
- func (c *MemoryJobCache) GetAll() *JobsMap
- func (c *MemoryJobCache) Persist() error
- func (c *MemoryJobCache) PersistEvery(persistWaitTime time.Duration)
- func (c *MemoryJobCache) Set(j *Job) error
- func (c *MemoryJobCache) Start(persistWaitTime time.Duration)
- type Metadata
- type MockDB
Constants ¶
This section is empty.
Variables ¶
var ( RFC3339WithoutTimezone = "2006-01-02T15:04:05" ErrInvalidJob = errors.New("Invalid Job. Job's must contain a Name and a Command field") )
var ( ErrJobDisabled = errors.New("Job cannot run, as it is disabled") ErrCmdIsEmpty = errors.New("Job Command is empity.") )
var (
ErrJobDoesntExist = errors.New("The job you requested does not exist")
)
Functions ¶
This section is empty.
Types ¶
type ErrJobNotFound ¶
type ErrJobNotFound string
ErrJobNotFound is raised when a Job is able to be found within a database.
func (ErrJobNotFound) Error ¶
func (id ErrJobNotFound) Error() string
type Job ¶
type Job struct { Name string `json:"name"` Id string `json:"id"` // Command to run // e.g. "bash /path/to/my/script.sh" Command string `json:"command"` // Email of the owner of this job // e.g. "admin@example.com" Owner string `json:"owner"` // Is this job disabled? Disabled bool `json:"disabled"` // Jobs that are dependent upon this one will be run after this job runs. DependentJobs []string `json:"dependent_jobs"` // List of ids of jobs that this job is dependent upon. ParentJobs []string `json:"parent_jobs"` // ISO 8601 String // e.g. "R/2014-03-08T20:00:00.000Z/PT2H" Schedule string `json:"schedule"` // Number of times to retry on failed attempt for each run. Retries uint `json:"retries"` // Duration in which it is safe to retry the Job. Epsilon string `json:"epsilon"` NextRunAt time.Time `json:"next_run_at"` // Meta data about successful and failed runs. Metadata Metadata `json:"metadata"` // Collection of Job Stats Stats []*JobStat `json:"stats"` // contains filtered or unexported fields }
func GetMockJob ¶
func GetMockJob() *Job
func GetMockJobWithGenericSchedule ¶
func GetMockJobWithGenericSchedule() *Job
func GetMockJobWithSchedule ¶
func NewFromBytes ¶
NewFromBytes returns a Job instance from a byte representation.
func (*Job) DeleteFromDependentJobs ¶
DeleteFromDependentJobs
func (*Job) DeleteFromParentJobs ¶
DeleteFromParentJobs goes through and deletes the current job from any parent jobs.
func (*Job) Disable ¶
func (j *Job) Disable()
Disable stops the job from running by stopping its jobTimer. It also sets Job.Disabled to true, which is reflected in the UI.
func (*Job) GetWaitDuration ¶
func (*Job) Init ¶
Init fills in the protected fields and parses the iso8601 notation. It also adds the job to the Cache
func (*Job) InitDelayDuration ¶
InitDelayDuration is used to parsed the iso8601 Schedule notation into its relevent fields in the Job struct. If checkTime is true, then it will return an error if the Scheduled time has passed.
func (*Job) StartWaiting ¶
StartWaiting begins a timer for when it should execute the Jobs .Run() method.
type JobStat ¶
type JobStat struct { JobId string `json:"job_id"` RanAt time.Time `json:"ran_at"` NumberOfRetries uint `json:"number_of_retries"` Success bool `json:"success"` ExecutionDuration time.Duration `json:"execution_duration"` }
JobStat is used to store metrics about a specific Job .Run()
func NewJobStat ¶
type JobsMap ¶
func NewJobsMap ¶
func NewJobsMap() *JobsMap
type KalaStats ¶
type KalaStats struct { ActiveJobs int `json:"active_jobs"` DisabledJobs int `json:"disabled_jobs"` Jobs int `json:"jobs"` ErrorCount uint `json:"error_count"` SuccessCount uint `json:"success_count"` NextRunAt time.Time `json:"next_run_at"` LastAttemptedRun time.Time `json:"last_attempted_run"` CreatedAt time.Time `json:"created"` }
KalaStats is the struct for storing app-level metrics
func NewKalaStats ¶
NewKalaStats is used to easily generate a current app-level metrics report.
type MemoryJobCache ¶
type MemoryJobCache struct {
// contains filtered or unexported fields
}
func NewMemoryJobCache ¶
func NewMemoryJobCache(jobDB JobDB) *MemoryJobCache
func NewMockCache ¶
func NewMockCache() *MemoryJobCache
func (*MemoryJobCache) Delete ¶
func (c *MemoryJobCache) Delete(id string) error
func (*MemoryJobCache) GetAll ¶
func (c *MemoryJobCache) GetAll() *JobsMap
func (*MemoryJobCache) Persist ¶
func (c *MemoryJobCache) Persist() error
func (*MemoryJobCache) PersistEvery ¶
func (c *MemoryJobCache) PersistEvery(persistWaitTime time.Duration)
func (*MemoryJobCache) Set ¶
func (c *MemoryJobCache) Set(j *Job) error
func (*MemoryJobCache) Start ¶
func (c *MemoryJobCache) Start(persistWaitTime time.Duration)