From 2ac3ff5801e60cdc03a36473ce235a035d85004d Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Mon, 15 Apr 2024 12:27:09 +0800 Subject: [PATCH] refactor: cmd update. --- pkg/common/cmd/api.go | 4 ++-- pkg/common/cmd/auth.go | 4 ++-- pkg/common/cmd/cron_task.go | 4 ++-- pkg/common/cmd/friend.go | 4 ++-- pkg/common/cmd/group.go | 4 ++-- pkg/common/cmd/msg.go | 4 ++-- pkg/common/cmd/msg_gateway.go | 4 ++-- pkg/common/cmd/msg_transfer.go | 4 ++-- pkg/common/cmd/push.go | 4 ++-- pkg/common/cmd/third.go | 4 ++-- pkg/common/cmd/user.go | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go index fdd840bf0..460fd0ac9 100644 --- a/pkg/common/cmd/api.go +++ b/pkg/common/cmd/api.go @@ -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) } diff --git a/pkg/common/cmd/auth.go b/pkg/common/cmd/auth.go index 8b76ae2d6..5ed02ffd0 100644 --- a/pkg/common/cmd/auth.go +++ b/pkg/common/cmd/auth.go @@ -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) diff --git a/pkg/common/cmd/cron_task.go b/pkg/common/cmd/cron_task.go index b29cee2ce..0e94cf52c 100644 --- a/pkg/common/cmd/cron_task.go +++ b/pkg/common/cmd/cron_task.go @@ -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) } diff --git a/pkg/common/cmd/friend.go b/pkg/common/cmd/friend.go index 6ca57c733..b8d46f77e 100644 --- a/pkg/common/cmd/friend.go +++ b/pkg/common/cmd/friend.go @@ -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) diff --git a/pkg/common/cmd/group.go b/pkg/common/cmd/group.go index d5638ae6c..4773ebf9c 100644 --- a/pkg/common/cmd/group.go +++ b/pkg/common/cmd/group.go @@ -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, diff --git a/pkg/common/cmd/msg.go b/pkg/common/cmd/msg.go index d90380743..a3b521b4b 100644 --- a/pkg/common/cmd/msg.go +++ b/pkg/common/cmd/msg.go @@ -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) diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go index bda0efaf9..897fd7008 100644 --- a/pkg/common/cmd/msg_gateway.go +++ b/pkg/common/cmd/msg_gateway.go @@ -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) } diff --git a/pkg/common/cmd/msg_transfer.go b/pkg/common/cmd/msg_transfer.go index 9e7457fed..86f42dc56 100644 --- a/pkg/common/cmd/msg_transfer.go +++ b/pkg/common/cmd/msg_transfer.go @@ -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) } diff --git a/pkg/common/cmd/push.go b/pkg/common/cmd/push.go index 0dca75fa0..0140ced23 100644 --- a/pkg/common/cmd/push.go +++ b/pkg/common/cmd/push.go @@ -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) diff --git a/pkg/common/cmd/third.go b/pkg/common/cmd/third.go index 5c8e1ed8f..0dfa7d5be 100644 --- a/pkg/common/cmd/third.go +++ b/pkg/common/cmd/third.go @@ -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) diff --git a/pkg/common/cmd/user.go b/pkg/common/cmd/user.go index cf9b211d3..315b93256 100644 --- a/pkg/common/cmd/user.go +++ b/pkg/common/cmd/user.go @@ -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)