collector

package
v2.0.0-...-e9c7f1d Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package collector collects output lines grouped by id and provides ways to retrieve and merge output ordered by the time each line was added.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Output

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

Output stores output lines grouped by id. Output can be retrieved for one or more ids and output for different ids can be merged together, while preserving their insertion original order based on the time it was collected. Output also tracks the active id, so you can append output without providing an id.

func New

func New() *Output

New returns a new output collector.

func (*Output) Append

func (o *Output) Append(text string)

Append appends the given line of text to the output of the currently active id.

func (*Output) AppendToID

func (o *Output) AppendToID(id int, text string)

AppendToID appends the given line of text to the output of the given id.

func (*Output) Clear

func (o *Output) Clear(id int)

Clear deletes all output for the given id.

func (*Output) Contains

func (o *Output) Contains(id int) bool

Contains returns true if any output lines were collected for the given id.

func (*Output) Get

func (o *Output) Get(id int) []string

Get returns the output lines for the given id.

func (*Output) GetAll

func (o *Output) GetAll(ids ...int) []string

GetAll returns the output lines for all ids sorted by the collection timestamp of each line of output.

func (*Output) Merge

func (o *Output) Merge(fromID, intoID int)

Merge merges the output lines from fromID into intoID, and sorts the output by the collection timestamp of each line of output.

func (*Output) SetActiveID

func (o *Output) SetActiveID(id int)

SetActiveID sets the active id. Text appended to this output will be associated with the active id.

Jump to

Keyboard shortcuts

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