rely on MICRO_REGISTRY to swap registries

This commit is contained in:
A.Unger
2020-11-11 15:28:22 +01:00
parent 4c1f14fc47
commit d0e28b6345
8 changed files with 69 additions and 19 deletions
+20 -2
View File
@@ -4,6 +4,12 @@ import (
"os"
"strings"
etcdr "github.com/micro/go-micro/v2/registry/etcd"
mdnsr "github.com/micro/go-micro/v2/registry/mdns"
"github.com/micro/go-micro/v2"
"github.com/micro/go-micro/v2/registry"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis/pkg/config"
@@ -14,7 +20,7 @@ import (
"github.com/spf13/viper"
)
// Execute is the entry point for the ocis-ocis command.
// Execute is the entry point for the ocis command.
func Execute() error {
cfg := config.New()
@@ -44,7 +50,19 @@ func Execute() error {
)
}
runtime.AddMicroPlatform(app)
var r registry.Registry
switch os.Getenv("MICRO_REGISTRY") {
case "etcd":
r = etcdr.NewRegistry()
default:
r = mdnsr.NewRegistry()
}
opts := micro.Options{
Registry: r,
}
runtime.AddMicroPlatform(app, opts)
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
+1 -1
View File
@@ -32,7 +32,7 @@ func Server(cfg *config.Config) *cli.Command {
return err
}
r := runtime.New()
r := runtime.New(cfg)
return r.Start()
},
}