forked from AdRoll/baker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnop.go
39 lines (29 loc) · 757 Bytes
/
nop.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
package output
import (
"sync/atomic"
"github.com/AdRoll/baker"
)
var NopDesc = baker.OutputDesc{
Name: "Nop",
New: NewNop,
Config: &NopConfig{},
Help: "No-operation output. This output simply drops all lines and does not write them anywhere.",
}
type Nop struct{ totaln int64 }
type NopConfig struct{}
func NewNop(cfg baker.OutputParams) (baker.Output, error) {
return &Nop{}, nil
}
func (b *Nop) CanShard() bool { return true }
func (nop *Nop) Run(input <-chan baker.OutputRecord, upch chan<- string) error {
for range input {
atomic.AddInt64(&nop.totaln, 1)
}
return nil
}
func (nop *Nop) Stats() baker.OutputStats {
return baker.OutputStats{
NumProcessedLines: atomic.LoadInt64(&nop.totaln),
NumErrorLines: 0,
}
}