sched

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DailyType    = "daily"
	MonthlyType  = "monthly"
	WeeklyType   = "weekly"
	PeriodicType = "periodic"

	MonthlyRetain = 12
	WeeklyRetain  = 5
	DailyRetain   = 7
)

Variables

View Source
var ParseCLI = map[string]func(string) (RetainIntervalSpec, error){
	DailyType:   parseDaily,
	WeeklyType:  parseWeekly,
	MonthlyType: parseMonthly,
}

Functions

func IntervalType

func IntervalType(interval Interval) string

func IsIntervalType

func IsIntervalType(t string) bool

func ParseScheduleAndPolicies

func ParseScheduleAndPolicies(scheduleString string) (
	[]RetainInterval,
	*PolicyTags,
	error,
)

func SamePolicyTags

func SamePolicyTags(p1, p2 *PolicyTags) bool

func ScheduleIntervalSummary

func ScheduleIntervalSummary(items []Interval, policyTags *PolicyTags) string

func ScheduleString

func ScheduleString(items []RetainIntervalSpec, p *PolicyTags) (string, error)

func ScheduleStringRetainInv

func ScheduleStringRetainInv(
	intvs []RetainInterval,
	p *PolicyTags,
) (string, error)

func ScheduleSummary

func ScheduleSummary(items []RetainInterval, policyTags *PolicyTags) string

func SpeedUp

func SpeedUp()

SpeedUp advances teh clock faster for tests.

Types

type Interval

type Interval interface {
	String() string
	IntervalType() string
	Spec() IntervalSpec
	// contains filtered or unexported methods
}

func Daily

func Daily(hour int, minute int) Interval

func Monthly

func Monthly(day int, hour int, minute int) Interval

func Periodic

func Periodic(period time.Duration) Interval

func Weekly

func Weekly(dow time.Weekday, hour int, minute int) Interval

type IntervalSpec

type IntervalSpec struct {
	Freq    string
	Period  uint64 `yaml:"period,omitempty"`
	Month   int    `yaml:"month,omitempty"`
	Weekday int    `yaml:"weekday,omitempty"`
	Day     int    `yaml:"day,omitempty"`
	Hour    int    `yaml:"hour,omitempty"`
	Minute  int    `yaml:"minute,omitempty"`
}

type PolicyTags

type PolicyTags struct {
	// Names is the list of policy names
	Names []string
}

PolicyTags groups one or more policies together.

func NewPolicyTags

func NewPolicyTags(policies string) (*PolicyTags, error)

func NewPolicyTagsFromSlice

func NewPolicyTagsFromSlice(policies []string) (*PolicyTags, error)

NewPolicyTagsFromSlice returns a new object from a string slice of names

func ParsePolicyTags

func ParsePolicyTags(policyTagsStr string) (*PolicyTags, error)

func (*PolicyTags) String

func (p *PolicyTags) String() string

func (*PolicyTags) Summary

func (p *PolicyTags) Summary() string

type RetainInterval

type RetainInterval interface {
	Interval
	// RetainNumber is the number of instances to retain
	RetainNumber() uint32
	// RetainIntervalSpec returns RetainIntervalSpec
	RetainIntervalSpec() RetainIntervalSpec
}

RetainInterval is a schedule interval with a number of instances to retain.

func NewRetainInterval

func NewRetainInterval(iv Interval) RetainInterval

func ParseSchedule

func ParseSchedule(schedule string) ([]RetainInterval, error)

func SetupIntvWithDefaults

func SetupIntvWithDefaults(intvs []RetainInterval) []RetainInterval

type RetainIntervalImpl

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

RetainIntervalImpl implements the RetainInterval interface

func (RetainIntervalImpl) IntervalType

func (p RetainIntervalImpl) IntervalType() string

func (RetainIntervalImpl) RetainIntervalSpec

func (p RetainIntervalImpl) RetainIntervalSpec() RetainIntervalSpec

func (RetainIntervalImpl) RetainNumber

func (p RetainIntervalImpl) RetainNumber() uint32

func (RetainIntervalImpl) Spec

func (RetainIntervalImpl) String

func (p RetainIntervalImpl) String() string

type RetainIntervalSpec

type RetainIntervalSpec struct {
	IntervalSpec `yaml:",inline"`
	Retain       uint32 `yaml:"retain,omitempty"`
}

RetainIntervalSpec is the serialized form of retain interval

func ParsePeriodic

func ParsePeriodic(input string) (RetainIntervalSpec, error)

Jump to

Keyboard shortcuts

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