eventdb

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package eventdb handles the events storage.

The DB contains multiple sqlite instances, a new sqlite instance would be created and also an old instance would be expired every day.

File Structure

Example file structure for period=1day, expiration=7days:

	storage/
	   |- event/
            |- 16912 -- Outdated
	        |- 16913 -- -7
	        |- 16914 -- -6
	        |- 16915 -- -5
	        |- 16916 -- -4
	        |- 16917 -- -3
	        |- 16918 -- -2
	        |- 16919 -- -1
	        |- 16920 -- Active

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStorage = errors.New("eventdb: no storage")

ErrNoStorage is returned when no storage is able to serve, which indicates that given stamp or stamp range may be invalid.

Functions

This section is empty.

Types

type DB

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

DB is the top level event storage handler.

func Open

func Open(fileName string, opts *Options) (*DB, error)

Open a DB by filename.

func (*DB) Close

func (db *DB) Close() (err error)

Close the DB.

func (*DB) GetByProjectID

func (db *DB) GetByProjectID(projectID, lowestLevel int, start, end uint32) (ews []EventWrapper, err error)

GetByProjectID returns event wrappers by project id and time range.

func (*DB) GetRange added in v0.2.5

func (db *DB) GetRange(lowestLevel int, start, end uint32) (ews []EventWrapper, err error)

GetRange returns event wrappers by lowest level and time range.

func (*DB) Put

func (db *DB) Put(ew *EventWrapper) (err error)

Put an event wraper into db.

type EventWrapper

type EventWrapper struct {
	ID                string  `gorm:"primary_key" json:"id"`
	RuleID            int     `sql:"index;not null" json:"ruleID"`
	ProjectID         int     `sql:"index;not null" json:"projectID"`
	Level             int     `sql:"index;not null" json:"level"`
	Comment           string  `sql:"type:varchar(256)" json:"comment"` // rule.Comment
	Name              string  `sql:"size:257;not null" json:"name"`
	Stamp             uint32  `sql:"index;not null" json:"stamp"`
	Score             float64 `json:"score"`   // index.Score
	Average           float64 `json:"average"` // index.Average
	Value             float64 `json:"value"`   // metric.Value
	TranslatedComment string  `sql:"type:varchar(513)" json:"translatedComment"`
}

EventWrapper is an event wrapper to store into sqlite.

func NewEventWrapper

func NewEventWrapper(ev *models.Event) *EventWrapper

NewEventWrapper creates a new EventWrapper from models.Event.

type Options

type Options struct {
	Period     uint32
	Expiration uint32
}

Options is to open DB.

Jump to

Keyboard shortcuts

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