mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
feat: optimize golang ci
This commit is contained in:
parent
32aeab262e
commit
6854a0965a
@ -593,11 +593,12 @@ linters-settings:
|
|||||||
- name: exported
|
- name: exported
|
||||||
severity: warning
|
severity: warning
|
||||||
- name: var-naming
|
- name: var-naming
|
||||||
arguments: [ ["ID", "HTTP", "URL", "URI", "URL", "URI", "API", "APIKey", "Token", "TokenID", "TokenSecret", "TokenKey", "TokenSecret", "JWT", "JWTToken", "JWTTokenID", "JWTTokenSecret", "JWTTokenKey", "JWTTokenSecret", "OAuth", "OAuthToken", "OAuth" ] ]
|
arguments: [ [ "OpenIM"] ]
|
||||||
|
# arguments: [ ["ID", "HTTP", "URL", "URI", "API", "APIKey", "Token", "TokenID", "TokenSecret", "TokenKey", "TokenSecret", "JWT", "JWTToken", "JWTTokenID", "JWTTokenSecret", "JWTTokenKey", "JWTTokenSecret", "OAuth", "OAuthToken", "RPC" ] ]
|
||||||
- name: atomic
|
- name: atomic
|
||||||
- name: line-length-limit
|
- name: line-length-limit
|
||||||
severity: error
|
severity: error
|
||||||
arguments: [80]
|
arguments: [200]
|
||||||
- name: unhandled-error
|
- name: unhandled-error
|
||||||
arguments : ["fmt.Printf", "myFunction"]
|
arguments : ["fmt.Printf", "myFunction"]
|
||||||
|
|
||||||
|
|||||||
2
pkg/common/db/cache/conversation.go
vendored
2
pkg/common/db/cache/conversation.go
vendored
@ -38,7 +38,7 @@ const (
|
|||||||
// recvMsgOptKey = "RECV_MSG_OPT:"
|
// recvMsgOptKey = "RECV_MSG_OPT:"
|
||||||
// superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
// superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
||||||
// superGroupRecvMsgNotNotifyUserIDsHashKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS_HASH:"
|
// superGroupRecvMsgNotNotifyUserIDsHashKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS_HASH:"
|
||||||
//conversationNotReceiveMessageUserIDsKey = "CONVERSATION_NOT_RECEIVE_MESSAGE_USER_IDS:".
|
// conversationNotReceiveMessageUserIDsKey = "CONVERSATION_NOT_RECEIVE_MESSAGE_USER_IDS:".
|
||||||
|
|
||||||
conversationExpireTime = time.Second * 60 * 60 * 12
|
conversationExpireTime = time.Second * 60 * 60 * 12
|
||||||
)
|
)
|
||||||
|
|||||||
@ -575,7 +575,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
|
|||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
// var seqs []int64
|
// var seqs []int64
|
||||||
//for i := end; i > end-num; i-- {
|
// for i := end; i > end-num; i-- {
|
||||||
// if i >= begin {
|
// if i >= begin {
|
||||||
// seqs = append([]int64{i}, seqs...)
|
// seqs = append([]int64{i}, seqs...)
|
||||||
// } else {
|
// } else {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -25,53 +24,56 @@ import (
|
|||||||
"github.com/openimsdk/open-im-server/v3/tools/component/checks"
|
"github.com/openimsdk/open-im-server/v3/tools/component/checks"
|
||||||
"github.com/openimsdk/open-im-server/v3/tools/component/util"
|
"github.com/openimsdk/open-im-server/v3/tools/component/util"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
"gopkg.in/yaml.v2"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/openimsdk/tools/errs"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/minio"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/minio"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const defaultCfgPath = "./config.yaml"
|
||||||
// defaultCfgPath is the default path of the configuration file.
|
const maxRetry = 100
|
||||||
defaultCfgPath = "../../../../../config/config.yaml"
|
|
||||||
maxRetry = 100
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
func initConfig(cfgPath string) error {
|
||||||
cfgPath = flag.String("c", defaultCfgPath, "Path to the configuration file")
|
viper.SetConfigType("yaml")
|
||||||
)
|
viper.AddConfigPath(".")
|
||||||
|
|
||||||
func initCfg() (*config.GlobalConfig, error) {
|
viper.SetConfigName("config")
|
||||||
data, err := os.ReadFile(*cfgPath)
|
viper.AddConfigPath("../../../../../config")
|
||||||
if err != nil {
|
|
||||||
return nil, errs.WrapMsg(err, "ReadFile unmarshal failed")
|
viper.SetEnvPrefix("openim")
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
|
if cfgPath != "" {
|
||||||
|
viper.SetConfigFile(cfgPath)
|
||||||
|
} else if envPath, ok := os.LookupEnv("OPENIM_CONFIG"); ok && envPath != "" {
|
||||||
|
viper.SetConfigFile(envPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := config.NewGlobalConfig()
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
err = yaml.Unmarshal(data, &conf)
|
return err
|
||||||
if err != nil {
|
|
||||||
return nil, errs.WrapMsg(err, "InitConfig unmarshal failed")
|
|
||||||
}
|
}
|
||||||
return conf, nil
|
|
||||||
|
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
var cfgFile string
|
||||||
|
pflag.StringVarP(&cfgFile, "config", "c", "", "config file (default is ./config.yaml)")
|
||||||
|
pflag.Parse()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
conf, err := initCfg()
|
|
||||||
if err != nil {
|
if err := initConfig(cfgFile); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Initialization failed: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Initialization failed: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := util.ConfigGetEnv(conf); err != nil {
|
// if err := util.ConfigGetEnv(conf); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Environment variable override failed: %v\n", err)
|
// fmt.Fprintf(os.Stderr, "Environment variable override failed: %v\n", err)
|
||||||
os.Exit(1)
|
// os.Exit(1)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Define a slice of functions to perform each service check
|
// Define a slice of functions to perform each service check
|
||||||
serviceChecks := []func(context.Context, *config.GlobalConfig) error{
|
serviceChecks := []func(context.Context, *config.GlobalConfig) error{
|
||||||
@ -89,11 +91,11 @@ func main() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.Object.Enable == "minio" {
|
if viper.GetString("object.enable") == "minio" {
|
||||||
minioConfig := checks.MinioCheck{
|
minioConfig := checks.MinioCheck{
|
||||||
Config: minio.Config(conf.Object.Minio),
|
Config: minio.Config(viper.GetString("object.minio")),
|
||||||
// UseSSL: conf.Minio.UseSSL,
|
// UseSSL: conf.Minio.UseSSL,
|
||||||
ApiURL: conf.Object.ApiURL,
|
ApiURL: viper.GetString("object.apiURL"),
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustUseSSL(&minioConfig)
|
adjustUseSSL(&minioConfig)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user