From 390c5b3e8b1cef66c0d878d4af6c3e5537fc1f6f Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 17:27:24 +0800 Subject: [PATCH 1/2] feat: add code lint --- .gitignore | 1 - .golangci.yml | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 5142fe551..fb8d428d2 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ deployments/charts/generated-configs/ ### OpenIM Config ### .env config/config.yaml -config/openim.yaml config/alertmanager.yml config/prometheus.yml config/email.tmpl diff --git a/.golangci.yml b/.golangci.yml index 6b8469b62..f0ca3a010 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,19 +39,19 @@ run: # from this option's value (see skip-dirs-use-default). # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-dirs: - - components - - docs - - util - - .*~ - - api/swagger/docs - - server/docs - - components/mnt/config/certs - - logs + # skip-dirs: + # - components + # - docs + # - util + # - .*~ + # - api/swagger/docs + # - server/docs + # - components/mnt/config/certs + # - logs # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true + # skip-dirs-use-default: true # which files to skip: they will be analyzed, but issues from them # won't be reported. Default value is empty list, but there is @@ -59,15 +59,15 @@ run: # autogenerated files. If it's not please let us know. # "/" will be replaced by current OS file path separator to properly work # on Windows. - skip-files: - - ".*\\.my\\.go$" - - _test.go - - ".*_test.go" - - "mocks/" - - ".github/" - - "logs/" - - "_output/" - - "components/" + # skip-files: + # - ".*\\.my\\.go$" + # - _test.go + # - ".*_test.go" + # - "mocks/" + # - ".github/" + # - "logs/" + # - "_output/" + # - "components/" # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit @@ -87,7 +87,7 @@ run: # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number + # format: colored-line-number # print lines of code with issue, default is true print-issued-lines: true @@ -150,6 +150,11 @@ linters-settings: comparison: true exhaustive: + # Program elements to check for exhaustiveness. + # Default: [ switch ] + check: + - switch + - map # check switch statements in generated files also check-generated: false # indicates that switch statements are to be considered exhaustive if a @@ -772,6 +777,7 @@ linters: - dupword - errname - gci + - exhaustive - gocritic - goprintffuncname - gomnd From cee74a016a74dab5e2842be75aaea0651a3f88a6 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com> Date: Tue, 2 Apr 2024 17:28:13 +0800 Subject: [PATCH 2/2] feat: add code lint --- config/openim.yaml | 260 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 config/openim.yaml diff --git a/config/openim.yaml b/config/openim.yaml new file mode 100644 index 000000000..4f17d24af --- /dev/null +++ b/config/openim.yaml @@ -0,0 +1,260 @@ +# openim.yaml 作为存放一些通用配置或特殊配置的文件,我们将包含日志、消息缓存、多登录策略、消息验证策略等配置。 +# 这些配置是跨多个服务的共享配置,它们对于整个系统的运行至关重要。 +log: + storageLocation: /data/workspaces/open-im-server/_output/logs/ + rotationTime: 24 + remainRotationCount: 2 + remainLogLevel: 6 + isStdout: false + isJson: false + withStack: false + +msgCacheTimeout: 86400 + +multiLoginPolicy: 1 + +messageVerify: + friendVerify: false + +tokenPolicy: + expire: 90 + +groupMessageHasReadReceiptEnable: true + +singleMessageHasReadReceiptEnable: true + +retainChatRecords: 365 + +chatRecordsClearTime: "0 2 * * 3" + +msgDestructTime: "0 2 * * *" + +secret: openIM123 + +iosPush: + pushSound: "xxx" + badgeCount: true + production: false + + +###################### Third-party service configuration ###################### +# Callback configuration +# +# Callback URL +# Whether to enable this callback event +# Timeout in seconds +# Whether to continue execution if callback fails +callback: + url: "http://127.0.0.1:10008/callbackExample" + beforeSendSingleMsg: + enable: false + timeout: 5 + failedContinue: true + beforeUpdateUserInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterUpdateUserInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterSendSingleMsg: + enable: false + timeout: 5 + failedContinue: true + beforeSendGroupMsg: + enable: false + timeout: 5 + failedContinue: true + afterSendGroupMsg: + enable: false + timeout: 5 + failedContinue: true + msgModify: + enable: false + timeout: 5 + failedContinue: true + userOnline: + enable: false + timeout: 5 + failedContinue: true + userOffline: + enable: false + timeout: 5 + failedContinue: true + userKickOff: + enable: false + timeout: 5 + failedContinue: true + offlinePush: + enable: false + timeout: 5 + failedContinue: true + onlinePush: + enable: false + timeout: 5 + failedContinue: true + superGroupOnlinePush: + enable: false + timeout: 5 + failedContinue: true + beforeAddFriend: + enable: false + timeout: 5 + failedContinue: true + beforeUpdateUserInfo: + enable: false + timeout: 5 + failedContinue: true + beforeCreateGroup: + enable: false + timeout: 5 + failedContinue: true + afterCreateGroup: + enable: false + timeout: 5 + failedContinue: true + beforeMemberJoinGroup: + enable: false + timeout: 5 + failedContinue: true + beforeSetGroupMemberInfo: + enable: false + timeout: 5 + failedContinue: true + afterSetGroupMemberInfo: + enable: false + timeout: 5 + failedContinue: true + setMessageReactionExtensions: + enable: false + timeout: 5 + failedContinue: true + quitGroup: + enable: false + timeout: 5 + failedContinue: true + killGroupMember: + enable: false + timeout: 5 + failedContinue: true + dismissGroup: + enable: false + timeout: 5 + failedContinue: true + joinGroup: + enable: false + timeout: 5 + failedContinue: true + groupMsgRead: + enable: false + timeout: 5 + failedContinue: true + singleMsgRead: + enable: false + timeout: 5 + failedContinue: true + updateUserInfo: + enable: false + timeout: 5 + failedContinue: true + beforeUserRegister: + enable: false + timeout: 5 + failedContinue: true + afterUserRegister: + enable: false + timeout: 5 + failedContinue: true + transferGroupOwner: + enable: false + timeout: 5 + failedContinue: true + beforeSetFriendRemark: + enable: false + timeout: 5 + failedContinue: true + afterSetFriendRemark: + enable: false + timeout: 5 + failedContinue: true + afterGroupMsgRead: + enable: false + timeout: 5 + failedContinue: true + afterGroupMsgRevoke: + enable: false + timeout: 5 + failedContinue: true + afterJoinGroup: + enable: false + timeout: 5 + failedContinue: true + beforeInviteUserToGroup: + enable: false + timeout: 5 + failedContinue: true + joinGroupAfter: + enable: false + timeout: 5 + failedContinue: true + setGroupInfoAfter: + enable: false + timeout: 5 + failedContinue: true + setGroupInfoBefore: + enable: false + timeout: 5 + failedContinue: true + revokeMsgAfter: + enable: false + timeout: 5 + failedContinue: true + addBlackBefore: + enable: false + timeout: 5 + failedContinue: true + addFriendAfter: + enable: false + timeout: 5 + failedContinue: true + addFriendAgreeBefore: + enable: false + timeout: 5 + failedContinue: true + deleteFriendAfter: + enable: false + timeout: 5 + failedContinue: true + importFriendsBefore: + enable: false + timeout: 5 + failedContinue: true + importFriendsAfter: + enable: false + timeout: 5 + failedContinue: true + removeBlackAfter: + enable: false + timeout: 5 + failedContinue: true + +###################### Prometheus ###################### +# Prometheus configuration for various services +# The number of Prometheus ports per service needs to correspond to rpcPort +# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh +prometheus: + enable: true + grafanaUrl: http://127.0.0.1:13000/ + apiPrometheusPort: [20100] + userPrometheusPort: [ 20110 ] + friendPrometheusPort: [ 20120 ] + messagePrometheusPort: [ 20130 ] + messageGatewayPrometheusPort: [ 20140 ] + groupPrometheusPort: [ 20150 ] + authPrometheusPort: [ 20160 ] + pushPrometheusPort: [ 20170 ] + conversationPrometheusPort: [ 20230 ] + rtcPrometheusPort: [ 21300 ] + thirdPrometheusPort: [ 21301 ] + messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports