Documentation
¶
Index ¶
- Constants
- Variables
- type BareJob
- func (j *BareJob) GetCommand() string
- func (j *BareJob) GetCronJobID() int
- func (j *BareJob) GetHistory() []*Execution
- func (j *BareJob) GetLastRun() *Execution
- func (j *BareJob) GetName() string
- func (j *BareJob) GetSchedule() string
- func (j *BareJob) Hash() (string, error)
- func (c *BareJob) Middlewares() []Middleware
- func (j *BareJob) NotifyStart()
- func (j *BareJob) NotifyStop()
- func (j *BareJob) Running() int32
- func (j *BareJob) SetCronJobID(id int)
- func (j *BareJob) SetLastRun(e *Execution)
- func (c *BareJob) Use(ms ...Middleware)
- type Context
- type CronUtils
- type ExecJob
- type Execution
- type Job
- type LocalJob
- type Logger
- type LogrusAdapter
- func (l *LogrusAdapter) Criticalf(format string, args ...interface{})
- func (l *LogrusAdapter) Debugf(format string, args ...interface{})
- func (l *LogrusAdapter) Errorf(format string, args ...interface{})
- func (l *LogrusAdapter) Noticef(format string, args ...interface{})
- func (l *LogrusAdapter) Warningf(format string, args ...interface{})
- type Middleware
- type RunJob
- type RunServiceJob
- type Scheduler
- func (s *Scheduler) AddJob(j Job) error
- func (s *Scheduler) DisableJob(name string) error
- func (s *Scheduler) EnableJob(name string) error
- func (s *Scheduler) Entries() []cron.Entry
- func (s *Scheduler) GetDisabledJob(name string) Job
- func (s *Scheduler) GetDisabledJobs() []Job
- func (s *Scheduler) GetJob(name string) Job
- func (s *Scheduler) GetRemovedJobs() []Job
- func (s *Scheduler) IsRunning() bool
- func (c *Scheduler) Middlewares() []Middleware
- func (s *Scheduler) RemoveJob(j Job) error
- func (s *Scheduler) RunJob(name string) error
- func (s *Scheduler) Start() error
- func (s *Scheduler) Stop() error
- func (c *Scheduler) Use(ms ...Middleware)
Constants ¶
const HashmeTagName = "hash"
Variables ¶
var ( // ErrSkippedExecution pass this error to `Execution.Stop` if you wish to mark // it as skipped. ErrSkippedExecution = errors.New("skipped execution") ErrUnexpected = errors.New("error unexpected, docker has returned exit code -1, maybe wrong user?") ErrMaxTimeRunning = errors.New("the job has exceeded the maximum allowed time running.") ErrLocalImageNotFound = errors.New("couldn't find image on the host") )
var ( ErrEmptyScheduler = errors.New("unable to start a empty scheduler.") ErrEmptySchedule = errors.New("unable to add a job with a empty schedule.") )
Functions ¶
This section is empty.
Types ¶
type BareJob ¶
type BareJob struct {
Schedule string `hash:"true"`
Name string `hash:"true"`
Command string `hash:"true"`
HistoryLimit int `default:"10"`
// contains filtered or unexported fields
}
func (*BareJob) GetCommand ¶
func (*BareJob) GetCronJobID ¶
func (*BareJob) GetHistory ¶ added in v0.8.0
GetHistory returns a copy of the job's execution history.
func (*BareJob) GetLastRun ¶ added in v0.8.0
GetLastRun returns the last execution of the job, if any.
func (*BareJob) GetSchedule ¶
func (*BareJob) Middlewares ¶
func (c *BareJob) Middlewares() []Middleware
func (*BareJob) NotifyStart ¶
func (j *BareJob) NotifyStart()
func (*BareJob) NotifyStop ¶
func (j *BareJob) NotifyStop()
func (*BareJob) SetCronJobID ¶
func (*BareJob) SetLastRun ¶ added in v0.8.0
SetLastRun stores the last executed run for the job.
func (*BareJob) Use ¶
func (c *BareJob) Use(ms ...Middleware)
type Context ¶
type CronUtils ¶
type CronUtils struct {
Logger Logger
}
Implement the cron logger interface
func NewCronUtils ¶
type ExecJob ¶
type ExecJob struct {
BareJob `mapstructure:",squash"`
Client *docker.Client `json:"-"`
Container string `hash:"true"`
User string `default:"root" hash:"true"`
TTY bool `default:"false" hash:"true"`
Environment []string `mapstructure:"environment"`
// contains filtered or unexported fields
}
func NewExecJob ¶
func (*ExecJob) Middlewares ¶
func (c *ExecJob) Middlewares() []Middleware
func (*ExecJob) Use ¶
func (c *ExecJob) Use(ms ...Middleware)
type Execution ¶
type Execution struct {
ID string
Date time.Time
Duration time.Duration
IsRunning bool
Failed bool
Skipped bool
Error error
OutputStream, ErrorStream *circbuf.Buffer `json:"-"`
}
Execution contains all the information relative to a Job execution.
func NewExecution ¶
NewExecution returns a new Execution, with a random ID
type LocalJob ¶
type LocalJob struct {
BareJob `mapstructure:",squash"`
Dir string
Environment []string `mapstructure:"environment"`
}
func NewLocalJob ¶
func NewLocalJob() *LocalJob
func (*LocalJob) Middlewares ¶
func (c *LocalJob) Middlewares() []Middleware
func (*LocalJob) Use ¶
func (c *LocalJob) Use(ms ...Middleware)
type LogrusAdapter ¶ added in v0.8.0
LogrusAdapter wraps a logrus.Logger to satisfy the Logger interface.
func (*LogrusAdapter) Criticalf ¶ added in v0.8.0
func (l *LogrusAdapter) Criticalf(format string, args ...interface{})
func (*LogrusAdapter) Debugf ¶ added in v0.8.0
func (l *LogrusAdapter) Debugf(format string, args ...interface{})
func (*LogrusAdapter) Errorf ¶ added in v0.8.0
func (l *LogrusAdapter) Errorf(format string, args ...interface{})
func (*LogrusAdapter) Noticef ¶ added in v0.8.0
func (l *LogrusAdapter) Noticef(format string, args ...interface{})
func (*LogrusAdapter) Warningf ¶ added in v0.8.0
func (l *LogrusAdapter) Warningf(format string, args ...interface{})
type Middleware ¶
type Middleware interface {
// Run is called instead of the original `Job.Run`, you MUST call to `ctx.Run`
// inside of the middleware `Run` function otherwise you will broken the
// Job workflow.
Run(*Context) error
// ContinueOnStop reports whether Run should be called even when the
// execution has been stopped
ContinueOnStop() bool
}
Middleware can wrap any job execution, allowing to execution code before or/and after of each `Job.Run`
type RunJob ¶
type RunJob struct {
BareJob `mapstructure:",squash"`
Client *docker.Client `json:"-"`
User string `default:"root"`
// ContainerName specifies the name of the container to be created. If
// nil, the job name will be used. If set to an empty string, Docker
// will assign a random name.
ContainerName *string `gcfg:"container-name" mapstructure:"container-name"`
TTY bool `default:"false"`
// do not use bool values with "default:true" because if
// user would set it to "false" explicitly, it still will be
// changed to "true" https://github.com/netresearch/ofelia/issues/135
// so lets use strings here as workaround
Delete string `default:"true"`
Pull string `default:"true"`
Image string
Network string
Hostname string
Entrypoint *string
Container string
Volume []string
VolumesFrom []string `gcfg:"volumes-from" mapstructure:"volumes-from,"`
Environment []string `mapstructure:"environment"`
// contains filtered or unexported fields
}
func (*RunJob) Middlewares ¶
func (c *RunJob) Middlewares() []Middleware
func (*RunJob) Use ¶
func (c *RunJob) Use(ms ...Middleware)
type RunServiceJob ¶
type RunServiceJob struct {
BareJob `mapstructure:",squash"`
Client *docker.Client `json:"-"`
User string `default:"root"`
TTY bool `default:"false"`
// do not use bool values with "default:true" because if
// user would set it to "false" explicitly, it still will be
// changed to "true" https://github.com/netresearch/ofelia/issues/135
// so lets use strings here as workaround
Delete string `default:"true"`
Image string
Network string
}
func NewRunServiceJob ¶
func NewRunServiceJob(c *docker.Client) *RunServiceJob
func (*RunServiceJob) Middlewares ¶
func (c *RunServiceJob) Middlewares() []Middleware
func (*RunServiceJob) Run ¶
func (j *RunServiceJob) Run(ctx *Context) error
func (*RunServiceJob) Use ¶
func (c *RunServiceJob) Use(ms ...Middleware)
type Scheduler ¶
type Scheduler struct {
Jobs []Job
Removed []Job
Disabled []Job
Logger Logger
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) DisableJob ¶ added in v0.8.0
DisableJob stops scheduling the job but keeps it for later enabling.
func (*Scheduler) GetDisabledJob ¶ added in v0.8.0
GetDisabledJob returns a disabled job by name.
func (*Scheduler) GetDisabledJobs ¶ added in v0.8.0
GetDisabledJobs returns a copy of all disabled jobs.
func (*Scheduler) GetRemovedJobs ¶ added in v0.8.0
GetRemovedJobs returns a copy of all jobs that were removed from the scheduler.
func (*Scheduler) Middlewares ¶
func (c *Scheduler) Middlewares() []Middleware
func (*Scheduler) Use ¶
func (c *Scheduler) Use(ms ...Middleware)