From 3ce1e6ed71c52f744b38feaf7f050379fcddb8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=86=89=E5=A2=A8=E5=B1=85=E5=A3=AB?= <94230530+go75@users.noreply.github.com> Date: Thu, 2 Nov 2023 12:27:59 +0800 Subject: [PATCH] Optimize the control structure (#1294) * cicd: robot automated Change * cicd: robot automated Change --------- Co-authored-by: go75 --- cmd/openim-api/main.go | 1 + internal/msgtransfer/init.go | 6 ++++-- internal/rpc/conversation/conversaion.go | 2 +- internal/tools/msg.go | 6 ++++-- pkg/apistruct/manage.go | 2 +- pkg/common/cmd/api.go | 4 +++- pkg/common/cmd/rpc.go | 4 +++- pkg/common/config/parse.go | 3 ++- pkg/common/db/relation/mysql_init.go | 3 ++- .../k8s_discovery_register.go | 6 ++++-- pkg/common/version/base.go | 6 +++--- pkg/common/version/types.go | 18 +++++++++--------- pkg/common/version/version.go | 16 ++++++++-------- 13 files changed, 45 insertions(+), 32 deletions(-) diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go index d1f5cb3f8..174300dc7 100644 --- a/cmd/openim-api/main.go +++ b/cmd/openim-api/main.go @@ -26,6 +26,7 @@ import ( "github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/OpenIMSDK/tools/log" + "github.com/openimsdk/open-im-server/v3/internal/api" "github.com/openimsdk/open-im-server/v3/pkg/common/cmd" "github.com/openimsdk/open-im-server/v3/pkg/common/config" diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index 4487826ee..7efc35794 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -16,10 +16,12 @@ package msgtransfer import ( "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" + "sync" + "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "sync" + + "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" "github.com/OpenIMSDK/tools/mw" diff --git a/internal/rpc/conversation/conversaion.go b/internal/rpc/conversation/conversaion.go index 0ea7d54be..d39881b35 100644 --- a/internal/rpc/conversation/conversaion.go +++ b/internal/rpc/conversation/conversaion.go @@ -112,7 +112,7 @@ func (c *conversationServer) SetConversation(ctx context.Context, req *pbconvers return resp, nil } -//nolint +// nolint func (c *conversationServer) SetConversations(ctx context.Context, req *pbconversation.SetConversationsReq, ) (*pbconversation.SetConversationsResp, error) { diff --git a/internal/tools/msg.go b/internal/tools/msg.go index 5397689b2..ca095051c 100644 --- a/internal/tools/msg.go +++ b/internal/tools/msg.go @@ -17,11 +17,13 @@ package tools import ( "context" "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" + "math" + "github.com/redis/go-redis/v9" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "math" + + "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register" "github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/log" diff --git a/pkg/apistruct/manage.go b/pkg/apistruct/manage.go index 1238b4757..411bd5662 100644 --- a/pkg/apistruct/manage.go +++ b/pkg/apistruct/manage.go @@ -41,7 +41,7 @@ type SendMsgReq struct { type BatchSendMsgReq struct { SendMsg IsSendAll bool `json:"isSendAll"` - RecvIDs []string `json:"recvIDs" binding:"required"` + RecvIDs []string `json:"recvIDs" binding:"required"` } type BatchSendMsgResp struct { diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go index 7ce872fac..6c74ddad9 100644 --- a/pkg/common/cmd/api.go +++ b/pkg/common/cmd/api.go @@ -16,9 +16,11 @@ package cmd import ( "fmt" + "github.com/OpenIMSDK/protocol/constant" - config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/spf13/cobra" + + config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) type ApiCmd struct { diff --git a/pkg/common/cmd/rpc.go b/pkg/common/cmd/rpc.go index 224edc0a0..0ccc37fcb 100644 --- a/pkg/common/cmd/rpc.go +++ b/pkg/common/cmd/rpc.go @@ -16,11 +16,13 @@ package cmd import ( "errors" + "github.com/OpenIMSDK/protocol/constant" - config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/spf13/cobra" "google.golang.org/grpc" + config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" + "github.com/OpenIMSDK/tools/discoveryregistry" "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc" diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 2c20f1a98..fee5efbe9 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -21,8 +21,9 @@ import ( "path/filepath" "github.com/OpenIMSDK/protocol/constant" - "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" "gopkg.in/yaml.v3" + + "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" ) //go:embed version diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go index 16b8c99fa..41399d5ca 100644 --- a/pkg/common/db/relation/mysql_init.go +++ b/pkg/common/db/relation/mysql_init.go @@ -22,10 +22,11 @@ import ( "github.com/OpenIMSDK/tools/log" "github.com/OpenIMSDK/tools/mw/specialerror" mysqldriver "github.com/go-sql-driver/mysql" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" "gorm.io/driver/mysql" "gorm.io/gorm" "gorm.io/gorm/logger" + + "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) const ( diff --git a/pkg/common/discovery_register/k8s_discovery_register.go b/pkg/common/discovery_register/k8s_discovery_register.go index 811d35b96..81543a447 100644 --- a/pkg/common/discovery_register/k8s_discovery_register.go +++ b/pkg/common/discovery_register/k8s_discovery_register.go @@ -4,12 +4,14 @@ import ( "context" "errors" "fmt" + "time" + "github.com/OpenIMSDK/tools/discoveryregistry" openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper" "github.com/OpenIMSDK/tools/log" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" "google.golang.org/grpc" - "time" + + "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistry, error) { diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go index 4161107c1..ac214269f 100644 --- a/pkg/common/version/base.go +++ b/pkg/common/version/base.go @@ -40,8 +40,8 @@ var ( // companion .gitattributes file containing 'export-subst' in this same // directory. See also https://git-scm.com/docs/gitattributes gitVersion string = "latest" - gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD) - gitTreeState string = "" // state of git tree, either "clean" or "dirty" + gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD) + gitTreeState string = "" // state of git tree, either "clean" or "dirty" buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') -) \ No newline at end of file +) diff --git a/pkg/common/version/types.go b/pkg/common/version/types.go index 3512640cc..ee4664149 100644 --- a/pkg/common/version/types.go +++ b/pkg/common/version/types.go @@ -4,15 +4,15 @@ package version // TODO: Add []string of api versions supported? It's still unclear // how we'll want to distribute that information. type Info struct { - Major string `json:"major,omitempty"` - Minor string `json:"minor,omitempty"` - GitVersion string `json:"gitVersion"` + Major string `json:"major,omitempty"` + Minor string `json:"minor,omitempty"` + GitVersion string `json:"gitVersion"` GitTreeState string `json:"gitTreeState,omitempty"` - GitCommit string `json:"gitCommit,omitempty"` - BuildDate string `json:"buildDate"` - GoVersion string `json:"goVersion"` - Compiler string `json:"compiler"` - Platform string `json:"platform"` + GitCommit string `json:"gitCommit,omitempty"` + BuildDate string `json:"buildDate"` + GoVersion string `json:"goVersion"` + Compiler string `json:"compiler"` + Platform string `json:"platform"` } type Output struct { @@ -21,7 +21,7 @@ type Output struct { } type OpenIMClientVersion struct { - ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version + ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version } // String returns info as a human-friendly version string. diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go index b841c3f65..b8ccfaf81 100644 --- a/pkg/common/version/version.go +++ b/pkg/common/version/version.go @@ -13,15 +13,15 @@ func Get() Info { // These variables typically come from -ldflags settings and in // their absence fallback to the settings in ./base.go return Info{ - Major: gitMajor, - Minor: gitMinor, - GitVersion: gitVersion, + Major: gitMajor, + Minor: gitMinor, + GitVersion: gitVersion, GitTreeState: gitTreeState, - GitCommit: gitCommit, - BuildDate: buildDate, - GoVersion: runtime.Version(), - Compiler: runtime.Compiler, - Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), + GitCommit: gitCommit, + BuildDate: buildDate, + GoVersion: runtime.Version(), + Compiler: runtime.Compiler, + Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), } }