go-zero/zrpc/resolver/internal/resolver.go

51 lines
1.1 KiB
Go
Raw Normal View History

package internal
2020-07-30 20:09:45 +08:00
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 (
2021-03-02 00:04:12 +08:00
// DirectScheme stands for direct scheme.
2021-03-01 23:52:44 +08:00
DirectScheme = "direct"
2021-03-02 00:04:12 +08:00
// DiscovScheme stands for discov scheme.
2021-03-01 23:52:44 +08:00
DiscovScheme = "discov"
// EtcdScheme stands for etcd scheme.
EtcdScheme = "etcd"
// KubernetesScheme stands for k8s scheme.
KubernetesScheme = "k8s"
2021-03-02 00:04:12 +08:00
// EndpointSepChar is the separator cha in endpoints.
2020-08-25 18:36:30 +08:00
EndpointSepChar = ','
2021-03-01 23:52:44 +08:00
subsetSize = 32
2020-08-06 20:55:38 +08:00
)
2020-08-18 18:36:44 +08:00
var (
2021-03-02 00:04:12 +08:00
// EndpointSep is the separator string in endpoints.
2020-08-25 18:36:30 +08:00
EndpointSep = fmt.Sprintf("%c", EndpointSepChar)
2021-03-01 23:52:44 +08:00
directResolverBuilder directBuilder
discovResolverBuilder discovBuilder
etcdResolverBuilder etcdBuilder
k8sResolverBuilder kubeBuilder
2020-08-18 18:36:44 +08:00
)
2020-07-31 17:33:08 +08:00
2021-03-02 00:04:12 +08:00
// RegisterResolver registers the direct and discov schemes to the resolver.
2020-08-18 18:36:44 +08:00
func RegisterResolver() {
resolver.Register(&directResolverBuilder)
resolver.Register(&discovResolverBuilder)
resolver.Register(&etcdResolverBuilder)
resolver.Register(&k8sResolverBuilder)
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
}