You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
908 B
36 lines
908 B
package cmd
|
|
|
|
import (
|
|
"OpenIM/internal/startrpc"
|
|
"OpenIM/pkg/common/config"
|
|
"OpenIM/pkg/discoveryregistry"
|
|
"fmt"
|
|
"github.com/spf13/cobra"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
type RpcCmd struct {
|
|
*RootCmd
|
|
rpcRegisterName string
|
|
}
|
|
|
|
func NewRpcCmd(rpcRegisterName string) *RpcCmd {
|
|
rpcCmd := &RpcCmd{NewRootCmd(), rpcRegisterName}
|
|
fmt.Println("line 18", *rpcCmd, rpcCmd, rpcRegisterName, config.Config.RpcRegisterName)
|
|
return rpcCmd
|
|
}
|
|
|
|
func (r *RpcCmd) AddRpc(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), r.rpcRegisterName, r.getPrometheusPortFlag(cmd), rpcFn)
|
|
}
|
|
}
|
|
|
|
func (r *RpcCmd) Exec(rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
|
fmt.Println(r)
|
|
|
|
r.AddRpc(rpcFn)
|
|
fmt.Println(r)
|
|
return r.Execute()
|
|
}
|