-
Notifications
You must be signed in to change notification settings - Fork 3
/
broken.go
41 lines (33 loc) · 897 Bytes
/
broken.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
package testscripts
import (
"context"
"errors"
"github.com/whitewater-guide/gorge/core"
)
type optionsBroken struct{}
type scriptBroken struct {
core.LoggingScript
}
func (s *scriptBroken) ListGauges() (core.Gauges, error) {
return nil, errors.New("this script is always broken")
}
func (s *scriptBroken) Harvest(ctx context.Context, recv chan<- *core.Measurement, errs chan<- error, codes core.StringSet, since int64) {
defer close(recv)
defer close(errs)
select {
case errs <- errors.New("this script is always broken"):
case <-ctx.Done():
return
}
}
var Broken = &core.ScriptDescriptor{
Name: "broken",
Description: "Test script that always returns error",
Mode: core.AllAtOnce,
DefaultOptions: func() interface{} {
return &optionsBroken{}
},
Factory: func(name string, options interface{}) (core.Script, error) {
return &scriptBroken{}, nil
},
}