diff --git a/zrpc/resolver/internal/kubebuilder.go b/zrpc/resolver/internal/kubebuilder.go index a4a9c3b7..5eecec46 100644 --- a/zrpc/resolver/internal/kubebuilder.go +++ b/zrpc/resolver/internal/kubebuilder.go @@ -1,3 +1,5 @@ +//go:build !no_k8s + package internal import ( diff --git a/zrpc/resolver/internal/register.go b/zrpc/resolver/internal/register.go new file mode 100644 index 00000000..364b2c9a --- /dev/null +++ b/zrpc/resolver/internal/register.go @@ -0,0 +1,8 @@ +//go:build no_k8s + +package internal + +// RegisterResolver registers the direct, etcd and discov schemes to the resolver. +func RegisterResolver() { + register() +} diff --git a/zrpc/resolver/internal/register_k8s.go b/zrpc/resolver/internal/register_k8s.go new file mode 100644 index 00000000..6cac1469 --- /dev/null +++ b/zrpc/resolver/internal/register_k8s.go @@ -0,0 +1,13 @@ +//go:build !no_k8s + +package internal + +import "google.golang.org/grpc/resolver" + +var k8sResolverBuilder kubeBuilder + +// RegisterResolver registers the direct, etcd, discov and k8s schemes to the resolver. +func RegisterResolver() { + register() + resolver.Register(&k8sResolverBuilder) +} diff --git a/zrpc/resolver/internal/resolver.go b/zrpc/resolver/internal/resolver.go index 2d64ccc8..7868eca8 100644 --- a/zrpc/resolver/internal/resolver.go +++ b/zrpc/resolver/internal/resolver.go @@ -28,15 +28,12 @@ var ( directResolverBuilder directBuilder discovResolverBuilder discovBuilder etcdResolverBuilder etcdBuilder - k8sResolverBuilder kubeBuilder ) -// RegisterResolver registers the direct and discov schemes to the resolver. -func RegisterResolver() { +func register() { resolver.Register(&directResolverBuilder) resolver.Register(&discovResolverBuilder) resolver.Register(&etcdResolverBuilder) - resolver.Register(&k8sResolverBuilder) } type nopResolver struct {