joblevel

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 7 Imported by: 1

README

go-joblevel

Go Reference Build Status Go Report Card CodeFactor codecov

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deduplicate

func Deduplicate(values []string) []string

Deduplicate a slice of strings

func DurationContaining

func DurationContaining(d time.Duration, t time.Time) (fromTime, toTime time.Time)

Find durationg containing the given time

Types

type Job

type Job struct {
	// A unique identifier for the job that doesn't change often
	ID string

	// How often the job should be run; parsed from strings like "5m" "1h"
	// Should evenly divide the 24 hours in a day
	Frequency time.Duration
	// contains filtered or unexported fields
}

A job that needs to be scheduled during the day

func NewJob

func NewJob(id string) *Job

Create new Job with given ID

func (*Job) RunsPerDay

func (j *Job) RunsPerDay() int

Calculate the number of runs per day for a job

func (*Job) ScheduleJob

func (j *Job) ScheduleJob()

Set job start times based upon ID hash and frequency

func (*Job) StartsBetween

func (j *Job) StartsBetween(fromTime, toTime time.Time) (bool, error)

Determine whether a job is started between a range of times

func (Job) WithFrequency

func (j Job) WithFrequency(frequency interface{}) Job

type Jobs

type Jobs []Job

A slice of Jobs

func NewJobsFromCSV

func NewJobsFromCSV(r io.Reader) Jobs

Load Jobs from a CSV

func (Jobs) AllStarts

func (jobs Jobs) AllStarts() startDurations

Return all start durations for a given set of Jobs

func (Jobs) CSV

func (jobs Jobs) CSV(w io.Writer) error

Write a CSV of Jobs to the provided io.Writer

func (Jobs) IDs

func (jobs Jobs) IDs() []string

Return the IDs for the provided jobs

func (Jobs) ScheduleCSV

func (jobs Jobs) ScheduleCSV(w io.Writer)

Write CSV of Job start IDs and starts with one line per job start duration

func (Jobs) ScheduleJobs

func (jobs Jobs) ScheduleJobs()

Set start times for each job

func (Jobs) ScheduledStartRecords

func (jobs Jobs) ScheduledStartRecords() [][]string

Returns a record for each start time of each Job

func (Jobs) StartingBetween

func (jobs Jobs) StartingBetween(fromTime, toTime time.Time) Jobs

Filter jobs to those that start between the given times

func (Jobs) StartingDuringDuration

func (jobs Jobs) StartingDuringDuration(t time.Time, d time.Duration) Jobs

Filters jobs to those starting during the rounded duration containing the given time For instance, setting 12:07pm and a 1 hour duration returns jobs between noon and 1pm

Directories

Path Synopsis
examples
simple Module

Jump to

Keyboard shortcuts

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