-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel.go
More file actions
30 lines (26 loc) · 987 Bytes
/
Copy pathparallel.go
File metadata and controls
30 lines (26 loc) · 987 Bytes
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
package parallels
//import "github.com/SharedCode/parallels/database"
import "github.com/SharedCode/parallels/database/repository"
// Pipeline interface defines the sourcer and sinker method signatures needing implementation.
type Pipeline interface {
Sourcer() ([]repository.KeyValue,bool)
Sinker([]repository.KeyValue)
}
// RunnerDefault is synonymous to Runner but using default parameter values
// on multiThreadedSourcer & threadCountThreshold.
func RunDefault(methods Pipeline){
Run(methods, false, DefaultThreadCountThreshold)
}
// Runner executes the pipeline runner.
func Run(methods Pipeline, multiThreadedSourcer bool, threadCountThreshold int){
// passthrough caller "cast" to expected types the params/returns.
sourcer := func()(interface{},bool){
return methods.Sourcer()
}
sinker := func(obj interface{}){
b := obj.([]repository.KeyValue)
methods.Sinker(b)
}
pi := NewParallel(threadCountThreshold)
pi.Pipeline(sourcer, sinker, multiThreadedSourcer)
}