store

package
v0.0.0-...-b15b68f Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

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

Aggregator stores single log records into minute candles, returning candle for previous minute when first log entry for new minute appears

func (*Aggregator) Store

func (p *Aggregator) Store(entry LogRecord) (minuteCandle Candle, ok bool)

Store LogRecord into temp storage and return Candle when minute change, counting multiple entries with same FromIP and FileName as single data point

type Bolt

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

Bolt implements store.Engine with boltdb

func NewBolt

func NewBolt(dbFile string) (*Bolt, error)

NewBolt makes persistent boltdb based store

func (*Bolt) Load

func (s *Bolt) Load(ctx context.Context, periodStart, periodEnd time.Time) (result []Candle, err error)

Load Candles by period

func (*Bolt) LoadStream

func (s *Bolt) LoadStream(ctx context.Context, periodStart, periodEnd time.Time) chan Candle

LoadStream get Candles by period and returns as async stream

func (*Bolt) Save

func (s *Bolt) Save(candle Candle) (err error)

Save Candles with starting minute time.Unix() as a key for bolt range query

type Candle

type Candle struct {
	Nodes       map[string]Info
	StartMinute time.Time
}

Candle contain one minute candle from log entries for that period

func NewCandle

func NewCandle() (c Candle)

NewCandle create empty candle

func (*Candle) Update

func (c *Candle) Update(l LogRecord)

Update log destination node and add same stats to "all" node

type Engine

type Engine interface {
	Save(candle Candle) (err error)
	Load(ctx context.Context, periodStart, periodEnd time.Time) (result []Candle, err error)
}

Engine defines interface to save log entries and load candles

type Info

type Info struct {
	Volume int
	Files  map[string]int
}

Info contain single node download statistics

func NewInfo

func NewInfo() Info

NewInfo create empty node information

type LogRecord

type LogRecord struct {
	FromIP   string    `json:"from_ip"`
	FileName string    `json:"file_name"`
	DestHost string    `json:"dest"`
	Date     time.Time `json:"ts"`
}

LogRecord contains meaningful subset of data from rlb LogRecord

Jump to

Keyboard shortcuts

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