job

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog interface {
	Add(job Job) error
	AddResult(result Result)
	All() map[uuid.UUID]Job
	AllResults() map[uuid.UUID][]Result
	Count() int
	CountResults(uuid uuid.UUID) int
	Delete(uuid uuid.UUID) error
	Get(uuid uuid.UUID) (Job, error)
	GetNotSchedulable() []Job
	GetSchedulable() []Job
	GetResults(uuid uuid.UUID) ([]Result, error)
	Statistics() CatalogStatistics
	Update(job Job) error
}

type CatalogStatistics

type CatalogStatistics struct {
	Count         int
	EnabledCount  int
	DisabledCount int
	ResultCount   int
}

type Job

type Job struct {
	Uuid             uuid.UUID
	Name             string
	Schedule         cron.Schedule
	Enabled          bool
	LimitConcurrency bool
	MaxConcurrency   int
	LimitRuns        bool
	MaxRuns          int
	Tasks            []task.Task
}

func New

func New(uuid uuid.UUID, name string, schedule cron.Schedule, tasks []task.Task, opts ...Option) Job

func (*Job) Disable

func (j *Job) Disable()

func (*Job) Enable

func (j *Job) Enable()

func (*Job) LogAttrs

func (j *Job) LogAttrs() []slog.Attr

func (*Job) LogValue

func (j *Job) LogValue() slog.Value

type MemoryCatalog

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

func NewMemoryCatalog

func NewMemoryCatalog() *MemoryCatalog

func (*MemoryCatalog) Add

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

func (*MemoryCatalog) AddResult

func (c *MemoryCatalog) AddResult(result Result)

func (*MemoryCatalog) All

func (c *MemoryCatalog) All() map[uuid.UUID]Job

func (*MemoryCatalog) AllResults

func (c *MemoryCatalog) AllResults() map[uuid.UUID][]Result

func (*MemoryCatalog) Count

func (c *MemoryCatalog) Count() int

func (*MemoryCatalog) CountResults added in v0.1.2

func (c *MemoryCatalog) CountResults(uuid uuid.UUID) int

func (*MemoryCatalog) Delete

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

func (*MemoryCatalog) Get

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

func (*MemoryCatalog) GetNotSchedulable added in v0.1.2

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

func (*MemoryCatalog) GetResults

func (c *MemoryCatalog) GetResults(uuid uuid.UUID) ([]Result, error)

func (*MemoryCatalog) GetSchedulable added in v0.1.2

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

func (*MemoryCatalog) Statistics

func (c *MemoryCatalog) Statistics() CatalogStatistics

func (*MemoryCatalog) Update

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

type Option

type Option func(*Job)

func WithConcurrencyLimit

func WithConcurrencyLimit(limit int) Option

func WithDisabled

func WithDisabled() Option

func WithRunLimit

func WithRunLimit(limit int) Option

type Result

type Result struct {
	Uuid        uuid.UUID
	RunUuid     uuid.UUID
	TriggerTime time.Time
	RunTime     time.Duration
	TaskResults []task.Result
	Error       error
}

Jump to

Keyboard shortcuts

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