Skip to content

Commit

Permalink
<feat> 完善grpc插件
Browse files Browse the repository at this point in the history
  • Loading branch information
ChansonWong committed Dec 25, 2019
1 parent 431574c commit 7d21545
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions grpc-server-plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
})

Expand Down

0 comments on commit 7d21545

Please sign in to comment.