Documentation
¶
Index ¶
- Constants
- func AddNotificationClients(job *Job, cfg *Config) error
- func Debugf(ctx context.Context, log logger.Log, format string, args ...interface{})
- func Error(ctx context.Context, log logger.Log, err error)
- func Errorf(ctx context.Context, log logger.Log, format string, args ...interface{})
- func Fatal(ctx context.Context, log logger.Log, err error)
- func Fatalf(ctx context.Context, log logger.Log, format string, args ...interface{})
- func Infof(ctx context.Context, log logger.Log, format string, args ...interface{})
- func NewEmailMessage(ji *cron.JobInvocation, options ...email.MessageOption) (email.Message, error)
- func NewManagementServer(jm *cron.JobManager, cfg *Config) *web.App
- func NewSlackMessage(ji *cron.JobInvocation, options ...slack.MessageOption) slack.Message
- func Warning(ctx context.Context, log logger.Log, err error)
- func Warningf(ctx context.Context, log logger.Log, format string, args ...interface{})
- func WithJobInvocationState(ctx context.Context, jis *JobInvocationState) context.Context
- type Config
- type Job
- func (job Job) Config() *JobConfig
- func (job *Job) Description() string
- func (job Job) Execute(ctx context.Context) error
- func (job Job) Name() string
- func (job Job) OnBroken(ctx context.Context)
- func (job Job) OnCancellation(ctx context.Context)
- func (job Job) OnComplete(ctx context.Context)
- func (job Job) OnDisabled(ctx context.Context)
- func (job Job) OnEnabled(ctx context.Context)
- func (job Job) OnFailure(ctx context.Context)
- func (job Job) OnFixed(ctx context.Context)
- func (job Job) OnStart(ctx context.Context)
- func (job Job) Schedule() cron.Schedule
- func (job Job) Timeout() time.Duration
- func (job *Job) WithConfig(cfg *JobConfig) *Job
- func (job *Job) WithDescription(description string) *Job
- func (job *Job) WithEmailClient(client email.Sender) *Job
- func (job *Job) WithErrorClient(client diagnostics.Notifier) *Job
- func (job *Job) WithLogger(log logger.FullReceiver) *Job
- func (job *Job) WithName(name string) *Job
- func (job *Job) WithSchedule(schedule cron.Schedule) *Job
- func (job *Job) WithSlackClient(client slack.Sender) *Job
- func (job *Job) WithStatsClient(client stats.Collector) *Job
- func (job *Job) WithTimeout(d time.Duration) *Job
- type JobConfig
- func (jc JobConfig) DescritionOrDefault() string
- func (jc JobConfig) NameOrDefault() string
- func (jc JobConfig) NotifyOnBrokenOrDefault() bool
- func (jc JobConfig) NotifyOnDisabledOrDefault() bool
- func (jc JobConfig) NotifyOnEnabledOrDefault() bool
- func (jc JobConfig) NotifyOnFailureOrDefault() bool
- func (jc JobConfig) NotifyOnFixedOrDefault() bool
- func (jc JobConfig) NotifyOnStartOrDefault() bool
- func (jc JobConfig) NotifyOnSuccessOrDefault() bool
- func (jc JobConfig) ScheduleOrDefault() string
- func (jc JobConfig) TimeoutOrDefault() time.Duration
- type JobInvocationState
Constants ¶
const ( // DefaultEmailMimeType is the default email mime type. DefaultEmailMimeType = "text/plain" // DefaultEmailSubjectTemplate is the default subject template. DefaultEmailSubjectTemplate = `{{.Var "jobName" }} :: {{ .Var "status" }}` // DefaultEmailHTMLBodyTemplate is the default email html body template. DefaultEmailHTMLBodyTemplate = `` /* 632-byte string literal not displayed */ // DefaultEmailTextBodyTemplate is the default body template. DefaultEmailTextBodyTemplate = `{{ .Var "jobName" }} {{ .Var "status" }} Elapsed: {{ .Var "elapsed" }} {{ if .HasVar "err" }}Error: {{ .Var "err" }}{{end}}` )
const (
DefaultMaxLogBytes = 10 * (1 << 10)
)
Constants and Defaults
Variables ¶
This section is empty.
Functions ¶
func AddNotificationClients ¶
AddNotificationClients adds notification clients to a given job.
func NewEmailMessage ¶
func NewEmailMessage(ji *cron.JobInvocation, options ...email.MessageOption) (email.Message, error)
NewEmailMessage returns a new email message.
func NewManagementServer ¶
func NewManagementServer(jm *cron.JobManager, cfg *Config) *web.App
NewManagementServer returns a new management server that lets you trigger jobs or look at job statuses via. a json api.
func NewSlackMessage ¶
func NewSlackMessage(ji *cron.JobInvocation, options ...slack.MessageOption) slack.Message
NewSlackMessage returns a new job started message.
func WithJobInvocationState ¶
func WithJobInvocationState(ctx context.Context, jis *JobInvocationState) context.Context
WithJobInvocationState sets the job invocation state on a context.
Types ¶
type Config ¶
type Config struct {
cron.Config `json:",inline" yaml:",inline"`
MaxLogBytes int `json:"maxLogBytes" yaml:"maxLogBytes"`
Logger logger.Config `json:"logger" yaml:"logger"`
Web web.Config `json:"web" yaml:"web"`
Airbrake airbrake.Config `json:"airbrake" yaml:"airbrake"`
AWS aws.Config `json:"aws" yaml:"aws"`
Email email.Message `json:"email" yaml:"email"`
Datadog datadog.Config `json:"datadog" yaml:"datadog"`
Slack slack.Config `json:"slack" yaml:"slack"`
}
Config is the jobkit config.
func (Config) MaxLogBytesOrDefault ¶
MaxLogBytesOrDefault is a the maximum amount of log data to buffer.
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is the main job body.
func (*Job) Description ¶
Description returns an optional description for the job.
func (Job) OnCancellation ¶
OnCancellation is a lifecycle event handler.
func (Job) OnComplete ¶
OnComplete is a lifecycle event handler.
func (Job) OnDisabled ¶
OnDisabled is a lifecycle event handler.
func (*Job) WithConfig ¶
WithConfig sets the config.
func (*Job) WithDescription ¶
WithDescription returns the job description.
func (*Job) WithEmailClient ¶
WithEmailClient sets the job email client.
func (*Job) WithErrorClient ¶
func (job *Job) WithErrorClient(client diagnostics.Notifier) *Job
WithErrorClient sets the job error client.
func (*Job) WithLogger ¶
func (job *Job) WithLogger(log logger.FullReceiver) *Job
WithLogger sets the job logger.
func (*Job) WithSchedule ¶
WithSchedule sets the schedule.
func (*Job) WithSlackClient ¶
WithSlackClient sets the job slack client.
func (*Job) WithStatsClient ¶
WithStatsClient sets the job stats client.
type JobConfig ¶
type JobConfig struct {
// Name is the name of the job.
Name string `json:"name" yaml:"name"`
// Description is a description of the job.
Description string `json:"description" yaml:"description"`
// Schedule returns the job schedule.
Schedule string `json:"schedule" yaml:"schedule"`
// Timeout represents the abort threshold for the job.
Timeout time.Duration `json:"timeout" yaml:"timeout"`
// NotifyOnStart governs if we should send notifications job start.
NotifyOnStart *bool `json:"notifyOnStart" yaml:"notifyOnStart"`
// NotifyOnSuccess governs if we should send notifications on any success.
NotifyOnSuccess *bool `json:"notifyOnSuccess" yaml:"notifyOnSuccess"`
// NotifyOnFailure governs if we should send notifications on any failure.
NotifyOnFailure *bool `json:"notifyOnFailure" yaml:"notifyOnFailure"`
// NotifyOnBroken governs if we should send notifications on a success => failure transition.
NotifyOnBroken *bool `json:"notifyOnBroken" yaml:"notifyOnBroken"`
// NotifyOnFixed governs if we should send notifications on a failure => success transition.
NotifyOnFixed *bool `json:"notifyOnFixed" yaml:"notifyOnFixed"`
// NotifyOnEnabled governs if we should send notifications when a job is enabled.
NotifyOnEnabled *bool `json:"notifyOnEnabled" yaml:"notifyOnEnabled"`
// NotifyOnDisabled governs if we should send notifications when a job is disabled.
NotifyOnDisabled *bool `json:"notifyOnDisabled" yaml:"notifyOnDisabled"`
}
JobConfig is something you can use to give your jobs some knobs to turn from configuration. You can use this job config by embedding it into your larger job config struct.
func (JobConfig) DescritionOrDefault ¶
DescritionOrDefault returns the job description if it's set.
func (JobConfig) NameOrDefault ¶
NameOrDefault returns the job name if it's set.
func (JobConfig) NotifyOnBrokenOrDefault ¶
NotifyOnBrokenOrDefault returns a value or a default.
func (JobConfig) NotifyOnDisabledOrDefault ¶
NotifyOnDisabledOrDefault returns a value or a default.
func (JobConfig) NotifyOnEnabledOrDefault ¶
NotifyOnEnabledOrDefault returns a value or a default.
func (JobConfig) NotifyOnFailureOrDefault ¶
NotifyOnFailureOrDefault returns a value or a default.
func (JobConfig) NotifyOnFixedOrDefault ¶
NotifyOnFixedOrDefault returns a value or a default.
func (JobConfig) NotifyOnStartOrDefault ¶
NotifyOnStartOrDefault returns a value or a default.
func (JobConfig) NotifyOnSuccessOrDefault ¶
NotifyOnSuccessOrDefault returns a value or a default.
func (JobConfig) ScheduleOrDefault ¶
ScheduleOrDefault returns the schedule or a default (every 5 minutes).
func (JobConfig) TimeoutOrDefault ¶
TimeoutOrDefault the job timeout or a default
type JobInvocationState ¶
JobInvocationState is the state object for a job invocation.
func GetJobInvocationState ¶
func GetJobInvocationState(ctx context.Context) *JobInvocationState
GetJobInvocationState returns the job invocation state.
func NewJobInvocationState ¶
func NewJobInvocationState() *JobInvocationState
NewJobInvocationState returns a new job invocation state.