store

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 10 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    = 40
	INCIDENT_HISTORY_LEN = 10
)

Variables

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

Functions

This section is empty.

Types

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 *url.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 *url.URL, targets ...*url.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() api.Report

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

func (*Store) Path

func (s *Store) Path() string

Path returns path to log file.

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 *url.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) SetPath added in v0.12.0

func (s *Store) SetPath(p string)

SetPath sets path to log file.

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