This repository was archived by the owner on Jan 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
82 lines (69 loc) · 1.4 KB
/
interface.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package graphpipe
type Result int
const (
Skip = 0 // Emit nothing
Update = 1 << iota // Activate children
More = 1 << iota // Request for next update
)
func (r Result) String() string {
if r == 0 {
return "-"
}
s := ""
if r&Update > 0 {
s = s + "U"
} else if r&More > 0 {
s = s + "+"
}
return s
}
// Node represents an updatable node in the pipeline.
type Node interface {
Update(tid int) Result
}
// SourceNode can emit signals to request an update.
type SourceNode interface {
Node
// Start will be called on first iteration.
// When the source is ready to emit a value, send a bool to ch.
Start(ch chan<- bool)
}
// IntSouce emits int.
type IntSource interface {
Value() (int, int)
Closed() bool
}
// Int32Source emits int32.
type Int32Source interface {
Value() (int, int32)
Closed() bool
}
// Int64Source emits int64.
type Int64Source interface {
Value() (int, int64)
Closed() bool
}
// StringSource emits string.
type StringSource interface {
Value() (int, string)
Closed() bool
}
// Float32Source emits float32.
type Float32Source interface {
Value() (int, float32)
Closed() bool
}
// Float64Source emits float64.
type Float64Source interface {
Value() (int, float64)
Closed() bool
}
// NilSource emits nothing.
type NilSource interface {
Value() int
Closed() bool
}
// AnySource emits anything (or do no emit at all).
type AnySource interface {
Closed() bool
}