mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
20f665ede8
* implement k8s service discovery * simplify code * use default namespace if not provided * disable codecov bot comment * ignore adhoc dir * simplify building target in NewClient * reformat code * Fix filepath (#990) * format code, and reorg imports (#991) * add more unit test Co-authored-by: anqiansong <anqiansong@gmail.com>
47 lines
939 B
Go
47 lines
939 B
Go
package resolver
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"google.golang.org/grpc/resolver"
|
|
)
|
|
|
|
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
|
|
)
|
|
|
|
// RegisterResolver registers the direct and discov schemes to the resolver.
|
|
func RegisterResolver() {
|
|
resolver.Register(&dirBuilder)
|
|
resolver.Register(&disBuilder)
|
|
resolver.Register(&k8sBuilder)
|
|
}
|
|
|
|
type nopResolver struct {
|
|
cc resolver.ClientConn
|
|
}
|
|
|
|
func (r *nopResolver) Close() {
|
|
}
|
|
|
|
func (r *nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
|
|
}
|