nevermind on ns lookup, because thats just configsvr on mongo
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/buraksezer/consistent"
|
||||
"github.com/cespare/xxhash"
|
||||
@@ -98,7 +99,12 @@ func (c *Client) scatterGather(key string, forEach func(addr string, each chan r
|
||||
out := make(map[string]int)
|
||||
done := false
|
||||
for i := 0; i < len(members); i++ {
|
||||
one := <-each
|
||||
var one result
|
||||
select {
|
||||
case <-time.After(time.Second * 10):
|
||||
continue
|
||||
case one = <-each:
|
||||
}
|
||||
if done {
|
||||
continue
|
||||
}
|
||||
@@ -111,12 +117,18 @@ func (c *Client) scatterGather(key string, forEach func(addr string, each chan r
|
||||
done = true
|
||||
}
|
||||
}
|
||||
close(each)
|
||||
if !done {
|
||||
final <- result{err: errors.New("no consensus")}
|
||||
}
|
||||
close(final)
|
||||
}()
|
||||
consensus := <-final
|
||||
return consensus.b, consensus.err
|
||||
select {
|
||||
case <-time.After(time.Second * 10):
|
||||
return nil, errors.New("timeout on consensus")
|
||||
case consensus := <-final:
|
||||
return consensus.b, consensus.err
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Get(key string) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user