You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
608 B
Go
31 lines
608 B
Go
4 years ago
|
package resolver
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
|
||
|
"google.golang.org/grpc/resolver"
|
||
|
)
|
||
|
|
||
|
type directBuilder struct{}
|
||
|
|
||
|
func (d *directBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (
|
||
|
resolver.Resolver, error) {
|
||
|
var addrs []resolver.Address
|
||
|
endpoints := strings.Split(target.Endpoint, EndpointSep)
|
||
|
|
||
|
for _, val := range subset(endpoints, subsetSize) {
|
||
|
addrs = append(addrs, resolver.Address{
|
||
|
Addr: val,
|
||
|
})
|
||
|
}
|
||
|
cc.UpdateState(resolver.State{
|
||
|
Addresses: addrs,
|
||
|
})
|
||
|
|
||
|
return &nopResolver{cc: cc}, nil
|
||
|
}
|
||
|
|
||
|
func (d *directBuilder) Scheme() string {
|
||
|
return DirectScheme
|
||
|
}
|