db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDatabase

func InitDatabase() error

InitDatabase initializes the database connection and starts all recurring jobs on the database.

Types

type History

type History []HistoryMessage

type HistoryMessage

type HistoryMessage struct {
	Timestamp time.Time `json:"timestamp"`
	Message   struct {
		Target string `json:"target"`
		Value  string `json:"value"`
	} `json:"message"`
}

HistoryMessage serves as a model to describe entries in the history table.

type Reader

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

func GetReader

func GetReader() *Reader

func (*Reader) GetHistoryEntries

func (reader *Reader) GetHistoryEntries(target string) (History, error)

GetHistoryEntries gets history all entries from the loaded database file

func (*Reader) GetHistoryEntriesFrom

func (reader *Reader) GetHistoryEntriesFrom(target string, from time.Time) (History, error)

GetHistoryEntriesFrom gets History entries after "from"

func (*Reader) GetHistoryEntriesFromThinned

func (reader *Reader) GetHistoryEntriesFromThinned(target string, from time.Time, maxDensity time.Duration) (History, error)

GetHistoryEntriesFromThinned thins out the history data gathered from GetHistoryEntriesFrom to be at least as spread apart as defined in maxDensity

func (*Reader) GetHistoryEntriesFromUntil

func (reader *Reader) GetHistoryEntriesFromUntil(target string, from time.Time, until time.Time) (History, error)

GetHistoryEntriesFromUntil gets History entries after "from" and before "until"

func (*Reader) GetHistoryEntriesFromUntilThinned

func (reader *Reader) GetHistoryEntriesFromUntilThinned(target string, from time.Time, until time.Time, maxDensity time.Duration) (History, error)

GetHistoryEntriesFromUntilThinned thins out the history data gathered from GetHistoryEntriesFromUntil to be at least as speread apart as defined in maxDensity

func (*Reader) GetHistoryEntriesThinned

func (reader *Reader) GetHistoryEntriesThinned(target string, maxDensity time.Duration) (History, error)

GetHistoryEntriesThinned thins out the history data gathered from GetHistoryEntries to be at least as spread apart as defined in maxDensity.

type Writer

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

func GetWriter

func GetWriter() *Writer

func (*Writer) AddHistoryEntry

func (writer *Writer) AddHistoryEntry(target string, content string) error

AddHistoryEntry adds an entry to the history table.

Jump to

Keyboard shortcuts

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