open-im-server/pkg/common/cmd/msg_gateway.go
Xinwei Xiong(cubxxw-openim) 166ddb1e34 style: add format
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-07-10 18:13:29 +08:00

38 lines
907 B
Go

package cmd
import (
"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
//"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
"github.com/spf13/cobra"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
)
type MsgGatewayCmd struct {
*RootCmd
}
func NewMsgGatewayCmd() MsgGatewayCmd {
return MsgGatewayCmd{NewRootCmd("msgGateway")}
}
func (m *MsgGatewayCmd) AddWsPortFlag() {
m.Command.Flags().IntP(constant.FlagWsPort, "w", 0, "ws server listen port")
}
func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int {
port, _ := cmd.Flags().GetInt(constant.FlagWsPort)
return port
}
func (m *MsgGatewayCmd) addRunE() {
m.Command.RunE = func(cmd *cobra.Command, args []string) error {
return msggateway.RunWsAndServer(m.getPortFlag(cmd), m.getWsPortFlag(cmd), m.getPrometheusPortFlag(cmd))
}
}
func (m *MsgGatewayCmd) Exec() error {
m.addRunE()
return m.Execute()
}