-
Notifications
You must be signed in to change notification settings - Fork 0
/
generic.go
53 lines (46 loc) · 1.21 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
package generic
import (
"github.com/itrs-group/cordial/pkg/plugins"
"github.com/itrs-group/cordial/pkg/samplers"
"github.com/rs/zerolog/log"
)
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 {
log.Debug().Msg("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 {
log.Error().Err(err).Msg("")
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 {
log.Debug().Msg("called")
var rowdata = []GenericData{
{"row4", "data1", "data2"},
{"row2", "data1", "data2"},
{"row3", "data1", "data2"},
{"row1", "data1", "data2"},
}
return p.UpdateTableFromSlice(rowdata)
}