forked from galaxydi/go-loghub
-
Notifications
You must be signed in to change notification settings - Fork 111
/
model.go
68 lines (58 loc) · 2 KB
/
model.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
66
67
68
package sls
import (
"strings"
)
// GetHistogramsResponse defines response from GetHistograms call
type SingleHistogram struct {
Progress string `json:"progress"`
Count int64 `json:"count"`
From int64 `json:"from"`
To int64 `json:"to"`
}
type GetHistogramsResponse struct {
Progress string `json:"progress"`
Count int64 `json:"count"`
Histograms []SingleHistogram `json:"histograms"`
}
func (resp *GetHistogramsResponse) IsComplete() bool {
return strings.ToLower(resp.Progress) == "complete"
}
// GetLogsResponse defines response from GetLogs call
type GetLogsResponse struct {
Progress string `json:"progress"`
Count int64 `json:"count"`
Logs []map[string]string `json:"logs"`
}
func (resp *GetLogsResponse) IsComplete() bool {
return strings.ToLower(resp.Progress) == "complete"
}
// IndexKey ...
type IndexKey struct {
Token []string `json:"token"` // tokens that split the log line.
CaseSensitive bool `json:"caseSensitive"`
Type string `json:"type"` // text, long, double
DocValue bool `json:"doc_value,omitempty"`
Alias string `json:"alias,omitempty"`
Chn bool `json:"chn"` // parse chinese or not
}
type IndexLine struct {
Token []string `json:"token"`
CaseSensitive bool `json:"caseSensitive"`
IncludeKeys []string `json:"include_keys,omitempty"`
ExcludeKeys []string `json:"exclude_keys,omitempty"`
Chn bool `json:"chn"` // parse chinese or not
}
// Index is an index config for a log store.
type Index struct {
Keys map[string]IndexKey `json:"keys,omitempty"`
Line *IndexLine `json:"line,omitempty"`
}
// CreateDefaultIndex return a full text index config
func CreateDefaultIndex() *Index {
return &Index{
Line: &IndexLine{
Token: []string{" ", "\n", "\t", "\r", ",", ";", "[", "]", "{", "}", "(", ")", "&", "^", "*", "#", "@", "~", "=", "<", ">", "/", "\\", "?", ":", "'", "\""},
CaseSensitive: false,
},
}
}