storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TTL             time.Duration
	CheckInterval   time.Duration
	MaxRestarts     int
	MaxEvents       int
	MaxEventsByTest int
	MaxDumpSize     int
	HMACKey         []byte
}

Config represents the storage's configurable options.

type Storage

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

Storage represents the storage itself, holding its configurations and state.

func New

func New(cfg *Config) (*Storage, error)

New contains the logic to construct and return a new *Storage according to the passed *Config object. In case of error, it returns the error to the caller.

func (*Storage) LoadEvents

func (s *Storage) LoadEvents(id string) (evts []app.Event, loaded bool)

LoadEvents returns the copy of an test's events slice if the test exists.

func (*Storage) SearchTest

func (s *Storage) SearchTest(f func(k, v string) bool) (id string, canary string)

SearchTest receives a function to be run against each tests' id and canary, and returns the id and canary of the first test for which the passed function returns true. If the function never returns true empty strings are returned to the caller.

func (*Storage) SetTest

func (s *Storage) SetTest(secret []byte) (id string, canary string, err error)

SetTest creates a new test or fetches an existing one to return a newly generated or already existing test id. In case of error, it returns the error to the caller.

func (*Storage) StartExpire

func (s *Storage) StartExpire(ret chan error)

StartExpire is used by the caller to start expiring events and, in case of a panic from expire function, try to restart the expiration process the configured number of times.

Panics should not and are not expected to happen as a normal occurrence, so this may be useless and soon to be dropped.

func (*Storage) StoreEvent

func (s *Storage) StoreEvent(evt app.Event) error

StoreEvent appends an event to an existing test if it exists, otherwise it will return an error to the caller.

func (*Storage) TotalEvents

func (s *Storage) TotalEvents() int

TotalEvents returns the number of total events recorded in the storage at the moment.

func (*Storage) TotalTests

func (s *Storage) TotalTests() int

TotalTests returns the number of total tests recorded in the storage at the moment.

Jump to

Keyboard shortcuts

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