scheduler

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandlerFunc

func NewHandlerFunc(target Target) func()

NewHandlerFunc creates a new handler function based on the target in the Handler struct. This function calls the target and loads the data into the database through the core API.

Types

type Daemon

type Daemon struct {
	Targets []Target
}

Daemon is the primary API that the user uses to add targets and run call cycles on a continuous basis.

func (*Daemon) Register

func (d *Daemon) Register(t Target)

Register adds a Target implementation to the daemon's target registry.

func (Daemon) Run

func (d Daemon) Run()

Run adds tasks according to all registered Target implementations and starts the blocking call to the gocron API.

type Directive

type Directive struct {
	Prefix        string
	Configuration *core.Configuration
	Warehouse     core.Warehouse
}

Directive defines where data from a target should go according to a provided configuration and database.

type Schedule

type Schedule struct {
	Type   ScheduleType
	Window uint64
}

Schedule defines a call cycle schedule configuration to be consumed by the gocron API, returned by Target.Schedule.

type ScheduleType

type ScheduleType int

ScheduleType abstracts the available window type constants for call cycle scheduling.

const (
	Second ScheduleType = iota
	Minute
	Hour
	Day
	Week
)

Minute, Hour, Day, and Week constants are used by the daemon to determine how to schedule calls with the gocron API.

type Target

type Target interface {
	Label() string
	Flag() string
	Schedule() (*Schedule, error)
	Directive() (*Directive, error)
	Call() ([]utils.Header, [][]interface{}, error)
}

Target is the interface that user-defined data retrieval processes must abide by in order to be successfully consumed by the daemon.

Jump to

Keyboard shortcuts

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