update
This commit is contained in:
@@ -53,6 +53,7 @@ type Server struct {
|
||||
|
||||
useDefaultBufferCfg bool
|
||||
delayStopMs int
|
||||
exposeHttp bool
|
||||
|
||||
serviceRegInfo *myregistry.ServiceInfo
|
||||
}
|
||||
@@ -82,6 +83,12 @@ func WithDelayStopMs(v int) Opt {
|
||||
}
|
||||
}
|
||||
|
||||
func WithExposeHttp(v bool) Opt {
|
||||
return func(server *Server) {
|
||||
server.exposeHttp = v
|
||||
}
|
||||
}
|
||||
|
||||
func SetFlag() {
|
||||
pflag.Int("grpc.port", 0, "listen port, 0 is random port")
|
||||
pflag.String("grpc.log", "true", "enable request log")
|
||||
@@ -206,6 +213,11 @@ func (s *Server) Run(ctx context.Context) error {
|
||||
ServiceName: s.serviceName,
|
||||
Ip: svcIp,
|
||||
Port: port,
|
||||
Extend: map[string]string{},
|
||||
}
|
||||
|
||||
if s.exposeHttp {
|
||||
s.serviceRegInfo.Extend["tag"] = mygrpc.ExposeHttpTag
|
||||
}
|
||||
|
||||
err = s.reg.Register(s.serviceRegInfo)
|
||||
|
||||
Reference in New Issue
Block a user