history

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 11 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 []prowapi.Pull

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, opener io.Opener, path string) (*History, error)

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) Flush

func (h *History) Flush()

Flush writes the action history to persistent storage if configured to do so.

func (*History) Record

func (h *History) Record(poolKey, action, baseSHA, err string, targets []prowapi.Pull, tenantIDs []string)

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 Record

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

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