historian

package
v0.0.0-...-ac41614 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BY_TIME_PREFIX                 = []byte{0}
	BY_SOURCE_AND_TIME_PREFIX      = []byte{1}
	BY_DATA_SOURCE_AND_TIME_PREFIX = []byte{2}
	BY_SERIAL_NUMBER_PREFIX        = []byte{3}
	SEQUENTIAL_COUNTER_PREFIX      = []byte{4}
	CURRENT_SIZE_COUNTER_PREFIX    = []byte{5}
	HIGHEST_FORWARDED_INDEX_PREFIX = []byte{6}
	DELIMETER                      = []byte(".")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Timestamp uint64   `json:"timestamp"`
	SourceID  string   `json:"source"`
	Type      string   `json:"type"`
	Data      string   `json:"data"`
	UUID      string   `json:"uuid"`
	Serial    uint64   `json:"serial"`
	Groups    []string `json:"groups"`
}

type EventIterator

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

func NewEventIterator

func NewEventIterator(iterator StorageIterator, limit int) *EventIterator

func (*EventIterator) Error

func (ei *EventIterator) Error() error

func (*EventIterator) Event

func (ei *EventIterator) Event() *Event

func (*EventIterator) Next

func (ei *EventIterator) Next() bool

func (*EventIterator) Release

func (ei *EventIterator) Release()

type Historian

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

func NewHistorian

func NewHistorian(storageDriver StorageDriver, eventLimit uint64, eventFloor uint64, purgeBatchSize int) *Historian

func (*Historian) ForwardIndex

func (historian *Historian) ForwardIndex() uint64

func (*Historian) LogEvent

func (historian *Historian) LogEvent(event *Event) error

func (*Historian) LogSerial

func (historian *Historian) LogSerial() uint64

func (*Historian) LogSize

func (historian *Historian) LogSize() uint64

func (*Historian) Purge

func (historian *Historian) Purge(query *HistoryQuery) error

func (*Historian) Query

func (historian *Historian) Query(query *HistoryQuery) (*EventIterator, error)

func (*Historian) RotateLog

func (historian *Historian) RotateLog() error

The behavior of log rotation is determined by the relationship between eventLimit, eventFloor, and purgeBatchSize. Log rotation occurs when the log contains eventLimit events. Log rotation will delete old events until there are eventFloor events remaining in the log. Configuring these two values can adjust the performance characteristics of the history log and how aggressively disk space is conserved.

Here are some example configurations and their performance characteristics:

eventLimit = 100000 eventFloor = 99999

In this case the most events ever stored
on disk will be 100000. However, after
there are at least 99999 events written to
the log every new log entry will require
a log rotation operation to occur in order
to keep the log size under the limit.

eventLimit = 200000 eventFloor = 100000

In this case a purge operation only occurs
once every 100000 writes instead of on every
write.

if eventFloor is greater than or equal to eventLimit then eventFloor is ignored and eventLimit is used as the event floor

func (*Historian) SetForwardIndex

func (historian *Historian) SetForwardIndex(i uint64) error

func (*Historian) SetLogSerial

func (historian *Historian) SetLogSerial(s uint64) error

type HistoryQuery

type HistoryQuery struct {
	MinSerial *uint64
	MaxSerial *uint64
	Sources   []string
	Data      *string
	Order     string
	Before    uint64
	After     uint64
	Limit     int
}

Jump to

Keyboard shortcuts

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