2020-07-30 20:09:45 +08:00
|
|
|
package resolver
|
|
|
|
|
2020-08-25 18:36:30 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/resolver"
|
|
|
|
)
|
2020-07-30 20:09:45 +08:00
|
|
|
|
2020-08-06 20:55:38 +08:00
|
|
|
const (
|
2020-08-25 18:36:30 +08:00
|
|
|
DirectScheme = "direct"
|
|
|
|
DiscovScheme = "discov"
|
|
|
|
EndpointSepChar = ','
|
|
|
|
subsetSize = 32
|
2020-08-06 20:55:38 +08:00
|
|
|
)
|
|
|
|
|
2020-08-18 18:36:44 +08:00
|
|
|
var (
|
2020-08-25 18:36:30 +08:00
|
|
|
EndpointSep = fmt.Sprintf("%c", EndpointSepChar)
|
|
|
|
dirBuilder directBuilder
|
|
|
|
disBuilder discovBuilder
|
2020-08-18 18:36:44 +08:00
|
|
|
)
|
2020-07-31 17:33:08 +08:00
|
|
|
|
2020-08-18 18:36:44 +08:00
|
|
|
func RegisterResolver() {
|
|
|
|
resolver.Register(&dirBuilder)
|
|
|
|
resolver.Register(&disBuilder)
|
2020-07-31 17:33:08 +08:00
|
|
|
}
|
|
|
|
|
2020-08-18 18:36:44 +08:00
|
|
|
type nopResolver struct {
|
2020-08-04 11:59:39 +08:00
|
|
|
cc resolver.ClientConn
|
2020-07-31 17:33:08 +08:00
|
|
|
}
|
|
|
|
|
2020-08-18 18:36:44 +08:00
|
|
|
func (r *nopResolver) Close() {
|
2020-07-30 20:09:45 +08:00
|
|
|
}
|
|
|
|
|
2020-08-18 18:36:44 +08:00
|
|
|
func (r *nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
|
2020-07-30 20:09:45 +08:00
|
|
|
}
|