jobs

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	// Run the job
	Run() error
}

type JobDb

type JobDb struct {
	Database string
}

func (*JobDb) GetJobRunLogRepository

func (j *JobDb) GetJobRunLogRepository() *JobRunLogRepository

type JobManager

type JobManager struct {
	// Job db
	JobDb JobDb

	// Job Details
	JobDetails []jobDetail
	// contains filtered or unexported fields
}

Job Manager

func NewJobManager

func NewJobManager(database string) *JobManager

Global job manager

func (*JobManager) RegisterJob

func (j *JobManager) RegisterJob(name string, duration time.Duration, job Job)

Add job

func (*JobManager) Start

func (j *JobManager) Start()

Start method to start the registered jobs

func (*JobManager) Stop

func (j *JobManager) Stop()

Stop method to signal the registered jobs to stop

type JobRunLogModel

type JobRunLogModel struct {
	// Job name
	Name string `bson:"name"`
	// Last execution date time in format dd-MMM-yyyy HH:mm:ss
	LastExecutionDateTime string `bson:"lastExecutionDateTime"`

	// Last execution status
	LastExecutionStatus JobStatus `bson:"lastExecutionStatus"`
	// Last execution message
	LastExecutionMessage string `bson:"lastExecutionMessage"`

	// Last execution duration
	LastExecutionDuration time.Duration `bson:"lastExecutionDuration"`
}

func (*JobRunLogModel) Id

func (j *JobRunLogModel) Id() string

type JobRunLogRepository

type JobRunLogRepository struct {
	odm.UnimplementedBootRepository[JobRunLogModel]
}

func (*JobRunLogRepository) IsRunning

func (j *JobRunLogRepository) IsRunning(id string) chan bool

func (*JobRunLogRepository) MarkJob

func (j *JobRunLogRepository) MarkJob(id, message string, status JobStatus) chan error

type JobStatus

type JobStatus string

Job status is used for both synchronization and monitoring. Before a job executes, it must check for status. If job is already running, it must not execute.

const (
	JobStatusScheduled JobStatus = "Scheduled"
	JobStatusRunning   JobStatus = "Running"
	JobStatusFailed    JobStatus = "Failed"
	JobStatusStopped   JobStatus = "Stopped"
)

Jump to

Keyboard shortcuts

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