-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathstorage.go
More file actions
51 lines (43 loc) · 1.05 KB
/
storage.go
File metadata and controls
51 lines (43 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package storage
import (
"errors"
"time"
"github.com/linuxboot/contest/pkg/xcontext"
)
var (
ErrReadOnlyStorage = errors.New("error read only storage")
ErrInsert = errors.New("error inserting into the db")
ErrConstructQuery = errors.New("error forming db query from api query")
ErrQuery = errors.New("error querying from the database")
)
var (
DefaultTimestampFormat = "2006-01-02T15:04:05.000Z07:00"
)
type Storage interface {
StoreLogs(ctx xcontext.Context, logs []Log) error
GetLogs(ctx xcontext.Context, query Query) (*Result, error)
}
// Log defines the basic log info pushed by the server
type Log struct {
JobID uint64
LogData string
Date time.Time
LogLevel string
}
// Query defines the different options to filter with
type Query struct {
JobID *uint64
LogData *string
LogLevel *string
StartDate *time.Time
EndDate *time.Time
PageSize uint
Page uint
}
//Result defines the expected result returned from the db
type Result struct {
Logs []Log
Count uint64
Page uint
PageSize uint
}