timeline

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package timeline reads a task's timeline: its own events and those of the units linked to it, every one kept forever.

Index

Constants

View Source
const KindRecord = "record"

KindRecord is the event kind of a record: its Key is the record kind of records.toml, its Actor the writer, its Data the record's JSON. A unit keeps one record of each kind, the newest.

Variables

This section is empty.

Functions

func HeldOf added in v0.4.0

func HeldOf(ctx context.Context, r Records, e task.Task) ([]unit.Unit, error)

HeldOf are the units a record of task e is read from after its own: e's units, then, when r is also Holdings, the other units it lists, the newest merged task's first.

func Pick

func Pick(recs map[unit.Unit]port.Event, id task.ID, held []unit.Unit) (port.Event, bool)

Pick is task id's record among recs, the records of its kind by unit, as RecordOf picks it.

func RecordOf

func RecordOf(ctx context.Context, r Records, kind string, id task.ID, held []unit.Unit) (port.Event, bool, error)

RecordOf is task id's record of kind: its own, else the first of held, the units it holds in order, that keeps one, as a pull request task's brief is its pull request's; false when none does.

Types

type Event

type Event struct {
	Seq int64
	port.Event
}

Event is an event of a timeline at Seq, its row in the event log, which grows with every event stored and orders and pages the timeline.

type Filter

type Filter struct {
	Kinds  []string
	Except []string
	Before int64
	Limit  int
}

Filter narrows a timeline: Kinds keeps those event kinds (every kind when empty), Except drops those, Before the events whose Seq is lower (all when 0), Limit at most that many (all when 0).

type Holdings

type Holdings interface {
	// UnitsOf are the units task id holds, in its order, then the own unit
	// (task.UnitOf) of every task merged into id, transitively; empty for a
	// task with none or no such task.
	UnitsOf(ctx context.Context, id task.ID) ([]unit.Unit, error)
}

Holdings are the units the tasks hold.

type Log

type Log interface {
	// EventsOf are the events of units f keeps, newest first (by Seq).
	EventsOf(ctx context.Context, units []unit.Unit, f Filter) ([]Event, error)
}

Log reads the event log.

type Merged

type Merged struct {
	Log      Log
	Holdings Holdings
	// Except are the event kinds no timeline shows, asked for by kind or not.
	Except []string
}

Merged is the Reader over the event log: a task's timeline is its own events and those of the units it holds, without the merge records and the kinds of Except.

func (Merged) Of

func (m Merged) Of(ctx context.Context, id task.ID, f Filter) ([]Event, error)

type Node added in v0.4.0

type Node struct {
	Rule, Label, Tone string
	At, End           time.Time
	Running           bool
	Actor             string
	Events            []Event
}

Node is one fact of a timeline: the events a rule folded, or one event no rule took (Rule ""). End is zero for a single event and for a span still Running.

func Group added in v0.4.0

func Group(events []Event, rules []Rule, words Words) []Node

Group folds events, oldest first, into nodes by rules, tried in their order; the nodes come out newest first. No event is dropped: one no rule takes is a node of its own, labeled by its kind's words or, when no layer words its kind, by the kind itself.

type Reader

type Reader interface {
	// Of are the events of task id and of its linked units that f keeps,
	// newest first (by Seq); empty for a task with none.
	Of(ctx context.Context, id task.ID, f Filter) ([]Event, error)
}

Reader reads timelines.

type Records

type Records interface {
	// Records are the record of kind on each of units that keeps one; with
	// no units, on every unit that keeps one.
	Records(ctx context.Context, kind string, units ...unit.Unit) (map[unit.Unit]port.Event, error)
}

Records reads the records the units keep.

type Rule added in v0.4.0

type Rule struct {
	Name               string
	Start, End, Absorb []string
	Label, Running     string
	// Unfinished is how a span reads whose end never came before its start kind came again.
	Unfinished string
	Tone       string
	// Subs words an event's sub, such as a review's verdict; a sub it leaves out reads as itself.
	Subs map[string]string
}

Rule folds events into one node of a timeline, as a profile's [facts.<name>] declares it: a Start kind opens the node, an End kind closes it when End is set (a span), and an Absorb kind joins the open span, or the node just before it when that node is the rule's.

type Word added in v0.4.0

type Word struct{ Label, Tone string }

Word is how one event kind reads on a timeline.

type Words added in v0.4.0

type Words struct {
	Kinds    map[string]Word
	Duration func(time.Duration) string
	// Sub is the short value of an event a label's {{.sub}} reads, such as a review's verdict; nil for none.
	Sub func(Event) string
}

Words are what Group reads beside the rules: each kind's words, a duration in words, and an event's sub.

Directories

Path Synopsis
Package timelinetest holds an in-memory timeline.Reader.
Package timelinetest holds an in-memory timeline.Reader.

Jump to

Keyboard shortcuts

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