history

package
v0.0.0-...-97238d6 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package history provides an append only, size limited log of recent actions that Tide has taken for each subpool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByNum

type ByNum []PRMeta

ByNum implements sort.Interface for []PRMeta to sort by ascending PR number.

func (ByNum) Len

func (prs ByNum) Len() int

func (ByNum) Less

func (prs ByNum) Less(i, j int) bool

func (ByNum) Swap

func (prs ByNum) Swap(i, j int)

type History

type History struct {
	sync.Mutex
	// contains filtered or unexported fields
}

History uses a `*recordLog` per pool to store a record of recent actions that Tide has taken. Using a log per pool ensure that history is retained for inactive pools even if other pools are very active.

func New

func New(maxRecordsPerKey int) *History

New creates a new History struct with the specificed recordLog size limit.

func (*History) AllRecords

func (h *History) AllRecords() map[string][]*Record

AllRecords generates a map from pool key -> sorted records for the pool.

func (*History) Record

func (h *History) Record(poolKey, action, baseSHA, err string, targets []PRMeta)

Record appends an entry to the recordlog specified by the poolKey.

func (*History) ServeHTTP

func (h *History) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves a JSON mapping from pool key -> sorted records for the pool.

type PRMeta

type PRMeta struct {
	Num    int    `json:"num"`
	Author string `json:"author"`
	Title  string `json:"title"`
	SHA    string `json:"SHA"`
}

PRMeta stores metadata about a PR at the time of the action.

type Record

type Record struct {
	Time    time.Time `json:"time"`
	Action  string    `json:"action"`
	BaseSHA string    `json:"baseSHA,omitempty"`
	Target  []PRMeta  `json:"target,omitempty"`
	Err     string    `json:"err,omitempty"`
}

Record is an entry describing one action that Tide has taken (e.g. TRIGGER or MERGE).

Jump to

Keyboard shortcuts

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