forked from clandry94/agraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.go
48 lines (38 loc) · 729 Bytes
/
filter.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
package agraph
import "fmt"
type FilterGraph struct {
Nodes map[string]Node
}
func (g FilterGraph) Insert(node *Node) error {
return nil
}
func (g FilterGraph) Remove(node *Node) error {
return nil
}
func (g FilterGraph) Process(data []uint8) {
}
type Node interface{
process()
}
type NopFilter struct {
Source chan []byte
Sink chan []byte
Next chan []byte
}
func (n NopFilter) process() error {
for {
select {
case data := <-n.Source:
fmt.Println("found data")
var filteredData, err = n.do(&data)
if err != nil {
panic("Could not filter!")
}
n.Sink <- filteredData
}
}
return nil
}
func (n NopFilter) do(data *[]byte) ([]byte, error) {
return []byte("Hello, world!"), nil
}