This commit is contained in:
wangchuxiao
2023-03-09 14:54:05 +08:00
parent 3bcc696826
commit 82f499f942
10 changed files with 40 additions and 17 deletions
+6 -7
View File
@@ -7,24 +7,23 @@ import (
"google.golang.org/grpc"
)
type AuthCmd struct {
type RpcCmd struct {
*RootCmd
}
func NewAuthCmd() *AuthCmd {
authCmd := &AuthCmd{NewRootCmd()}
func NewRpcCmd() *RpcCmd {
authCmd := &RpcCmd{NewRootCmd()}
return authCmd
}
func (a *AuthCmd) Exec() error {
a.Command.RunE = func(cmd *cobra.Command, args []string) error {
func (a *RpcCmd) Exec() error {
a.Command.Run = func(cmd *cobra.Command, args []string) {
a.port = a.getPortFlag(cmd)
a.prometheusPort = a.getPrometheusPortFlag(cmd)
return a.getConfFromCmdAndInit(cmd)
}
return a.Execute()
}
func (a *AuthCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
func (a *RpcCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
}