rely on MICRO_REGISTRY to swap registries
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -32,7 +32,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
r := runtime.New()
|
||||
r := runtime.New(cfg)
|
||||
return r.Start()
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user