job

package
v0.0.0-...-2af02f3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 346

Documentation

Index

Constants

View Source
const (
	// ImageScanJob is name of scan job it will be used as key to register to job service.
	ImageScanJob = "IMAGE_SCAN"
	// ImageScanAllJob is the name of "scanall" job in job service
	ImageScanAllJob = "IMAGE_SCAN_ALL"
	// ImageGC the name of image garbage collection job in job service
	ImageGC = "IMAGE_GC"
	// ImageGCReadOnly the name of image garbage collection read only job in job service
	ImageGCReadOnly = "IMAGE_GC_READ_ONLY"
	// JobKindGeneric : Kind of generic job
	JobKindGeneric = "Generic"
	// JobKindScheduled : Kind of scheduled job
	JobKindScheduled = "Scheduled"
	// JobKindPeriodic : Kind of periodic job
	JobKindPeriodic = "Periodic"

	// JobServiceStatusPending   : job status pending
	JobServiceStatusPending = "Pending"
	// JobServiceStatusRunning   : job status running
	JobServiceStatusRunning = "Running"
	// JobServiceStatusStopped   : job status stopped
	JobServiceStatusStopped = "Stopped"
	// JobServiceStatusCancelled : job status cancelled
	JobServiceStatusCancelled = "Cancelled"
	// JobServiceStatusError     : job status error
	JobServiceStatusError = "Error"
	// JobServiceStatusSuccess   : job status success
	JobServiceStatusSuccess = "Success"
	// JobServiceStatusScheduled : job status scheduled
	JobServiceStatusScheduled = "Scheduled"

	// JobActionStop : the action to stop the job
	JobActionStop = "stop"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	SubmitJob(*models.JobData) (string, error)
	GetJobLog(uuid string) ([]byte, error)
	PostAction(uuid, action string) error
	GetExecutions(uuid string) ([]job.Stats, error)
	// TODO Redirect joblog when we see there's memory issue.
	// GetJobServiceConfig retrieves the job config
	GetJobServiceConfig() (*job.Config, error)
}

Client wraps interface to access jobservice.

var (
	// GlobalClient is an instance of the default client that can be used globally
	GlobalClient Client = NewDefaultClient(config.InternalJobServiceURL(), config.CoreSecret())

	// ErrJobNotFound indicates the job not found
	ErrJobNotFound = errors.New("job not found")
)

type DefaultClient

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

DefaultClient is the default implementation of Client interface

func NewDefaultClient

func NewDefaultClient(endpoint, secret string) *DefaultClient

NewDefaultClient creates a default client based on endpoint and secret.

func NewReplicationClient

func NewReplicationClient(endpoint, secret string) *DefaultClient

NewReplicationClient used to create a client for replication

func (*DefaultClient) GetExecutions

func (d *DefaultClient) GetExecutions(periodicJobID string) ([]job.Stats, error)

GetExecutions ...

func (*DefaultClient) GetJobLog

func (d *DefaultClient) GetJobLog(uuid string) ([]byte, error)

GetJobLog call jobserivce API to get the log of a job. It only accepts the UUID of the job

func (*DefaultClient) GetJobServiceConfig

func (d *DefaultClient) GetJobServiceConfig() (*job.Config, error)

GetJobServiceConfig retrieves the job service configuration

func (*DefaultClient) PostAction

func (d *DefaultClient) PostAction(uuid, action string) error

PostAction call jobservice's API to operate action for job specified by uuid

func (*DefaultClient) SubmitJob

func (d *DefaultClient) SubmitJob(jd *models.JobData) (string, error)

SubmitJob call jobservice API to submit a job and returns the job's UUID.

type ScanJobParms

type ScanJobParms struct {
	JobID      int64  `json:"job_int_id"`
	Repository string `json:"repository"`
	Tag        string `json:"tag"`
	Digest     string `json:"digest"`
}

ScanJobParms holds parameters used to submit jobs to jobservice

type StatusBehindError

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

StatusBehindError represents the error got when trying to stop a success/failed job

func (*StatusBehindError) Error

func (s *StatusBehindError) Error() string

Error returns the detail message about the error

func (*StatusBehindError) Status

func (s *StatusBehindError) Status() string

Status returns the current status of the job

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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