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 (*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.
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.
Click to show internal directories.
Click to hide internal directories.