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.
go-zero/zrpc/internal/resolver/resolver.go

47 lines
939 B
Go

4 years ago
package resolver
import (
"fmt"
"google.golang.org/grpc/resolver"
)
4 years ago
const (
// DirectScheme stands for direct scheme.
DirectScheme = "direct"
// DiscovScheme stands for discov scheme.
DiscovScheme = "discov"
// KubernetesScheme stands for k8s scheme.
KubernetesScheme = "k8s"
// EndpointSepChar is the separator cha in endpoints.
EndpointSepChar = ','
subsetSize = 32
)
var (
// EndpointSep is the separator string in endpoints.
EndpointSep = fmt.Sprintf("%c", EndpointSepChar)
dirBuilder directBuilder
disBuilder discovBuilder
k8sBuilder kubeBuilder
)
4 years ago
// RegisterResolver registers the direct and discov schemes to the resolver.
func RegisterResolver() {
resolver.Register(&dirBuilder)
resolver.Register(&disBuilder)
resolver.Register(&k8sBuilder)
4 years ago
}
type nopResolver struct {
cc resolver.ClientConn
4 years ago
}
func (r *nopResolver) Close() {
4 years ago
}
func (r *nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
4 years ago
}