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.
Open-IM-Server/pkg/common/cmd/rpc.go

30 lines
731 B

2 years ago
package cmd
import (
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/startrpc"
2 years ago
"github.com/spf13/cobra"
2 years ago
"google.golang.org/grpc"
)
2 years ago
type RpcCmd struct {
2 years ago
*RootCmd
}
2 years ago
func NewRpcCmd(name string) *RpcCmd {
authCmd := &RpcCmd{NewRootCmd(name)}
2 years ago
return authCmd
2 years ago
}
2 years ago
func (a *RpcCmd) Exec() error {
a.Command.Run = func(cmd *cobra.Command, args []string) {
2 years ago
a.port = a.getPortFlag(cmd)
a.prometheusPort = a.getPrometheusPortFlag(cmd)
}
2 years ago
return a.Execute()
2 years ago
}
2 years ago
2 years ago
func (a *RpcCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
2 years ago
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
2 years ago
}