job

package
v0.0.0-...-f5bf215 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package job provides an http handler to serve up jobs to ETL parsers.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidDateConfig = errors.New("invalid source date configuration")

ErrInvalidDateConfig is returned if both DailyOnly and FullHistory are true for a source. Only one of these options can be true.

View Source
var ErrInvalidStartDate = errors.New("invalid start date")

ErrInvalidStartDate is returned if startDate is time.Time{}

View Source
var ErrMoreJSON = errors.New("JSON body not completely consumed")

ErrMoreJSON is returned when response from gardener has unknown fields.

View Source
var ErrNoConfiguredJobs = errors.New("no configured jobs")

ErrNoConfiguredJobs is returned when a new Job Service cannot be created because there are no configured jobs.

View Source
var (
	// ErrNoDateAvailable is returned if a DateIterator does not have a date available.
	ErrNoDateAvailable = errors.New("no date is available")
)

Functions

This section is empty.

Types

type DailyIterator

type DailyIterator struct {
	Date time.Time // The next date to process.
	// contains filtered or unexported fields
}

DailyIterator tracks state and dates for "daily" processing events.

func NewDailyIterator

func NewDailyIterator(delay time.Duration, saver namedSaver) *DailyIterator

NewDailyIterator creates a new DailyIterator. The delay is an additional offset after UTC midnight before the next Date is processed. The starting Date will be yesterday or the date successfully loaded from the given saver.

func (*DailyIterator) Next

func (d *DailyIterator) Next() (time.Time, error)

Next returns the next "daily" date. Until 'delay' after UTC midnight, Next will return ErrNoDateAvailable. If err is nil, then the returned time is the next daily date. The current date is saved before every update.

type DateIterator

type DateIterator interface {
	Next() (time.Time, error)
}

DateIterator defines the interface common to the Daily and Historical iterators.

DateIterator implementations should prioritize process continuity and reliability after restart. For example, the sequence of operations should roughly follow: filter, save, read, update, return. By saving the current date before updating, we ensure that a mid-process restart would pickup where it left off, possibly at the expense of some reprocessing, but with assurance that no date data was skipped.

type HistoricalIterator

type HistoricalIterator struct {
	Date time.Time // The next date to process.
	// contains filtered or unexported fields
}

HistoricalIterator tracks state and dates for "historical" processing events.

func NewHistoricalIterator

func NewHistoricalIterator(start time.Time, saver namedSaver) *HistoricalIterator

NewHistoricalIterator creates a new HistoricalIterator. The iterator will begin from the given start unless a different date is successfully loaded from the given saver. The returned HistoricalIterator.Date is guaranteed to be later or equal to the start date.

func (*HistoricalIterator) Next

func (h *HistoricalIterator) Next() (time.Time, error)

Next returns the next "historical" date. If this date is within 36h of current, real world date, then the historical cycle restarts. The current date is saved before every update.

type JobIterator

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

JobIterator iterates over Job configurations for an underlying DateIterator sequence.

func NewJobIterator

func NewJobIterator(date DateIterator, jobSpecs []tracker.JobWithTarget) *JobIterator

NewJobIterator creates a new JobIterator. For every date returned by the DateIterator, the JobIterator will enumerate every jobSpec for that date before advancing to the next date.

func (*JobIterator) Len

func (j *JobIterator) Len() int

Len returns the number of Job specs.

func (*JobIterator) Next

func (j *JobIterator) Next() (*tracker.JobWithTarget, error)

Next returns the next JobWithTarget for the current date. Next may return an error when the underlying DateIterator returns an error, e.g. ErrNoDateAvailable.

type Service

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

Service contains all information needed to provide a job service. It iterates through successive dates, processing that date from all TypeSources in the source bucket.

func NewJobService

func NewJobService(startDate time.Time,
	sources []config.SourceConfig,
	statsClient stiface.Client,
	dailySaver namedSaver,
	histSaver namedSaver,
) (*Service, error)

NewJobService creates the default job service.

func (*Service) NextJob

func (svc *Service) NextJob(ctx context.Context) *tracker.JobWithTarget

NextJob returns a tracker.Job to dispatch.

Jump to

Keyboard shortcuts

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