named things so we could detect replication target

This commit is contained in:
Stephen McQuay 2013-05-14 21:42:24 -07:00
parent 530ac5a0e5
commit 11f4236d03

View File

@ -6,12 +6,6 @@ import (
"time" "time"
) )
var (
Web = fakeSearch("web")
Image = fakeSearch("image")
Video = fakeSearch("video")
)
type Search func(query string) Result type Search func(query string) Result
type Result struct { type Result struct {
@ -38,9 +32,15 @@ func First(query string, replicas ...Search) Result {
func Google(query string) (results []Result) { func Google(query string) (results []Result) {
c := make(chan Result) c := make(chan Result)
go func() { c <- First(query, Web, Web) }() go func() {
go func() { c <- First(query, Image, Image) }() c <- First(query, fakeSearch("web 1"), fakeSearch("web 2"))
go func() { c <- First(query, Video, Video) }() }()
go func() {
c <- First(query, fakeSearch("vid 1"), fakeSearch("vid 2"))
}()
go func() {
c <- First(query, fakeSearch("img 1"), fakeSearch("img 2"))
}()
timeout := time.After(80 * time.Millisecond) timeout := time.After(80 * time.Millisecond)
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {