retentiongrid

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const RetentionGridKeepCountAll int = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	Date() time.Time
	LessThan(b Entry) bool
}

A point inside the grid, i.e. a thing the grid can decide to remove

type Grid

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

func NewGrid

func NewGrid(l []Interval) *Grid

func (Grid) FitEntries

func (g Grid) FitEntries(now time.Time, entries []Entry) (keep, remove []Entry)

Partition a list of RetentionGridEntries into the Grid, relative to a given start date `now`.

The `keepCount` oldest entries per `retentiongrid.Interval` are kept (`keep`), the others are removed (`remove`).

Entries that are younger than `now` are always kept. Those that are older than the earliest beginning of an interval are removed.

type Interval

type Interval interface {
	Length() time.Duration
	KeepCount() int
}

Jump to

Keyboard shortcuts

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