job

package
v0.0.0-...-c22d2bc Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2017 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DAYOFWEEK = 4
	MONTH     = 3
	DAY       = 2
	HOUR      = 1
	MINUTE    = 0
	SUNDAY    = "Sunday"
	MONDAY    = "Monday"
	TUESDAY   = "Tuesday"
	WEDNESDAY = "Wednesday"
	THURSDAY  = "Thursday"
	FRIDAY    = "Friday"
	SATURDAY  = "Saturday"
)

Variables

This section is empty.

Functions

func CreateRunToken

func CreateRunToken() string

func ParseDayOfMonthIntoFilter

func ParseDayOfMonthIntoFilter(rawStr string) (func(testTime time.Time) bool, error)

ParseDayOfMonthIntoFilter - Translate schedule notation of a day in a month (1 - 32)

into a function that when called with a datetime, will tell you if the date is on that day of the month

func ParseDayOfWeekIntoFilter

func ParseDayOfWeekIntoFilter(rawStr string) (func(testTime time.Time) bool, error)

ParseDayOfWeekIntoFilter - Translate schedule notation of a day of the week (0: Sun - 6: Sat)

into a function that when called with a datetime will, tell you if the date is on that day

func ParseHourIntoFilter

func ParseHourIntoFilter(rawStr string) (func(testTime time.Time) bool, error)

ParseHourIntoFilter - Translate schedule notation of an hour in a day (0 - 23)

into a function that when called with a datetime, will tell you if the time is currently in that hour

func ParseMinuteIntoFilter

func ParseMinuteIntoFilter(rawStr string) (func(testTime time.Time) bool, error)

ParseMinuteIntoFilter - Translate schedule notation of a minute in an hour (0 - 59)

into a function that when called with a datetime, will tell you if the time is currently in that minute

func ParseMonthIntoFilter

func ParseMonthIntoFilter(rawStr string) (func(testTime time.Time) bool, error)

ParseMonthIntoFilter - Translate schedule notation of a month (1: Jan - 12: Dec)

into a function that when called with a datetime, will tell you if the date is in that month

Types

type ChanComm

type ChanComm struct {
	Signal string
	Error  error
	Writer http.ResponseWriter
}

type JobConfig

type JobConfig struct {
	Label     string // The name of the job.  Used in logging
	Command   string // String to be run on the system
	GroupName string // Used to relate jobs and in logging *unused*
	Schedule  string // Traditional encoded string to represent the schedule
	Locking   bool   // Self-locking daemon that won't step on its own toes
	Filters   []func(currentTime time.Time) bool
}

JobConfig - Object representing a single scheduled job

func (*JobConfig) CheckIfScheduled

func (j *JobConfig) CheckIfScheduled(timeToCheck time.Time) bool

CheckIfScheduled - Initiates each filter for a job and returns whether or not to run the job

func (*JobConfig) MakeAPIFormat

func (j *JobConfig) MakeAPIFormat() (JobConfigAPI, error)

MakeAPIFormat - Convert internal object into external data

func (*JobConfig) ParseScheduleIntoFilters

func (j *JobConfig) ParseScheduleIntoFilters(testing bool) error

ParseScheduleIntoFilters - Translate schedule string into iterable functions

type JobConfigAPI

type JobConfigAPI struct {
	Label     string // The name of the job.  Used in logging
	Command   string // String to be run on the system
	GroupName string // Used to relate jobs and in logging *unused*
	Locking   bool   // Self-locking daemon that won't step on its own toes
	Schedule  string // Traditional encoded string to represent the schedule
}

JobConfigAPI - Object representing a single scheduled job and is JSON friendly for API use

type JobSchedule

type JobSchedule struct {
	Job          []JobConfig
	LabelToIndex map[string]int
}

JobSchedule - Keep all the jobs together in an iterable slice

func (*JobSchedule) CheckConfig

func (h *JobSchedule) CheckConfig() error

CheckConfig - Sanity checks on the JobSchedule and builds LabelToIndex. MUST BE RUN EVERYTIME THE RUNNING CONFIG IS CHANGED!

func (*JobSchedule) GetJobByID

func (h *JobSchedule) GetJobByID(jobID int) (JobConfig, error)

GetJobByID - Find a job using its ID

func (*JobSchedule) GetJobByLabel

func (h *JobSchedule) GetJobByLabel(title string) (JobConfig, int, error)

GetJobByTitle - Find a job using its title

func (*JobSchedule) MakeAPIFormat

func (h *JobSchedule) MakeAPIFormat() (JobScheduleAPI, error)

MakeAPIFormat - Convert internal object into external data

func (*JobSchedule) ParseJobConfig

func (h *JobSchedule) ParseJobConfig(confFile string) error

ParseJobConfig - Decode TOML config file and initiate ParseScheduleIntoFilters for each job

func (*JobSchedule) WriteJobConfig

func (h *JobSchedule) WriteJobConfig(confFile string) error

WriteJobConfig - update the written config file with any changes that have occured

type JobScheduleAPI

type JobScheduleAPI struct {
	Job []JobConfigAPI
}

JobScheduleAPI - Keep all the jobs together in an iterable slice and is JSON friendly for API use

type RunningJob

type RunningJob struct {
	Token     string
	Config    JobConfig
	Channel   chan ChanComm
	Exec      *exec.Cmd
	StdOut    io.ReadCloser
	StdErr    io.ReadCloser
	StartTime time.Time
}

func (*RunningJob) DetermineLoggingDir

func (r *RunningJob) DetermineLoggingDir() string

DetermineLoggingPath - Get the filepath to write new logs to

func (*RunningJob) MakeAPIFormat

func (j *RunningJob) MakeAPIFormat(jobToken string) (RunningJobAPI, error)

MakeAPIFormat - Convert internal object into external data

func (*RunningJob) Run

func (r *RunningJob) Run(running *RunningJobTracker)

Run - Executes command

type RunningJobAPI

type RunningJobAPI struct {
	Token       string
	StartTime   time.Time
	ElapsedTime time.Duration
	PID         int
	MemUse      int

	Config JobConfigAPI
}

type RunningJobTracker

type RunningJobTracker struct {
	Sync *sync.RWMutex
	Jobs map[string]RunningJob
}

func (*RunningJobTracker) MakeAPIFormat

func (t *RunningJobTracker) MakeAPIFormat() (RunningJobTrackerAPI, error)

MakeAPIFormat - Convert internal object into external data

type RunningJobTrackerAPI

type RunningJobTrackerAPI struct {
	Jobs []RunningJobAPI
}

Jump to

Keyboard shortcuts

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