forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop.go
44 lines (39 loc) · 918 Bytes
/
noop.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
package kapacitor
import (
"log"
"github.com/influxdata/kapacitor/pipeline"
)
type NoOpNode struct {
node
}
// Create a new NoOpNode which does nothing with the data and just passes it through.
func newNoOpNode(et *ExecutingTask, n *pipeline.NoOpNode, l *log.Logger) (*NoOpNode, error) {
nn := &NoOpNode{
node: node{Node: n, et: et, logger: l},
}
nn.node.runF = nn.runNoOp
return nn, nil
}
func (s *NoOpNode) runNoOp([]byte) error {
switch s.Wants() {
case pipeline.StreamEdge:
for p, ok := s.ins[0].NextPoint(); ok; p, ok = s.ins[0].NextPoint() {
for _, child := range s.outs {
err := child.CollectPoint(p)
if err != nil {
return err
}
}
}
case pipeline.BatchEdge:
for b, ok := s.ins[0].NextBatch(); ok; b, ok = s.ins[0].NextBatch() {
for _, child := range s.outs {
err := child.CollectBatch(b)
if err != nil {
return err
}
}
}
}
return nil
}