job

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ErrKindNotFound errKind = iota
	ErrKindExist
)

Variables

View Source
var (
	ErrNotFound = Error{/* contains filtered or unexported fields */}
	ErrExist    = Error{/* contains filtered or unexported fields */}
)

Functions

This section is empty.

Types

type Catalog added in v0.1.5

type Catalog interface {
	Add(job Job) error
	All() []Job
	AvailableJobs() []Job
	Delete(jobId uuid.UUID) error
	Disable(jobId uuid.UUID) error
	Enable(jobId uuid.UUID) error
	HasEnabledJobs() bool
	InactiveJobs() []Job
	PendingJobs() []Job
	RunnableJobs() []Job
	SchedulableJobs() []Job
	Update(job Job) error
}

type Error added in v0.1.5

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

func NewError added in v0.1.5

func NewError(kind errKind, err error) Error

func (Error) Error added in v0.1.5

func (e Error) Error() string

type GlobalStats added in v0.1.5

type GlobalStats struct {
	ConfiguredJobs  float64
	EnabledJobs     float64
	DisabledJobs    float64
	InactiveJobs    float64
	AvailableJobs   float64
	SchedulableJobs float64
	RunnableJobs    float64
	PendingJobs     float64
	ActiveJobs      float64
	RunningJobs     float64
	CompletedTasks  float64
	TotalTasks      float64
}

type Job

type Job struct {
	Uuid     uuid.UUID
	Name     string
	Enabled  bool
	Schedule cron.Schedule
	MaxRuns  int
	Status   Status
	Tasks    Sequence
	History  []Result
	// contains filtered or unexported fields
}

func NewJob added in v0.1.5

func NewJob(name string, s cron.Schedule, maxRuns int, tasks Sequence) Job

func (*Job) AddResult added in v0.1.5

func (j *Job) AddResult(r Result)

func (*Job) AllResults added in v0.1.5

func (j *Job) AllResults() []Result

func (*Job) CountRuns added in v0.1.5

func (j *Job) CountRuns() int

func (*Job) CurrentResult added in v0.1.5

func (j *Job) CurrentResult() Result

func (*Job) Disable added in v0.1.5

func (j *Job) Disable()

func (*Job) Enable added in v0.1.5

func (j *Job) Enable()

func (*Job) IsActive added in v0.1.5

func (j *Job) IsActive() bool

func (*Job) IsAvailable added in v0.1.5

func (j *Job) IsAvailable() bool

func (*Job) IsEligible added in v0.1.5

func (j *Job) IsEligible() bool

func (*Job) IsEnabled added in v0.1.5

func (j *Job) IsEnabled() bool

func (*Job) IsInactive added in v0.1.5

func (j *Job) IsInactive() bool

func (*Job) IsPending

func (j *Job) IsPending() bool

func (*Job) IsRunnable added in v0.1.5

func (j *Job) IsRunnable() bool

func (*Job) IsSchedulable added in v0.1.5

func (j *Job) IsSchedulable() bool

func (*Job) SetStatus

func (j *Job) SetStatus(s Status)

func (*Job) UpdateResult added in v0.1.5

func (j *Job) UpdateResult(r Result)

type MemoryCatalog

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

func NewMemoryCatalog

func NewMemoryCatalog() *MemoryCatalog

func (*MemoryCatalog) Add added in v0.1.5

func (c *MemoryCatalog) Add(job Job) error

func (*MemoryCatalog) All added in v0.1.5

func (c *MemoryCatalog) All() []Job

func (*MemoryCatalog) AvailableJobs added in v0.1.5

func (c *MemoryCatalog) AvailableJobs() []Job

func (*MemoryCatalog) Count added in v0.1.5

func (c *MemoryCatalog) Count() int

func (*MemoryCatalog) Delete added in v0.1.5

func (c *MemoryCatalog) Delete(jobId uuid.UUID) error

func (*MemoryCatalog) Disable added in v0.1.5

func (c *MemoryCatalog) Disable(jobId uuid.UUID) error

func (*MemoryCatalog) Enable added in v0.1.5

func (c *MemoryCatalog) Enable(jobId uuid.UUID) error

func (*MemoryCatalog) Exists added in v0.1.5

func (c *MemoryCatalog) Exists(id uuid.UUID) bool

func (*MemoryCatalog) Get added in v0.1.5

func (c *MemoryCatalog) Get(id uuid.UUID) (Job, error)

func (*MemoryCatalog) GetJobsByStatus added in v0.1.5

func (c *MemoryCatalog) GetJobsByStatus(status Status) []Job

func (*MemoryCatalog) HasEnabledJobs added in v0.1.5

func (c *MemoryCatalog) HasEnabledJobs() bool

func (*MemoryCatalog) InactiveJobs added in v0.1.5

func (c *MemoryCatalog) InactiveJobs() []Job

func (*MemoryCatalog) PendingJobs added in v0.1.5

func (c *MemoryCatalog) PendingJobs() []Job

func (*MemoryCatalog) RunnableJobs added in v0.1.5

func (c *MemoryCatalog) RunnableJobs() []Job

func (*MemoryCatalog) SchedulableJobs added in v0.1.5

func (c *MemoryCatalog) SchedulableJobs() []Job

func (*MemoryCatalog) Update added in v0.1.5

func (c *MemoryCatalog) Update(job Job) error

type Orchestrator

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

func NewOrchestrator

func NewOrchestrator(catalog Catalog, taskHandlers *task.HandlerRepository, config OrchestratorConfig) *Orchestrator

func (*Orchestrator) IsStarted added in v0.1.5

func (o *Orchestrator) IsStarted() bool

func (*Orchestrator) Start added in v0.1.5

func (o *Orchestrator) Start(ctx context.Context)

func (*Orchestrator) Statistics added in v0.1.5

func (o *Orchestrator) Statistics() OrchestratorStats

type OrchestratorConfig

type OrchestratorConfig struct {
	MaxJobs          int
	ScheduleInterval time.Duration // milliseconds
	StartDelay       time.Duration
	ErrorHandler     func(err error)
	MessageHandler   func(msg task.IntercomMessage)
}

func NewOrchestratorConfig

func NewOrchestratorConfig(maxJobs int, delay int, interval int, errF func(err error), msgF func(msg task.IntercomMessage)) (OrchestratorConfig, error)

type OrchestratorStats added in v0.1.5

type OrchestratorStats struct {
	Job   GlobalStats
	Tasks []TaskStats
}

func (OrchestratorStats) HasTaskErrors added in v0.1.5

func (o OrchestratorStats) HasTaskErrors() bool

func (OrchestratorStats) TasksCompleted added in v0.1.5

func (o OrchestratorStats) TasksCompleted() float64

func (OrchestratorStats) TasksTotal added in v0.1.5

func (o OrchestratorStats) TasksTotal() float64

type Result added in v0.1.5

type Result struct {
	Start    time.Time
	Finish   time.Time
	Status   Status
	Messages []task.Message
	Tasks    []task.Task
}

func (Result) Runtime added in v0.1.5

func (r Result) Runtime() time.Duration

type Sequence added in v0.1.5

type Sequence struct {
	Tasks []task.Task
	// contains filtered or unexported fields
}

func NewSequence added in v0.1.5

func NewSequence(tasks []task.Task) Sequence

func (*Sequence) ActiveIndex added in v0.1.5

func (s *Sequence) ActiveIndex() int

func (*Sequence) ActiveTask added in v0.1.5

func (s *Sequence) ActiveTask() task.Task

func (*Sequence) All added in v0.1.5

func (s *Sequence) All() []task.Task

func (*Sequence) Count added in v0.1.5

func (s *Sequence) Count() int

func (*Sequence) CountExecuted added in v0.1.5

func (s *Sequence) CountExecuted() int

func (*Sequence) Executed added in v0.1.5

func (s *Sequence) Executed() []task.Task

func (*Sequence) IsActive added in v0.1.5

func (s *Sequence) IsActive() bool

func (*Sequence) RegisterTask added in v0.1.5

func (s *Sequence) RegisterTask(t task.Task)

func (*Sequence) RegisterTasks added in v0.1.5

func (s *Sequence) RegisterTasks(t []task.Task)

func (*Sequence) ResetHistory added in v0.1.5

func (s *Sequence) ResetHistory()

type Status

type Status int
const (
	StatusNone Status = iota
	StatusInactive
	StatusAvailable
	StatusSchedulable
	StatusRunnable
	StatusPending
	StatusActive
	StatusCompleted
	StatusError
)

func (Status) String

func (s Status) String() string

type TaskStats added in v0.1.5

type TaskStats struct {
	Uuid      uuid.UUID
	Name      string
	Completed float64
	Total     float64
	HasErrors bool
}

Jump to

Keyboard shortcuts

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