-
Notifications
You must be signed in to change notification settings - Fork 153
/
source.go
51 lines (40 loc) · 1019 Bytes
/
source.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
package execute
import (
"context"
"fmt"
"github.com/influxdata/flux/metadata"
"github.com/influxdata/flux/plan"
)
type Node interface {
AddTransformation(t Transformation)
}
// MetadataNode is a node that has additional metadata
// that should be added to the result after it is
// processed.
type MetadataNode interface {
Node
Metadata() metadata.Metadata
}
type Source interface {
Node
Run(ctx context.Context)
SetLabel(label string)
Label() string
}
type CreateSource func(spec plan.ProcedureSpec, id DatasetID, ctx Administration) (Source, error)
var procedureToSource = make(map[plan.ProcedureKind]CreateSource)
func RegisterSource(k plan.ProcedureKind, c CreateSource) {
if procedureToSource[k] != nil {
panic(fmt.Errorf("duplicate registration for source with procedure kind %v", k))
}
procedureToSource[k] = c
}
type ExecutionNode struct {
label string
}
func (n *ExecutionNode) SetLabel(label string) {
n.label = label
}
func (n *ExecutionNode) Label() string {
return n.label
}