コード例 #1
0
ファイル: overlap.go プロジェクト: mcuadros/ofelia
// Run stops the execution if the another execution is already running
func (m *Overlap) Run(ctx *core.Context) error {
	if m.NoOverlap && ctx.Job.Running() > 1 {
		ctx.Stop(core.ErrSkippedExecution)
	}

	return ctx.Next()
}
コード例 #2
0
ファイル: slack.go プロジェクト: ivanfoo/ofelia
// Run sends a message to the slack channel, its close stop the exection to
// collect the metrics
func (m *Slack) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.SlackOnlyOnError {
		m.pushMessage(ctx)
	}

	return err
}
コード例 #3
0
ファイル: save.go プロジェクト: mcuadros/ofelia
// Run save the result of the execution to disk
func (m *Save) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.SaveOnlyOnError {
		err := m.saveToDisk(ctx)
		if err != nil {
			ctx.Logger.Errorf("Save error: %q", err)
		}
	}

	return err
}
コード例 #4
0
ファイル: mail.go プロジェクト: ivanfoo/ofelia
// Run sents a email with the result of the execution
func (m *Mail) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.MailOnlyOnError {
		err := m.sendMail(ctx)
		if err != nil {
			ctx.Logger.Error("Mail error: %q", err)
		}
	}

	return err
}