Moved to google.golang.org/genproto/googleapis/api/annotations

Fixes #52
This commit is contained in:
Valerio Gheri
2017-03-31 18:01:58 +02:00
parent 024c5a4e4e
commit c40779224f
2037 changed files with 831329 additions and 1854 deletions

32
vendor/github.com/go-kit/kit/sd/lb/random.go generated vendored Normal file
View File

@@ -0,0 +1,32 @@
package lb
import (
"math/rand"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/sd"
)
// NewRandom returns a load balancer that selects services randomly.
func NewRandom(s sd.Subscriber, seed int64) Balancer {
return &random{
s: s,
r: rand.New(rand.NewSource(seed)),
}
}
type random struct {
s sd.Subscriber
r *rand.Rand
}
func (r *random) Endpoint() (endpoint.Endpoint, error) {
endpoints, err := r.s.Endpoints()
if err != nil {
return nil, err
}
if len(endpoints) <= 0 {
return nil, ErrNoEndpoints
}
return endpoints[r.r.Intn(len(endpoints))], nil
}