Remove duplicated code and use existant getRegistry() instead

This commit is contained in:
Ingmar Aasoja
2021-01-29 11:54:44 +02:00
parent 5c235be89b
commit f9954bb022
+2 -17
View File
@@ -1,7 +1,6 @@
package grpc package grpc
import ( import (
"os"
"strings" "strings"
"time" "time"
@@ -9,12 +8,8 @@ import (
mclient "github.com/micro/go-micro/v2/client" mclient "github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/client/grpc" "github.com/micro/go-micro/v2/client/grpc"
etcdr "github.com/micro/go-micro/v2/registry/etcd"
mdnsr "github.com/micro/go-micro/v2/registry/mdns"
"github.com/micro/go-micro/v2/registry"
"github.com/micro/go-plugins/wrapper/trace/opencensus/v2" "github.com/micro/go-plugins/wrapper/trace/opencensus/v2"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/wrapper/prometheus" "github.com/owncloud/ocis/ocis-pkg/wrapper/prometheus"
) )
@@ -22,17 +17,7 @@ import (
var DefaultClient = newGrpcClient() var DefaultClient = newGrpcClient()
func newGrpcClient() mclient.Client { func newGrpcClient() mclient.Client {
addresses := strings.Split(os.Getenv("MICRO_REGISTRY_ADDRESS"), ",") r := *registry.GetRegistry()
var r registry.Registry
switch os.Getenv("MICRO_REGISTRY") {
case "etcd":
r = etcdr.NewRegistry(
registry.Addrs(addresses...),
)
default:
r = mdnsr.NewRegistry()
}
c := grpc.NewClient( c := grpc.NewClient(
mclient.RequestTimeout(10*time.Second), mclient.RequestTimeout(10*time.Second),