refactor: cmd update.

This commit is contained in:
Gordon 2024-04-15 12:27:09 +08:00
parent b8a0c41e2e
commit 2ac3ff5801
11 changed files with 22 additions and 22 deletions

View File

@ -41,7 +41,7 @@ func NewApiCmd() *ApiCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -50,6 +50,6 @@ func (a *ApiCmd) Exec() error {
return a.Execute()
}
func (a *ApiCmd) preRunE() error {
func (a *ApiCmd) runE() error {
return api.Start(a.ctx, a.Index(), a.apiConfig)
}

View File

@ -42,7 +42,7 @@ func NewAuthRpcCmd() *AuthRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
@ -52,7 +52,7 @@ func (a *AuthRpcCmd) Exec() error {
return a.Execute()
}
func (a *AuthRpcCmd) preRunE() error {
func (a *AuthRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.authConfig.ZookeeperConfig, &a.authConfig.RpcConfig.Prometheus, a.authConfig.RpcConfig.RPC.ListenIP,
a.authConfig.RpcConfig.RPC.RegisterIP, a.authConfig.RpcConfig.RPC.Ports,
a.Index(), a.authConfig.Share.RpcRegisterName.Auth, &a.authConfig.Share, a.authConfig, auth.Start)

View File

@ -43,7 +43,7 @@ func NewCronTaskCmd() *CronTaskCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -52,6 +52,6 @@ func (a *CronTaskCmd) Exec() error {
return a.Execute()
}
func (a *CronTaskCmd) preRunE() error {
func (a *CronTaskCmd) runE() error {
return tools.Start(a.ctx, a.cronTaskConfig)
}

View File

@ -46,7 +46,7 @@ func NewFriendRpcCmd() *FriendRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -55,7 +55,7 @@ func (a *FriendRpcCmd) Exec() error {
return a.Execute()
}
func (a *FriendRpcCmd) preRunE() error {
func (a *FriendRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.friendConfig.ZookeeperConfig, &a.friendConfig.RpcConfig.Prometheus, a.friendConfig.RpcConfig.RPC.ListenIP,
a.friendConfig.RpcConfig.RPC.RegisterIP, a.friendConfig.RpcConfig.RPC.Ports,
a.Index(), a.friendConfig.Share.RpcRegisterName.Friend, &a.friendConfig.Share, a.friendConfig, friend.Start)

View File

@ -47,7 +47,7 @@ func NewGroupRpcCmd() *GroupRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -56,7 +56,7 @@ func (a *GroupRpcCmd) Exec() error {
return a.Execute()
}
func (a *GroupRpcCmd) preRunE() error {
func (a *GroupRpcCmd) runE() error {
log.CInfo(a.ctx, "GroupRpcCmd preRunE", "rpc config", a.groupConfig.RpcConfig)
return startrpc.Start(a.ctx, &a.groupConfig.ZookeeperConfig, &a.groupConfig.RpcConfig.Prometheus, a.groupConfig.RpcConfig.RPC.ListenIP,
a.groupConfig.RpcConfig.RPC.RegisterIP, a.groupConfig.RpcConfig.RPC.Ports,

View File

@ -47,7 +47,7 @@ func NewMsgRpcCmd() *MsgRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -56,7 +56,7 @@ func (a *MsgRpcCmd) Exec() error {
return a.Execute()
}
func (a *MsgRpcCmd) preRunE() error {
func (a *MsgRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.msgConfig.ZookeeperConfig, &a.msgConfig.RpcConfig.Prometheus, a.msgConfig.RpcConfig.RPC.ListenIP,
a.msgConfig.RpcConfig.RPC.RegisterIP, a.msgConfig.RpcConfig.RPC.Ports,
a.Index(), a.msgConfig.Share.RpcRegisterName.Msg, &a.msgConfig.Share, a.msgConfig, msg.Start)

View File

@ -43,7 +43,7 @@ func NewMsgGatewayCmd() *MsgGatewayCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -52,6 +52,6 @@ func (m *MsgGatewayCmd) Exec() error {
return m.Execute()
}
func (m *MsgGatewayCmd) preRunE() error {
func (m *MsgGatewayCmd) runE() error {
return msggateway.Start(m.ctx, m.Index(), m.msgGatewayConfig)
}

View File

@ -44,7 +44,7 @@ func NewMsgTransferCmd() *MsgTransferCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -53,6 +53,6 @@ func (m *MsgTransferCmd) Exec() error {
return m.Execute()
}
func (m *MsgTransferCmd) preRunE() error {
func (m *MsgTransferCmd) runE() error {
return msgtransfer.Start(m.ctx, m.Index(), m.msgTransferConfig)
}

View File

@ -47,7 +47,7 @@ func NewPushRpcCmd() *PushRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -56,7 +56,7 @@ func (a *PushRpcCmd) Exec() error {
return a.Execute()
}
func (a *PushRpcCmd) preRunE() error {
func (a *PushRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.pushConfig.ZookeeperConfig, &a.pushConfig.RpcConfig.Prometheus, a.pushConfig.RpcConfig.RPC.ListenIP,
a.pushConfig.RpcConfig.RPC.RegisterIP, a.pushConfig.RpcConfig.RPC.Ports,
a.Index(), a.pushConfig.Share.RpcRegisterName.Push, &a.pushConfig.Share, a.pushConfig, push.Start)

View File

@ -46,7 +46,7 @@ func NewThirdRpcCmd() *ThirdRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -55,7 +55,7 @@ func (a *ThirdRpcCmd) Exec() error {
return a.Execute()
}
func (a *ThirdRpcCmd) preRunE() error {
func (a *ThirdRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.thirdConfig.ZookeeperConfig, &a.thirdConfig.RpcConfig.Prometheus, a.thirdConfig.RpcConfig.RPC.ListenIP,
a.thirdConfig.RpcConfig.RPC.RegisterIP, a.thirdConfig.RpcConfig.RPC.Ports,
a.Index(), a.thirdConfig.Share.RpcRegisterName.Third, &a.thirdConfig.Share, a.thirdConfig, third.Start)

View File

@ -47,7 +47,7 @@ func NewUserRpcCmd() *UserRpcCmd {
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE()
return ret.runE()
}
return ret
}
@ -56,7 +56,7 @@ func (a *UserRpcCmd) Exec() error {
return a.Execute()
}
func (a *UserRpcCmd) preRunE() error {
func (a *UserRpcCmd) runE() error {
return startrpc.Start(a.ctx, &a.userConfig.ZookeeperConfig, &a.userConfig.RpcConfig.Prometheus, a.userConfig.RpcConfig.RPC.ListenIP,
a.userConfig.RpcConfig.RPC.RegisterIP, a.userConfig.RpcConfig.RPC.Ports,
a.Index(), a.userConfig.Share.RpcRegisterName.User, &a.userConfig.Share, a.userConfig, user.Start)