store

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package store implements how to output the log, and how to restore from the log file.

Index

Constants

View Source
const (
	PROBE_HISTORY_LEN    = 60
	INCIDENT_HISTORY_LEN = 20
)

Variables

View Source
var (
	LogRestoreBytes = int64(10 * 1024 * 1024)
)

Functions

This section is empty.

Types

type PathPattern added in v0.16.0

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

func ParsePathPattern added in v0.16.0

func ParsePathPattern(s string) PathPattern

func (PathPattern) Build added in v0.16.0

func (p PathPattern) Build(t time.Time) string

func (PathPattern) Glob added in v0.16.0

func (p PathPattern) Glob() string

func (PathPattern) IsEmpty added in v0.16.0

func (p PathPattern) IsEmpty() bool

func (PathPattern) ListAll added in v0.16.0

func (p PathPattern) ListAll() []string

ListAll returns all log file pathes. The result is sorted by time order.

func (PathPattern) ListBetween added in v0.16.0

func (p PathPattern) ListBetween(since, until time.Time) []string

ListBetween returns log file pathes. The result is filtered by since and until query, but not sorted.

func (PathPattern) Match added in v0.16.0

func (p PathPattern) Match(filename string, since, until time.Time) bool

func (PathPattern) String added in v0.16.0

func (p PathPattern) String() string

type RecordHandler added in v0.12.0

type RecordHandler func(api.Record)

type Store

type Store struct {
	Console io.Writer

	OnStatusChanged []RecordHandler
	// contains filtered or unexported fields
}

Store is the log handler of Ayd, and it also the database of Ayd.

func New

func New(path string, console io.Writer) (*Store, error)

func (*Store) ActivateTarget added in v0.12.0

func (s *Store) ActivateTarget(source, target *api.URL)

ActivateTarget marks the target will reported via specified source. This method prepares a probeHistory, and mark it as active.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CurrentIncidents

func (s *Store) CurrentIncidents() []*api.Incident

func (*Store) DeactivateTarget added in v0.12.0

func (s *Store) DeactivateTarget(source *api.URL, targets ...*api.URL)

DeactivateTarget marks the target is no longer reported via specified source.

func (*Store) Errors added in v0.11.0

func (s *Store) Errors() (healthy bool, messages []string)

Errors returns store status and error logs.

func (*Store) IncidentCount

func (s *Store) IncidentCount() int

IncidentCount returns the count of incident causes.

func (*Store) IncidentHistory

func (s *Store) IncidentHistory() []*api.Incident

func (*Store) MakeReport

func (s *Store) MakeReport(probeHistoryLength int) api.Report

MakeReport creates ayd.Report for exporting for endpoint. The result includes only information about active targets.

func (*Store) OpenLog added in v0.14.0

func (s *Store) OpenLog(since, until time.Time) (api.LogScanner, error)

func (*Store) Pathes added in v0.16.0

func (s *Store) Pathes() []string

Path returns pathes to log files.

func (*Store) ProbeHistory

func (s *Store) ProbeHistory() []api.ProbeHistory

ProbeHistory returns a slice of lib-ayd.ProbeHistory. This method only returns active target's ProbeHistory.

func (*Store) Report

func (s *Store) Report(source *api.URL, r api.Record)

Report reports a Record to this Store.

See also probeHistoryMap.Append about the arguments.

func (*Store) ReportInternalError

func (s *Store) ReportInternalError(scope, message string)

func (*Store) Restore

func (s *Store) Restore() error

func (*Store) Targets added in v0.12.0

func (s *Store) Targets() []string

Targets returns target URLs as a string slice. The result is includes inactive target, sorted in dictionary order.

Jump to

Keyboard shortcuts

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