-
Notifications
You must be signed in to change notification settings - Fork 0
/
generic.go
63 lines (54 loc) · 1.33 KB
/
generic.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
package generic
import (
"github.com/itrs-group/cordial/pkg/logger"
"github.com/itrs-group/cordial/pkg/plugins"
"github.com/itrs-group/cordial/pkg/samplers"
)
func init() {
logger.EnableDebugLog()
}
var (
log = logger.Log
logDebug = logger.Debug
logError = logger.Error
)
type GenericData struct {
RowName string
Column1 string
Column2 string
}
type GenericSampler struct {
samplers.Samplers
localdata string
}
func New(s plugins.Connection, name string, group string) (*GenericSampler, error) {
c := new(GenericSampler)
c.Plugins = c
return c, c.New(s, name, group)
}
func (g *GenericSampler) InitSampler() error {
logDebug.Println("called")
example, err := g.Parameter("EXAMPLE")
longparameter, err := g.Parameter("DIRS")
log.Printf("long param len: %d\n%s", len(longparameter), longparameter)
if err != nil {
logError.Println(err)
return nil
}
g.localdata = example
columns, columnnames, sortcol, err := g.ColumnInfo(GenericData{})
g.SetColumns(columns)
g.SetColumnNames(columnnames)
g.SetSortColumn(sortcol)
return g.Headline("example", g.localdata)
}
func (p *GenericSampler) DoSample() error {
logDebug.Print("called")
var rowdata = []GenericData{
{"row4", "data1", "data2"},
{"row2", "data1", "data2"},
{"row3", "data1", "data2"},
{"row1", "data1", "data2"},
}
return p.UpdateTableFromSlice(rowdata)
}