|
|
@ -7,33 +7,23 @@ import (
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type RpcCmd struct {
|
|
|
|
type AuthCmd struct {
|
|
|
|
*RootCmd
|
|
|
|
*RootCmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewRpcCmd() *RpcCmd {
|
|
|
|
func NewAuthCmd() *AuthCmd {
|
|
|
|
rpcCmd := &RpcCmd{NewRootCmd()}
|
|
|
|
authCmd := &AuthCmd{NewRootCmd()}
|
|
|
|
return rpcCmd
|
|
|
|
return authCmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *RpcCmd) addRpc(rpcRegisterName string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) {
|
|
|
|
func (a *AuthCmd) Execute() error {
|
|
|
|
r.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
|
|
|
a.Command.Run = func(cmd *cobra.Command, args []string) {
|
|
|
|
return startrpc.Start(r.getPortFlag(cmd), rpcRegisterName, r.getPrometheusPortFlag(cmd), rpcFn)
|
|
|
|
a.port = a.getPortFlag(cmd)
|
|
|
|
|
|
|
|
a.prometheusPort = a.getPrometheusPortFlag(cmd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.Execute()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (r *RpcCmd) Exec(rpcRegisterName string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
|
|
|
func (a *AuthCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
|
|
|
r.addRpc(rpcRegisterName, rpcFn)
|
|
|
|
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
|
|
|
|
return r.Execute()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (r *RpcCmd) addRpc2(rpcRegisterName *string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) {
|
|
|
|
|
|
|
|
r.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
|
|
|
return startrpc.Start(r.getPortFlag(cmd), *rpcRegisterName, r.getPrometheusPortFlag(cmd), rpcFn)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (r *RpcCmd) Exec2(rpcRegisterName *string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
|
|
|
|
|
|
|
r.addRpc2(rpcRegisterName, rpcFn)
|
|
|
|
|
|
|
|
return r.Execute()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|