From 7d21545391a8dac50da7ce9580c790720e31a1b7 Mon Sep 17 00:00:00 2001 From: huangguochao <917929050@qq.com> Date: Wed, 25 Dec 2019 11:40:43 +0800 Subject: [PATCH] =?UTF-8?q?=20=E5=AE=8C=E5=96=84grpc=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grpc-server-plugin.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/grpc-server-plugin.go b/grpc-server-plugin.go index 3e78f59..7b3bca9 100644 --- a/grpc-server-plugin.go +++ b/grpc-server-plugin.go @@ -15,24 +15,28 @@ import ( var Server = struct { RunMode string `yaml:"runmode"` GRPCPort string `yaml:"grpcport"` - ConsulHost string `yaml:"ConsulHost"` - ConsulPort string `yaml:"ConsulPort"` ServerName string `yaml:"servername"` }{} +var Registry = struct { + Type string `yaml:"type"` + Host string `yaml:"host"` +}{} + var Service micro.Service func init() { config, err := ioutil.ReadFile("config/server.yml") + registyConfig, err := ioutil.ReadFile("config/registry.yml") if err != nil { fmt.Print(err) } yaml.Unmarshal(config, &Server) + yaml.Unmarshal(registyConfig, &Registry) - consulAddress := Server.ConsulHost + ":" + Server.ConsulPort reg := consul.NewRegistry(func(op *registry.Options) { op.Addrs = []string{ - consulAddress, + Registry.Host, } })