storages

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 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 Criteria

type Criteria struct {
	Page  int
	Limit int
}

type FetchCriteria

type FetchCriteria struct {
	Criteria
	StartDate time.Time
	EndDate   time.Time
	Filters   map[Filter]interface{}
}

type Filter

type Filter int
const (
	Severity Filter = iota
	Facility
	Application
)

func (Filter) GetBinding

func (filter Filter) GetBinding() string

func (Filter) GetColumnForSQL

func (filter Filter) GetColumnForSQL() string

func (Filter) GetTitle

func (filter Filter) GetTitle() string

type LogEvent

type LogEvent struct {
	Host     string
	Message  string
	Severity int
	Facility int
	Date     time.Time
	AppName  string
}

type LogStorage

type LogStorage interface {
	SaveEvent(event LogEvent) (bool, error)
	FetchEvents(criteria FetchCriteria, page int, limit int) ([]LogEvent, int)
	FetchFilter(filter Filter) ([]Lookup, error)
}

type Lookup

type Lookup struct {
	Key  interface{}
	Name string
}

type MemoryStorage

type MemoryStorage struct {
	Logs []LogEvent
}

func (*MemoryStorage) FetchEvents

func (storage *MemoryStorage) FetchEvents(criteria FetchCriteria, page int, limit int) ([]LogEvent, int)

func (*MemoryStorage) SaveEvent

func (storage *MemoryStorage) SaveEvent(event LogEvent) (bool, error)

type SqlLite3Storage

type SqlLite3Storage struct {
	Db *sql.DB
}

func NewSqlLite3Storage

func NewSqlLite3Storage(dbFile string) *SqlLite3Storage

func (*SqlLite3Storage) FetchEvents

func (storage *SqlLite3Storage) FetchEvents(criteria FetchCriteria, page int, limit int) ([]LogEvent, int)

func (*SqlLite3Storage) FetchFilter

func (storage *SqlLite3Storage) FetchFilter(filter Filter) ([]Lookup, error)

func (*SqlLite3Storage) GenerateWhere

func (storage *SqlLite3Storage) GenerateWhere(criteria FetchCriteria) string

func (*SqlLite3Storage) SaveEvent

func (storage *SqlLite3Storage) SaveEvent(event LogEvent) (bool, error)

Jump to

Keyboard shortcuts

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