-
Notifications
You must be signed in to change notification settings - Fork 2
/
sqlog_api.go
65 lines (57 loc) · 1.89 KB
/
sqlog_api.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package sqlog
type Tick struct {
Index int `json:"index"`
Start int64 `json:"epoch_start"`
End int64 `json:"epoch_end"`
Count int64 `json:"count"`
Debug int64 `json:"debug"`
Info int64 `json:"info"`
Warn int64 `json:"warn"`
Error int64 `json:"error"`
}
type TicksInput struct {
Expr string `json:"expr"`
Level []string `json:"level"` // ["debug","info","warn","error"]
EpochEnd int64 `json:"epoch"`
IntervalSec int `json:"interval"`
MaxResult int `json:"limit"`
}
type EntriesInput struct {
Expr string `json:"expr"`
Level []string `json:"level"` // ["debug","info","warn","error"]
Direction string `json:"dir"` // before|after
EpochStart int64 `json:"epoch"` // @TODO: add epochMax
NanosStart int `json:"nanos"`
MaxResult int `json:"limit"`
}
type Output struct {
Scheduled bool `json:"scheduled,omitempty"` // Indicates that this is a partial result
TaskIds []int32 `json:"tasks,omitempty"` // The id so that the result can be retrieved in the future
Error error `json:"-"` // The last error occurred
Ticks []*Tick `json:"ticks,omitempty"` // The ticks available in this response
Entries []any `json:"entries,omitempty"` // The log records available in this response
}
func (l *sqlog) Entries(input *EntriesInput) (*Output, error) {
if s, ok := l.storage.(StorageWithApi); ok {
return s.Entries(input)
}
return &Output{}, nil
}
func (l *sqlog) Ticks(input *TicksInput) (*Output, error) {
if s, ok := l.storage.(StorageWithApi); ok {
return s.Ticks(input)
}
return &Output{}, nil
}
func (l *sqlog) Result(taskId int32) (*Output, error) {
if s, ok := l.storage.(StorageWithApi); ok {
return s.Result(taskId)
}
return &Output{}, nil
}
func (l *sqlog) Cancel(taskId int32) error {
if s, ok := l.storage.(StorageWithApi); ok {
return s.Cancel(taskId)
}
return nil
}