job

package
v1.0.685 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 13

Documentation

Index

Constants

View Source
const (
	ResourceTypeCheckStatuses = "check_statuses"
	ResourceTypeComponent     = "components"
	ResourceTypePlaybook      = "playbook"
	ResourceTypeScraper       = "config_scraper"
	ResourceTypeUpstream      = "upstream"
)

Variables

View Source
var (
	EvictedJobs chan uuid.UUID
)
View Source
var RetentionBalanced = Retention{
	Success: 3,
	Failed:  3,
}
View Source
var RetentionFailed = Retention{
	Success: 0,
	Failed:  3,
}
View Source
var RetentionFew = Retention{
	Success: 1,
	Failed:  3,
}
View Source
var RetentionHigh = Retention{
	Success: 3,
	Failed:  6,
}

Functions

func AggregateCheckStatus1d added in v1.0.245

func AggregateCheckStatus1d(ctx context.Context) (int, error)

func AggregateCheckStatus1h added in v1.0.245

func AggregateCheckStatus1h(ctx context.Context) (int, error)

func CleanupSoftDeletedComponents added in v1.0.267

func CleanupSoftDeletedComponents(ctx context.Context, olderThan time.Duration) (int, error)

func CleanupStaleAgentHistory added in v1.0.518

func CleanupStaleAgentHistory(ctx context.Context, itemsToRetain int) (int, error)

func CleanupStaleHistory added in v1.0.445

func CleanupStaleHistory(ctx context.Context, age time.Duration, name, resourceID string, statuses ...string) (int, error)

func CleanupStaleRunningHistory added in v1.0.446

func CleanupStaleRunningHistory(ctx context.Context, age time.Duration) (int, error)

func CronDetailsHandler added in v1.0.502

func CronDetailsHandler(crons ...*cron.Cron) func(c echo.Context) error

func DeleteOldCheckStatuses added in v1.0.245

func DeleteOldCheckStatuses(ctx context.Context, retention int) (int, error)

func DeleteOldCheckStatuses1d added in v1.0.245

func DeleteOldCheckStatuses1d(ctx context.Context, retention int) (int, error)

func DeleteOldCheckStatuses1h added in v1.0.245

func DeleteOldCheckStatuses1h(ctx context.Context, retention int) (int, error)

func RefreshCheckSizeSummary added in v1.0.440

func RefreshCheckSizeSummary(ctx context.Context) error

func RefreshCheckStatusSummary added in v1.0.245

func RefreshCheckStatusSummary(ctx context.Context) error

func RefreshCheckStatusSummaryAged added in v1.0.245

func RefreshCheckStatusSummaryAged(ctx context.Context) error

func RefreshConfigItemAnalysisChangeCount30d added in v1.0.666

func RefreshConfigItemAnalysisChangeCount30d(ctx context.Context) error

func RefreshConfigItemAnalysisChangeCount7d added in v1.0.666

func RefreshConfigItemAnalysisChangeCount7d(ctx context.Context) error

func StartJobHistoryEvictor added in v1.0.668

func StartJobHistoryEvictor(ctx context.Context)

Types

type Job added in v1.0.202

type Job struct {
	context.Context
	Name                     string
	Schedule                 string
	Singleton                bool
	Debug, Trace             bool
	Timeout                  time.Duration
	Fn                       func(ctx JobRuntime) error
	JobHistory               bool
	RunNow                   bool
	ID                       string
	ResourceID, ResourceType string
	IgnoreSuccessHistory     bool

	Retention Retention
	LastJob   *models.JobHistory

	// Semaphores control concurrent execution of related jobs.
	// They are acquired sequentially and released in reverse order.
	// Hence, they should be ordered from most specific to most general
	// so broader locks are held for the least amount of time.
	// The job is responsible in providing the semaphores in the correct order.
	Semaphores []*semaphore.Weighted
	// contains filtered or unexported fields
}

func NewJob

func NewJob(ctx context.Context, name string, schedule string, fn func(ctx JobRuntime) error) *Job

func (*Job) AddToScheduler added in v1.0.202

func (j *Job) AddToScheduler(cronRunner *cron.Cron) error

func (*Job) FindHistory added in v1.0.250

func (j *Job) FindHistory(statuses ...string) ([]models.JobHistory, error)

func (*Job) GetContext added in v1.0.577

func (j *Job) GetContext() map[string]any

func (*Job) GetEntry added in v1.0.202

func (j *Job) GetEntry(cronRunner *cron.Cron) *cron.Entry

func (*Job) GetProperty added in v1.0.548

func (j *Job) GetProperty(property string) (string, bool)

func (*Job) GetPropertyInt added in v1.0.564

func (j *Job) GetPropertyInt(property string, def int) int

func (*Job) GetResourcedName added in v1.0.418

func (j *Job) GetResourcedName() string

func (*Job) Label added in v1.0.307

func (j *Job) Label() string

func (*Job) PK added in v1.0.607

func (j *Job) PK() string

func (*Job) RemoveFromScheduler added in v1.0.202

func (j *Job) RemoveFromScheduler(cronRunner *cron.Cron)

func (*Job) Reschedule added in v1.0.307

func (j *Job) Reschedule(schedule string, cronRunner *cron.Cron) error

func (*Job) Retain added in v1.0.265

func (j *Job) Retain(r Retention) *Job

func (*Job) Run added in v1.0.202

func (j *Job) Run()

func (*Job) RunOnStart added in v1.0.202

func (j *Job) RunOnStart() *Job

func (*Job) SetID added in v1.0.202

func (j *Job) SetID(id string) *Job

func (*Job) SetTimeout added in v1.0.202

func (j *Job) SetTimeout(t time.Duration) *Job

func (*Job) String added in v1.0.250

func (j *Job) String() string

func (*Job) Unschedule added in v1.0.245

func (j *Job) Unschedule()

type JobCronEntry added in v1.0.502

type JobCronEntry struct {
	ID           string    `json:"id"`
	Name         string    `json:"name"`
	Schedule     string    `json:"schedule"`
	ResourceID   string    `json:"resource_id,omitempty"`
	ResourceType string    `json:"resource_type,omitempty"`
	LastRan      time.Time `json:"last_ran,omitempty"`
	NextRun      time.Time `json:"next_run"`
	NextRunIn    string    `json:"next_run_in"`
}

type JobRuntime

type JobRuntime struct {
	context.Context
	Job       *Job
	Span      trace.Span
	History   *models.JobHistory
	Table, Id string
	// contains filtered or unexported fields
}

func New added in v1.0.564

func New(ctx context.Context) JobRuntime

func (*JobRuntime) Failf added in v1.0.245

func (j *JobRuntime) Failf(message string, args ...interface{})

func (*JobRuntime) ID added in v1.0.250

func (j *JobRuntime) ID() string

func (*JobRuntime) Skipped added in v1.0.614

func (j *JobRuntime) Skipped(msg string)

func (*JobRuntime) VerboseDB added in v1.0.607

func (j *JobRuntime) VerboseDB() *gorm.DB

type Retention added in v1.0.250

type Retention struct {
	// Success is the number of success job history to retain
	Success int

	// Failed is the number of unsuccessful job history to retain
	Failed int
}

func (Retention) Count added in v1.0.325

func (r Retention) Count(status string) int

func (Retention) Empty added in v1.0.415

func (r Retention) Empty() bool

func (Retention) String added in v1.0.250

func (r Retention) String() string

type StatusRing added in v1.0.325

type StatusRing struct {
	// contains filtered or unexported fields
}

func NewStatusRing added in v1.0.608

func NewStatusRing(r Retention, singleton bool, evicted chan uuid.UUID) StatusRing

func (*StatusRing) Add added in v1.0.325

func (sr *StatusRing) Add(job *models.JobHistory)

Jump to

Keyboard shortcuts

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