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 (c *BareJob) ResetMiddlewares(ms ...Middleware)
- func (j *BareJob) Running() int32
- func (j *BareJob) SetCronJobID(id int)
- func (j *BareJob) SetLastRun(e *Execution)
- func (c *BareJob) Use(ms ...Middleware)
- type ComposeJob
- 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 (c *Scheduler) ResetMiddlewares(ms ...Middleware)
- 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 an empty scheduler") ErrEmptySchedule = errors.New("unable to add a job with an 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) ResetMiddlewares ¶ added in v0.9.0
func (c *BareJob) ResetMiddlewares(ms ...Middleware)
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 ComposeJob ¶ added in v0.9.0
type ComposeJob struct {
BareJob `mapstructure:",squash"`
File string `default:"compose.yml" gcfg:"file" mapstructure:"file" hash:"true"`
Service string `gcfg:"service" mapstructure:"service" hash:"true"`
Exec bool `default:"false" gcfg:"exec" mapstructure:"exec" hash:"true"`
}
func NewComposeJob ¶ added in v0.9.0
func NewComposeJob() *ComposeJob
func (*ComposeJob) Hash ¶ added in v0.9.0
func (j *ComposeJob) Hash() (string, error)
func (*ComposeJob) Middlewares ¶ added in v0.9.0
func (c *ComposeJob) Middlewares() []Middleware
func (*ComposeJob) ResetMiddlewares ¶ added in v0.9.0
func (c *ComposeJob) ResetMiddlewares(ms ...Middleware)
func (*ComposeJob) Run ¶ added in v0.9.0
func (j *ComposeJob) Run(ctx *Context) error
func (*ComposeJob) Use ¶ added in v0.9.0
func (c *ComposeJob) 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" hash:"true"`
// contains filtered or unexported fields
}
func NewExecJob ¶
func (*ExecJob) Middlewares ¶
func (c *ExecJob) Middlewares() []Middleware
func (*ExecJob) ResetMiddlewares ¶ added in v0.9.0
func (c *ExecJob) ResetMiddlewares(ms ...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 `hash:"true"`
Environment []string `mapstructure:"environment" hash:"true"`
}
func NewLocalJob ¶
func NewLocalJob() *LocalJob
func (*LocalJob) Middlewares ¶
func (c *LocalJob) Middlewares() []Middleware
func (*LocalJob) ResetMiddlewares ¶ added in v0.9.0
func (c *LocalJob) ResetMiddlewares(ms ...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" hash:"true"`
// 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" hash:"true"`
TTY bool `default:"false" hash:"true"`
// 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" hash:"true"`
Pull string `default:"true" hash:"true"`
Image string `hash:"true"`
Network string `hash:"true"`
Hostname string `hash:"true"`
Entrypoint *string `hash:"true"`
Container string `hash:"true"`
Volume []string `hash:"true"`
VolumesFrom []string `gcfg:"volumes-from" mapstructure:"volumes-from," hash:"true"`
Environment []string `mapstructure:"environment" hash:"true"`
MaxRuntime time.Duration `gcfg:"max-runtime" mapstructure:"max-runtime"`
// contains filtered or unexported fields
}
func (*RunJob) Middlewares ¶
func (c *RunJob) Middlewares() []Middleware
func (*RunJob) ResetMiddlewares ¶ added in v0.9.0
func (c *RunJob) ResetMiddlewares(ms ...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" hash:"true"`
TTY bool `default:"false" hash:"true"`
// 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" hash:"true"`
Image string `hash:"true"`
Network string `hash:"true"`
MaxRuntime time.Duration `gcfg:"max-runtime" mapstructure:"max-runtime"`
}
func NewRunServiceJob ¶
func NewRunServiceJob(c *docker.Client) *RunServiceJob
func (*RunServiceJob) Hash ¶ added in v0.9.0
func (j *RunServiceJob) Hash() (string, error)
func (*RunServiceJob) Middlewares ¶
func (c *RunServiceJob) Middlewares() []Middleware
func (*RunServiceJob) ResetMiddlewares ¶ added in v0.9.0
func (c *RunServiceJob) ResetMiddlewares(ms ...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) ResetMiddlewares ¶ added in v0.9.0
func (c *Scheduler) ResetMiddlewares(ms ...Middleware)
func (*Scheduler) Use ¶
func (c *Scheduler) Use(ms ...Middleware)