history

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInconsistentMetadata = errors.New("inconsistent metadata")
	ErrRepeatID             = errors.New("repeat transaction uuid found")
	ErrMissingOnlineEvent   = errors.New("session does not have online event")
	ErrMissingOfflineEvent  = errors.New("session does not have offline event")
	ErrInvalidEventOrder    = errors.New("invalid event order")
	ErrFalseReboot          = errors.New("not a true reboot")
	ErrNoReboot             = errors.New("no reboot found")
)
View Source
var (
	EventNotFoundErr = errors.New("event not found")
)

Functions

This section is empty.

Types

type Comparator

type Comparator interface {
	Compare(baseEvent interpreter.Event, newEvent interpreter.Event) (bool, error)
}

Comparator compares two events and returns true if the condition has been matched. A Comparator can also return an error when it deems appropriate.

type ComparatorErr

type ComparatorErr struct {
	OriginalErr     error
	ComparisonEvent interpreter.Event
	ErrorTag        validation.Tag
}

ComparatorErr is used when an error is found with a trigger event when comparing it to a another event in the history of events.

func (ComparatorErr) Error

func (e ComparatorErr) Error() string

func (ComparatorErr) Event

func (e ComparatorErr) Event() interpreter.Event

Event returns the event in history that caused the error to be thrown.

func (ComparatorErr) Tag added in v0.0.4

func (e ComparatorErr) Tag() validation.Tag

Tag implements the TaggedError interface.

func (ComparatorErr) Unwrap

func (e ComparatorErr) Unwrap() error

type ComparatorFunc

type ComparatorFunc func(interpreter.Event, interpreter.Event) (bool, error)

ComparatorFunc is a function that compares two events.

func DefaultComparator added in v0.0.5

func DefaultComparator() ComparatorFunc

DefaultComparator is a Comparator that always returns false and nil.

func DuplicateEventComparator

func DuplicateEventComparator() ComparatorFunc

DuplicateEventComparator returns a ComparatorFunc to check and see if newEvent is a duplicate. A duplicate event in this case is defined as sharing the same event type and boot-time as the base event while having a birthdate that is equal to or newer than baseEvent's birthdate. If newEvent is found to be a duplicate, it returns true and an error. It assumes that newEvent has a valid boot-time and event-type and does not do any error-checking of newEvent's boot-time or event type.

func OlderBootTimeComparator

func OlderBootTimeComparator() ComparatorFunc

OlderBootTimeComparator returns a ComparatorFunc to check and see if newEvent's boot-time is less than the baseEvent's boot-time. If it is, it returns true and an error. OlderBootTimeComparator assumes that newEvent has a valid boot-time and does not do any error-checking of newEvent's boot-time.

func (ComparatorFunc) Compare

func (c ComparatorFunc) Compare(baseEvent interpreter.Event, newEvent interpreter.Event) (bool, error)

Compare runs the ComparatorFunc, making a ComparatorFunc a Comparator

type Comparators

type Comparators []Comparator

Comparators are a list of objects that implement the Comparator interface

func (Comparators) Compare

func (c Comparators) Compare(baseEvent interpreter.Event, newEvent interpreter.Event) (bool, error)

Compare runs through a list of Comparators and compares two events using each comparator. Returns true on the first comparator that matches.

type CycleValidationErr added in v0.0.4

type CycleValidationErr struct {
	OriginalErr       error
	ErrorTag          validation.Tag
	ErrorDetailKey    string
	ErrorDetailValues []string
}

CycleValidationErr is an error returned by validators for list of events.

func (CycleValidationErr) Error added in v0.0.4

func (e CycleValidationErr) Error() string

func (CycleValidationErr) ErrorDetails added in v0.0.4

func (e CycleValidationErr) ErrorDetails() string

ErrorDetails returns the ErrorCauseKey and ErrorCauseValues in a string.

func (CycleValidationErr) Fields added in v0.0.4

func (e CycleValidationErr) Fields() []string

Fields returns the fields that resulted in the error.

func (CycleValidationErr) Tag added in v0.0.4

Tag implements the TaggedError interface.

func (CycleValidationErr) Unwrap added in v0.0.4

func (e CycleValidationErr) Unwrap() error

type CycleValidator added in v0.0.5

type CycleValidator interface {
	Valid(events []interpreter.Event) (bool, error)
}

CycleValidator validates a list of events.

type CycleValidatorFunc added in v0.0.4

type CycleValidatorFunc func(events []interpreter.Event) (valid bool, err error)

CycleValidatorFunc is a function type that takes in a slice of events and returns whether the slice of events is valid or not.

func DefaultCycleValidator added in v0.0.5

func DefaultCycleValidator() CycleValidatorFunc

DefaultCycleValidator is a CycleValidator that always returns true and nil.

func EventOrderValidator added in v0.0.5

func EventOrderValidator(order []string) CycleValidatorFunc

EventOrderValidator returns a CycleValidatorFunc that validates that there exists, within the history of events, particular events in the proper order.

func MetadataValidator added in v0.0.4

func MetadataValidator(fields []string, checkWithinCycle bool) CycleValidatorFunc

MetadataValidator takes in a slice of metadata keys and returns a CycleValidatorFunc that validates that events in the slice have the same values for the keys passed in. If checkWithinCycle is true, it will only check that events with the same boot-time have the same values.

func SessionOfflineValidator added in v0.0.4

func SessionOfflineValidator(excludeFunc func(events []interpreter.Event, id string) bool) CycleValidatorFunc

SessionOfflineValidator returns a CycleValidatorFunc that validates that all sessions in the slice (except for the most recent session) have an offline event. It takes in excludeFunc, which is a function that takes in a session ID and returns true if that session is still valid even if it does not have an offline event.

func SessionOnlineValidator added in v0.0.4

func SessionOnlineValidator(excludeFunc func(events []interpreter.Event, id string) bool) CycleValidatorFunc

SessionOnlineValidator returns a CycleValidatorFunc that validates that all sessions in the slice (determined by sessionIDs) have an online event. It takes in excludeFunc, which is a function that takes in a session ID and returns true if that session is still valid even if it does not have an online event.

func TransactionUUIDValidator added in v0.0.4

func TransactionUUIDValidator() CycleValidatorFunc

TransactionUUIDValidator returns a CycleValidatorFunc that validates that all events in the slice have different TransactionUUIDs.

func TrueRebootValidator added in v0.0.5

func TrueRebootValidator() CycleValidatorFunc

TrueRebootValidator returns a CycleValidatorFunc that validates that the latest online event is the result of a true reboot, meaning that it has a boot-time that is different from the event that precedes it. If an online event is not found, false and an error is returned.

func (CycleValidatorFunc) Valid added in v0.0.4

func (cf CycleValidatorFunc) Valid(events []interpreter.Event) (bool, error)

Valid runs the CycleValidatorFunc.

type CycleValidators added in v0.0.5

type CycleValidators []CycleValidator

CycleValidators are a list of objects that implement the CycleValidator interface

func (CycleValidators) Valid added in v0.0.5

func (c CycleValidators) Valid(events []interpreter.Event) (bool, error)

Valid runs through a list of CycleValidators and checks that the list of events is valid against each validator. It runs through all of the validators and returns the errors collected from each one. If at least one validator returns false, then false is returned.

type EventFinderErr

type EventFinderErr struct {
	OriginalErr error
	ErrorTag    validation.Tag
}

EventFinderErr is an error used by EventFinder.

func (EventFinderErr) Error

func (e EventFinderErr) Error() string

func (EventFinderErr) Tag added in v0.0.4

func (e EventFinderErr) Tag() validation.Tag

Tag implements the TaggedError interface.

func (EventFinderErr) Unwrap

func (e EventFinderErr) Unwrap() error

type EventsParserFunc added in v0.0.4

type EventsParserFunc func([]interpreter.Event, interpreter.Event) ([]interpreter.Event, error)

EventsParserFunc is a function that returns the relevant events from a slice of events.

func CurrentCycleParser added in v0.0.5

func CurrentCycleParser(comparator Comparator) EventsParserFunc

CurrentCycleParser returns an EventsParser that takes in a list of events and returns a sorted subset of that list which includes all of the events with the boot-time of the current cycle sorted from newest to oldest by birthdate. CurrentCycleParser also runs the list of events through the comparator to see if the current event is valid.

func DefaultCycleParser added in v0.0.5

func DefaultCycleParser(comparator Comparator) EventsParserFunc

DefaultCycleParser runs each event in the history through the comparator and returns the entire history if no errors are found.

func LastCycleParser added in v0.0.5

func LastCycleParser(comparator Comparator) EventsParserFunc

LastCycleParser returns an EventsParser that takes in a list of events and returns a sorted subset of that list which includes all of the events with the boot-time of the previous cycle sorted from newest to oldest by birthdate. LastCycleParser also runs the list of events through the comparator to see if the current event is valid.

func LastCycleToCurrentParser added in v0.0.5

func LastCycleToCurrentParser(comparator Comparator) EventsParserFunc

LastCycleToCurrentParser returns an EventsParser that takes in a list of events and returns a sorted subset of that list. The slice includes all of the events with the boot-time of the previous cycle as well as all events with the latest boot-time that have a birthdate less than or equal to the current event. The returned slice is sorted from newest to oldest primarily by boot-time, and then by birthdate.

func RebootParser added in v0.0.5

func RebootParser(comparator Comparator) EventsParserFunc

RebootParser returns an EventsParser that takes in a list of events and returns a sorted subset of that list containing events that are relevant to the latest reboot. The slice starts with the last reboot-pending (if available) or last offline event and includes all events afterwards that have a birthdate less than the first fully-manageable event (if available) or the first operational event (if available) or the first online event of the current cycle. The returned slice is sorted from newest to oldest primarily by boot-time, and then by birthdate. RebootParser also runs the list of events through the comparator to see if the current event is valid.

func RebootToCurrentParser added in v0.0.5

func RebootToCurrentParser(comparator Comparator) EventsParserFunc

RebootToCurrentParser returns an EventsParser that takes in a list of events and returns a sorted subset of that list containing events that are relevant to the latest reboot. The slice starts with the last reboot-pending (if available) or last offline event and includes all events afterwards that have a birthdate less than or equal to the current event. The returned slice is sorted from newest to oldest primarily by boot-time, and then by birthdate. RebootToCurrentParser also runs the list of events through the comparator to see if the current event is valid.

func (EventsParserFunc) Parse added in v0.0.4

func (p EventsParserFunc) Parse(events []interpreter.Event, currentEvent interpreter.Event) ([]interpreter.Event, error)

Parse implements the EventsParser interface.

type FinderFunc

type FinderFunc func([]interpreter.Event, interpreter.Event) (interpreter.Event, error)

FinderFunc is a function type that takes in a slice of events and the current event and returns an Event from the slice.

func CurrentSessionFinder

func CurrentSessionFinder(validator validation.Validator) FinderFunc

CurrentSessionFinder returns a function to find an event that is deemed valid by the Validator passed in with the boot-time of the current event.

func LastSessionFinder

func LastSessionFinder(validator validation.Validator) FinderFunc

LastSessionFinder returns a function to find an event that is deemed valid by the Validator passed in with the boot-time of the previous session.

func (FinderFunc) Find

func (f FinderFunc) Find(events []interpreter.Event, currentEvent interpreter.Event) (interpreter.Event, error)

Jump to

Keyboard shortcuts

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