From cb0394392b84e617e851d55ab55221e887e09bbc Mon Sep 17 00:00:00 2001
From: Gordon <46924906+FGadvancer@users.noreply.github.com>
Date: Tue, 24 Oct 2023 20:28:22 +0800
Subject: [PATCH 1/7] fix: reset branch. (#1277)
* fix: to start im or chat, ZooKeeper must be started first.
* fix: msg gateway start output err info
Signed-off-by: Gordon <1432970085@qq.com>
* fix: msg gateway start output err info
Signed-off-by: Gordon <1432970085@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* fix: go mod update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* chore: package path changes
Signed-off-by: withchao <993506633@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: token update
Signed-off-by: Gordon <1432970085@qq.com>
* fix: get all userID
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: msggateway add online status call
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: log change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: log change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* chore: network mode change
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat: add api of get server time
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* feat: remove go work sum
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: pull message add isRead field
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: check msg-transfer script
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: script update
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: start don't kill old process
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: check component
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: pull message set isRead only message come from single.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix: multiple gateway kick user each other.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: add ex field to update group info.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
* cicd: robot automated Change
* refactor: change project module name.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: change project module name.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* refactor: change project module name.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
* test: for pressure test.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* test: for pressure test.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* test: for pressure test.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* test: message log.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
* fxi: component check output valid info.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fxi: component check output valid info.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* test: send message test log.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* cicd: robot automated Change
* cicd: robot automated Change
* test: remove info log.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* feat: api of send message add sendTime field.
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
* fix: add callback for update user's info.
* cicd: robot automated Change
* fix: change callback command name.
* cicd: robot automated Change
* fix: single chat unread status change.
* fix: single chat unread status change.
* fix: single chat unread status change.
* fix: user status change.
* cicd: robot automated Change
* fix: user status change.
* fix: user status change.
* fix: user status change.
* cicd: robot automated Change
* fix: ws close when user logout.
* fix: remove repeat platform on online status.
* cicd: robot automated Change
* fix: api send messages for notification conversation .
* fix: api send messages for notification conversation .
* fix: api send messages for notification conversation .
* fix: api send messages for notification conversation .
* fix: api send messages for notification conversation .
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
* re: remove router of unsubscribeStatus.
* re: remove router of unsubscribeStatus.
* re: remove router of unsubscribeStatus.
* re: remove router of unsubscribeStatus.
* fix: reset branch
* fix: not support redis cluster. CROSSSLOT Keys in request don't hash to the same slot
* fix: update user.FaceURL do not trigger GroupMemberInfoSetNotification
* cicd: robot automated Change
* fix: api send messages for notification conversation.
* fix: api send messages for notification conversation.
---------
Signed-off-by: Gordon <1432970085@qq.com>
Signed-off-by: withchao <993506633@qq.com>
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: withchao <993506633@qq.com>
Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com>
Co-authored-by: FGadvancer
Co-authored-by: withchao
---
.golangci.yml | 2 +-
cmd/openim-api/main.go | 1 -
go.work | 8 +-
internal/msgtransfer/init.go | 9 +-
internal/rpc/msg/as_read.go | 3 +-
internal/rpc/user/user.go | 9 +-
internal/tools/msg.go | 6 +-
pkg/authverify/token.go | 3 -
pkg/callbackstruct/common.go | 1 -
pkg/common/cmd/api.go | 9 +-
pkg/common/cmd/cron_task.go | 2 -
pkg/common/cmd/msg_gateway.go | 4 -
pkg/common/cmd/msg_transfer.go | 2 -
pkg/common/cmd/msg_utils.go | 27 +-
pkg/common/cmd/root.go | 101 ++--
pkg/common/cmd/rpc.go | 9 +-
pkg/common/config/config.go | 2 -
pkg/common/config/parse.go | 9 +-
pkg/common/convert/black.go | 8 +-
pkg/common/convert/conversation.go | 4 -
pkg/common/convert/friend.go | 22 +-
pkg/common/convert/msg.go | 2 -
pkg/common/convert/user.go | 2 -
pkg/common/db/cache/black.go | 19 +-
pkg/common/db/cache/friend.go | 20 +-
pkg/common/db/cache/group.go | 7 +-
pkg/common/db/cache/meta_cache.go | 12 +-
pkg/common/db/cache/msg.go | 20 +-
pkg/common/db/controller/auth.go | 7 +-
pkg/common/db/controller/black.go | 4 -
pkg/common/db/controller/conversation.go | 19 +-
pkg/common/db/controller/friend.go | 51 +-
pkg/common/db/controller/group.go | 26 -
pkg/common/db/controller/msg.go | 462 +++++++-----------
pkg/common/db/controller/msg_test.go | 1 -
pkg/common/db/controller/s3.go | 1 -
pkg/common/db/controller/user.go | 20 +-
pkg/common/db/localcache/conversation.go | 1 -
pkg/common/db/localcache/group.go | 2 -
pkg/common/db/relation/black_model.go | 5 +-
pkg/common/db/relation/chat_log_model.go | 8 +-
pkg/common/db/relation/conversation_model.go | 6 -
pkg/common/db/relation/friend_model.go | 5 -
.../db/relation/friend_request_model.go | 6 -
pkg/common/db/relation/group_member_model.go | 7 -
pkg/common/db/relation/group_model.go | 4 -
pkg/common/db/relation/group_request_model.go | 2 -
pkg/common/db/relation/log_model.go | 9 +-
pkg/common/db/relation/meta_db.go | 1 -
pkg/common/db/relation/mysql_init.go | 12 +-
pkg/common/db/relation/object_model.go | 2 -
pkg/common/db/relation/user_model.go | 10 +-
pkg/common/db/s3/cont/controller.go | 84 ++--
pkg/common/db/s3/cont/id.go | 2 -
pkg/common/db/s3/cos/cos.go | 124 ++---
pkg/common/db/s3/minio/image.go | 19 +-
pkg/common/db/s3/minio/minio.go | 175 ++-----
pkg/common/db/s3/oss/oss.go | 119 ++---
pkg/common/db/table/relation/group.go | 2 +-
pkg/common/db/table/relation/utils.go | 4 +-
pkg/common/db/table/unrelation/msg.go | 3 -
pkg/common/db/unrelation/mongo.go | 54 +-
pkg/common/db/unrelation/msg.go | 134 ++---
pkg/common/db/unrelation/msg_convert.go | 68 ++-
pkg/common/db/unrelation/super_group.go | 8 -
pkg/common/db/unrelation/user.go | 21 +-
.../k8s_discovery_register.go | 27 +-
pkg/common/http/http_client.go | 20 +-
pkg/common/kafka/consumer_group.go | 1 -
pkg/common/kafka/producer.go | 7 +-
pkg/common/locker/message_locker.go | 4 -
pkg/common/prome/gather.go | 35 --
pkg/common/prome/prometheus.go | 4 -
pkg/common/tls/tls.go | 3 -
pkg/msgprocessor/conversation.go | 23 +-
pkg/msgprocessor/options.go | 4 -
pkg/rpcclient/auth.go | 1 -
pkg/rpcclient/conversation.go | 10 +-
pkg/rpcclient/friend.go | 5 -
pkg/rpcclient/group.go | 14 -
pkg/rpcclient/msg.go | 13 +-
pkg/rpcclient/notification/friend.go | 33 +-
pkg/rpcclient/notification/group.go | 118 ++---
pkg/rpcclient/notification/msg.go | 2 -
pkg/rpcclient/notification/user.go | 52 +-
pkg/rpcclient/push.go | 1 -
pkg/rpcclient/third.go | 9 +-
pkg/rpcclient/user.go | 12 -
pkg/statistics/statistics.go | 6 +-
tools/url2im/pkg/buffer.go | 2 +-
tools/yamlfmt/yamlfmt.go | 2 +-
91 files changed, 778 insertions(+), 1441 deletions(-)
diff --git a/.golangci.yml b/.golangci.yml
index 8785b72d8..dd68ce5a6 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -510,7 +510,7 @@ linters-settings:
nestif:
# minimal complexity of if statements to report, 5 by default
- min-complexity: 6
+ min-complexity: 4
nilnil:
# By default, nilnil checks all returned types below.
diff --git a/cmd/openim-api/main.go b/cmd/openim-api/main.go
index 174300dc7..d1f5cb3f8 100644
--- a/cmd/openim-api/main.go
+++ b/cmd/openim-api/main.go
@@ -26,7 +26,6 @@ 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/go.work b/go.work
index 33faf5195..1c819212c 100644
--- a/go.work
+++ b/go.work
@@ -1,18 +1,16 @@
go 1.19
-
use (
.
./test/typecheck
./tools/changelog
- ./tools/component
- ./tools/data-conversion
- ./tools/imctl
//./tools/imctl
./tools/infra
./tools/ncpu
./tools/openim-web
- ./tools/url2im
./tools/versionchecker
./tools/yamlfmt
+ ./tools/component
+ ./tools/url2im
+ ./tools/data-conversion
)
diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go
index e5066633a..4487826ee 100644
--- a/internal/msgtransfer/init.go
+++ b/internal/msgtransfer/init.go
@@ -16,12 +16,10 @@ package msgtransfer
import (
"fmt"
- "sync"
-
+ "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
-
- "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
+ "sync"
"github.com/OpenIMSDK/tools/mw"
@@ -65,7 +63,8 @@ func StartTransfer(prometheusPort int) error {
/*
client, err := openkeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openkeeper.WithFreq(time.Hour), openkeeper.WithRoundRobin(), openkeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
- config.Config.Zookeeper.Password), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
+ config.Config.Zookeeper.Password), openkeeper.WithTimeout(10), openkeeper.WithLogger(log.NewZkLogger()))*/
+ if err != nil {
return err
}
if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil {
diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go
index 55c3ba088..6e3bbe987 100644
--- a/internal/rpc/msg/as_read.go
+++ b/internal/rpc/msg/as_read.go
@@ -147,6 +147,7 @@ func (m *msgServer) MarkConversationAsRead(
for i := hasReadSeq + 1; i <= req.HasReadSeq; i++ {
seqs = append(seqs, i)
}
+
if len(seqs) > 0 {
log.ZDebug(ctx, "MarkConversationAsRead", "seqs", seqs, "conversationID", req.ConversationID)
if err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, seqs); err != nil {
@@ -164,7 +165,6 @@ func (m *msgServer) MarkConversationAsRead(
m.conversationAndGetRecvID(conversation, req.UserID), seqs, hasReadSeq); err != nil {
return nil, err
}
-
} else if conversation.ConversationType == constant.SuperGroupChatType ||
conversation.ConversationType == constant.NotificationChatType {
if req.HasReadSeq > hasReadSeq {
@@ -178,6 +178,7 @@ func (m *msgServer) MarkConversationAsRead(
req.UserID, seqs, hasReadSeq); err != nil {
return nil, err
}
+
}
return &msg.MarkConversationAsReadResp{}, nil
diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go
index 83573eeef..f2ceb3beb 100644
--- a/internal/rpc/user/user.go
+++ b/internal/rpc/user/user.go
@@ -290,8 +290,7 @@ func (s *userServer) SubscribeOrCancelUsersStatus(ctx context.Context, req *pbus
// GetUserStatus Get the online status of the user.
func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatusReq) (resp *pbuser.GetUserStatusResp,
- err error,
-) {
+ err error) {
onlineStatusList, err := s.UserDatabase.GetUserStatus(ctx, req.UserIDs)
if err != nil {
return nil, err
@@ -301,8 +300,7 @@ func (s *userServer) GetUserStatus(ctx context.Context, req *pbuser.GetUserStatu
// SetUserStatus Synchronize user's online status.
func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatusReq) (resp *pbuser.SetUserStatusResp,
- err error,
-) {
+ err error) {
err = s.UserDatabase.SetUserStatus(ctx, req.UserID, req.Status, req.PlatformID)
if err != nil {
return nil, err
@@ -326,8 +324,7 @@ func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatu
// GetSubscribeUsersStatus Get the online status of subscribers.
func (s *userServer) GetSubscribeUsersStatus(ctx context.Context,
- req *pbuser.GetSubscribeUsersStatusReq,
-) (*pbuser.GetSubscribeUsersStatusResp, error) {
+ req *pbuser.GetSubscribeUsersStatusReq) (*pbuser.GetSubscribeUsersStatusResp, error) {
userList, err := s.UserDatabase.GetAllSubscribeList(ctx, req.UserID)
if err != nil {
return nil, err
diff --git a/internal/tools/msg.go b/internal/tools/msg.go
index ca095051c..5397689b2 100644
--- a/internal/tools/msg.go
+++ b/internal/tools/msg.go
@@ -17,13 +17,11 @@ package tools
import (
"context"
"fmt"
- "math"
-
+ "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
"github.com/redis/go-redis/v9"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
-
- "github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
+ "math"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
diff --git a/pkg/authverify/token.go b/pkg/authverify/token.go
index 724d4934f..a8e577fde 100644
--- a/pkg/authverify/token.go
+++ b/pkg/authverify/token.go
@@ -41,7 +41,6 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
if opUserID == ownerUserID {
return nil
}
-
return errs.ErrNoPermission.Wrap(utils.GetSelfFuncName())
}
@@ -53,7 +52,6 @@ func CheckAdmin(ctx context.Context) error {
if utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID) {
return nil
}
-
return errs.ErrNoPermission.Wrap(fmt.Sprintf("user %s is not admin userID", mcontext.GetOpUserID(ctx)))
}
@@ -76,6 +74,5 @@ func WsVerifyToken(token, userID string, platformID int) error {
if claim.PlatformID != platformID {
return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token platform %d != %d", claim.PlatformID, platformID))
}
-
return nil
}
diff --git a/pkg/callbackstruct/common.go b/pkg/callbackstruct/common.go
index 8b320a04f..ef84d52b9 100644
--- a/pkg/callbackstruct/common.go
+++ b/pkg/callbackstruct/common.go
@@ -61,7 +61,6 @@ func (c CommonCallbackResp) Parse() error {
if c.ActionCode != errs.NoError || c.ErrCode != errs.NoError {
return errs.NewCodeError(int(c.ErrCode), c.ErrMsg).WithDetail(c.ErrDlt)
}
-
return nil
}
diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go
index 98a200f14..7ce872fac 100644
--- a/pkg/common/cmd/api.go
+++ b/pkg/common/cmd/api.go
@@ -16,11 +16,9 @@ package cmd
import (
"fmt"
-
"github.com/OpenIMSDK/protocol/constant"
- "github.com/spf13/cobra"
-
config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
+ "github.com/spf13/cobra"
)
type ApiCmd struct {
@@ -44,7 +42,8 @@ func (a *ApiCmd) GetPortFromConfig(portType string) int {
fmt.Println("GetPortFromConfig:", portType)
if portType == constant.FlagPort {
return config2.Config.Api.OpenImApiPort[0]
- }
+ } else {
- return 0
+ return 0
+ }
}
diff --git a/pkg/common/cmd/cron_task.go b/pkg/common/cmd/cron_task.go
index c1e18e5cf..1b0e796ac 100644
--- a/pkg/common/cmd/cron_task.go
+++ b/pkg/common/cmd/cron_task.go
@@ -23,7 +23,6 @@ type CronTaskCmd struct {
func NewCronTaskCmd() *CronTaskCmd {
ret := &CronTaskCmd{NewRootCmd("cronTask", WithCronTaskLogName())}
ret.SetRootCmdPt(ret)
-
return ret
}
@@ -35,6 +34,5 @@ func (c *CronTaskCmd) addRunE(f func() error) {
func (c *CronTaskCmd) Exec(f func() error) error {
c.addRunE(f)
-
return c.Execute()
}
diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go
index c9ecfa42b..c96bbd7af 100644
--- a/pkg/common/cmd/msg_gateway.go
+++ b/pkg/common/cmd/msg_gateway.go
@@ -31,7 +31,6 @@ type MsgGatewayCmd struct {
func NewMsgGatewayCmd() *MsgGatewayCmd {
ret := &MsgGatewayCmd{NewRootCmd("msgGateway")}
ret.SetRootCmdPt(ret)
-
return ret
}
@@ -44,7 +43,6 @@ func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int {
if port == 0 {
port = m.PortFromConfig(constant.FlagWsPort)
}
-
return port
}
@@ -56,10 +54,8 @@ func (m *MsgGatewayCmd) addRunE() {
func (m *MsgGatewayCmd) Exec() error {
m.addRunE()
-
return m.Execute()
}
-
func (m *MsgGatewayCmd) GetPortFromConfig(portType string) int {
if portType == constant.FlagWsPort {
return config2.Config.LongConnSvr.OpenImWsPort[0]
diff --git a/pkg/common/cmd/msg_transfer.go b/pkg/common/cmd/msg_transfer.go
index 1e0449b4c..20349ebbb 100644
--- a/pkg/common/cmd/msg_transfer.go
+++ b/pkg/common/cmd/msg_transfer.go
@@ -27,7 +27,6 @@ type MsgTransferCmd struct {
func NewMsgTransferCmd() *MsgTransferCmd {
ret := &MsgTransferCmd{NewRootCmd("msgTransfer")}
ret.SetRootCmdPt(ret)
-
return ret
}
@@ -39,6 +38,5 @@ func (m *MsgTransferCmd) addRunE() {
func (m *MsgTransferCmd) Exec() error {
m.addRunE()
-
return m.Execute()
}
diff --git a/pkg/common/cmd/msg_utils.go b/pkg/common/cmd/msg_utils.go
index 82306da8c..cfaf631ec 100644
--- a/pkg/common/cmd/msg_utils.go
+++ b/pkg/common/cmd/msg_utils.go
@@ -22,7 +22,7 @@ import (
type MsgUtilsCmd struct {
cobra.Command
- // msgTool *tools.MsgTool
+ msgTool *tools.MsgTool
}
func (m *MsgUtilsCmd) AddUserIDFlag() {
@@ -31,7 +31,6 @@ func (m *MsgUtilsCmd) AddUserIDFlag() {
func (m *MsgUtilsCmd) getUserIDFlag(cmdLines *cobra.Command) string {
userID, _ := cmdLines.Flags().GetString("userID")
-
return userID
}
@@ -39,17 +38,26 @@ func (m *MsgUtilsCmd) AddFixAllFlag() {
m.Command.PersistentFlags().BoolP("fixAll", "f", false, "openIM fix all seqs")
}
+func (m *MsgUtilsCmd) getFixAllFlag(cmdLines *cobra.Command) bool {
+ fixAll, _ := cmdLines.Flags().GetBool("fixAll")
+ return fixAll
+}
+
func (m *MsgUtilsCmd) AddClearAllFlag() {
m.Command.PersistentFlags().BoolP("clearAll", "c", false, "openIM clear all seqs")
}
+func (m *MsgUtilsCmd) getClearAllFlag(cmdLines *cobra.Command) bool {
+ clearAll, _ := cmdLines.Flags().GetBool("clearAll")
+ return clearAll
+}
+
func (m *MsgUtilsCmd) AddSuperGroupIDFlag() {
m.Command.PersistentFlags().StringP("superGroupID", "g", "", "openIM superGroupID")
}
func (m *MsgUtilsCmd) getSuperGroupIDFlag(cmdLines *cobra.Command) string {
superGroupID, _ := cmdLines.Flags().GetString("superGroupID")
-
return superGroupID
}
@@ -57,10 +65,20 @@ func (m *MsgUtilsCmd) AddBeginSeqFlag() {
m.Command.PersistentFlags().Int64P("beginSeq", "b", 0, "openIM beginSeq")
}
+func (m *MsgUtilsCmd) getBeginSeqFlag(cmdLines *cobra.Command) int64 {
+ beginSeq, _ := cmdLines.Flags().GetInt64("beginSeq")
+ return beginSeq
+}
+
func (m *MsgUtilsCmd) AddLimitFlag() {
m.Command.PersistentFlags().Int64P("limit", "l", 0, "openIM limit")
}
+func (m *MsgUtilsCmd) getLimitFlag(cmdLines *cobra.Command) int64 {
+ limit, _ := cmdLines.Flags().GetInt64("limit")
+ return limit
+}
+
func (m *MsgUtilsCmd) Execute() error {
return m.Command.Execute()
}
@@ -113,7 +131,6 @@ func NewSeqCmd() *SeqCmd {
seqCmd := &SeqCmd{
NewMsgUtilsCmd("seq", "seq", nil),
}
-
return seqCmd
}
@@ -141,7 +158,6 @@ func (s *SeqCmd) GetSeqCmd() *cobra.Command {
// println(seq)
}
}
-
return &s.Command
}
@@ -157,7 +173,6 @@ func NewMsgCmd() *MsgCmd {
msgCmd := &MsgCmd{
NewMsgUtilsCmd("msg", "msg", nil),
}
-
return msgCmd
}
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index d1deb628c..7bff0f798 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -17,6 +17,8 @@ package cmd
import (
"fmt"
+ config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
+
"github.com/spf13/cobra"
"github.com/OpenIMSDK/protocol/constant"
@@ -59,81 +61,62 @@ func NewRootCmd(name string, opts ...func(*CmdOpts)) *RootCmd {
Short: fmt.Sprintf(`Start %s `, name),
Long: fmt.Sprintf(`Start %s `, name),
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
- if err := rootCmd.getConfFromCmdAndInit(cmd); err != nil {
- panic(err)
- }
- cmdOpts := &CmdOpts{}
- for _, opt := range opts {
- opt(cmdOpts)
- }
- if cmdOpts.loggerPrefixName == "" {
- cmdOpts.loggerPrefixName = "OpenIM.log.all"
- }
- err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel,
- config.Config.Log.IsStdout, config.Config.Log.IsJson, config.Config.Log.StorageLocation,
- config.Config.Log.RemainRotationCount, config.Config.Log.RotationTime)
- if err != nil {
- panic(err)
- }
-
- return nil
+ return rootCmd.persistentPreRun(cmd, opts...)
},
}
rootCmd.Command = cmd
rootCmd.addConfFlag()
-
return rootCmd
}
-// func (rc *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error {
-// if err := rc.initializeConfiguration(cmd); err != nil {
-// return fmt.Errorf("failed to get configuration from command: %w", err)
-// }
+func (rc *RootCmd) persistentPreRun(cmd *cobra.Command, opts ...func(*CmdOpts)) error {
+ if err := rc.initializeConfiguration(cmd); err != nil {
+ return fmt.Errorf("failed to get configuration from command: %w", err)
+ }
-// cmdOpts := rc.applyOptions(opts...)
+ cmdOpts := rc.applyOptions(opts...)
-// if err := rc.initializeLogger(cmdOpts); err != nil {
-// return fmt.Errorf("failed to initialize from config: %w", err)
-// }
+ if err := rc.initializeLogger(cmdOpts); err != nil {
+ return fmt.Errorf("failed to initialize from config: %w", err)
+ }
-// return nil
-// }
+ return nil
+}
-//nolint:unused //unused work wrongly
func (rc *RootCmd) initializeConfiguration(cmd *cobra.Command) error {
return rc.getConfFromCmdAndInit(cmd)
}
-// func (rc *RootCmd) applyOptions(opts ...func(*CmdOpts)) *CmdOpts {
-// cmdOpts := defaultCmdOpts()
-// for _, opt := range opts {
-// opt(cmdOpts)
-// }
+func (rc *RootCmd) applyOptions(opts ...func(*CmdOpts)) *CmdOpts {
+ cmdOpts := defaultCmdOpts()
+ for _, opt := range opts {
+ opt(cmdOpts)
+ }
-// return cmdOpts
-// }
+ return cmdOpts
+}
-// func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
-// logConfig := config.Config.Log
+func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
+ logConfig := config.Config.Log
-// return log.InitFromConfig(
+ return log.InitFromConfig(
-// cmdOpts.loggerPrefixName,
-// rc.Name,
-// logConfig.RemainLogLevel,
-// logConfig.IsStdout,
-// logConfig.IsJson,
-// logConfig.StorageLocation,
-// logConfig.RemainRotationCount,
-// logConfig.RotationTime,
-// )
-// }
+ cmdOpts.loggerPrefixName,
+ rc.Name,
+ logConfig.RemainLogLevel,
+ logConfig.IsStdout,
+ logConfig.IsJson,
+ logConfig.StorageLocation,
+ logConfig.RemainRotationCount,
+ logConfig.RotationTime,
+ )
+}
-// func defaultCmdOpts() *CmdOpts {
-// return &CmdOpts{
-// loggerPrefixName: "OpenIM.log.all",
-// }
-// }
+func defaultCmdOpts() *CmdOpts {
+ return &CmdOpts{
+ loggerPrefixName: "OpenIM.log.all",
+ }
+}
func (r *RootCmd) SetRootCmdPt(cmdItf RootCmdPt) {
r.cmdItf = cmdItf
@@ -152,7 +135,6 @@ func (r *RootCmd) getPortFlag(cmd *cobra.Command) int {
if port == 0 {
port = r.PortFromConfig(constant.FlagPort)
}
-
return port
}
@@ -169,7 +151,6 @@ func (r *RootCmd) getPrometheusPortFlag(cmd *cobra.Command) int {
if port == 0 {
port = r.PortFromConfig(constant.FlagPrometheusPort)
}
-
return port
}
@@ -180,8 +161,7 @@ func (r *RootCmd) GetPrometheusPortFlag() int {
func (r *RootCmd) getConfFromCmdAndInit(cmdLines *cobra.Command) error {
configFolderPath, _ := cmdLines.Flags().GetString(constant.FlagConf)
fmt.Println("configFolderPath:", configFolderPath)
-
- return config.InitConfig(configFolderPath)
+ return config2.InitConfig(configFolderPath)
}
func (r *RootCmd) Execute() error {
@@ -194,12 +174,9 @@ func (r *RootCmd) AddCommand(cmds ...*cobra.Command) {
func (r *RootCmd) GetPortFromConfig(portType string) int {
fmt.Println("RootCmd.GetPortFromConfig:", portType)
-
return 0
}
-
func (r *RootCmd) PortFromConfig(portType string) int {
fmt.Println("PortFromConfig:", portType)
-
return r.cmdItf.GetPortFromConfig(portType)
}
diff --git a/pkg/common/cmd/rpc.go b/pkg/common/cmd/rpc.go
index 6d34c6603..224edc0a0 100644
--- a/pkg/common/cmd/rpc.go
+++ b/pkg/common/cmd/rpc.go
@@ -16,13 +16,11 @@ 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"
@@ -35,7 +33,6 @@ type RpcCmd struct {
func NewRpcCmd(name string) *RpcCmd {
ret := &RpcCmd{NewRootCmd(name)}
ret.SetRootCmdPt(ret)
-
return ret
}
@@ -44,7 +41,6 @@ func (a *RpcCmd) Exec() error {
a.port = a.getPortFlag(cmd)
a.prometheusPort = a.getPrometheusPortFlag(cmd)
}
-
return a.Execute()
}
@@ -55,10 +51,8 @@ func (a *RpcCmd) StartSvr(
if a.GetPortFlag() == 0 {
return errors.New("port is required")
}
-
return startrpc.Start(a.GetPortFlag(), name, a.GetPrometheusPortFlag(), rpcFn)
}
-
func (a *RpcCmd) GetPortFromConfig(portType string) int {
switch a.Name {
case RpcPushServer:
@@ -94,6 +88,5 @@ func (a *RpcCmd) GetPortFromConfig(portType string) int {
return config2.Config.RpcPort.OpenImUserPort[0]
}
}
-
return 0
}
diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go
index d521fbd51..95f4a864e 100644
--- a/pkg/common/config/config.go
+++ b/pkg/common/config/config.go
@@ -336,7 +336,6 @@ func (c *configStruct) RegisterConf2Registry(registry discoveryregistry.SvcDisco
if err != nil {
return err
}
-
return registry.RegisterConf2Registry(ConfKey, data)
}
@@ -349,6 +348,5 @@ func (c *configStruct) EncodeConfig() []byte {
if err := yaml.NewEncoder(buf).Encode(c); err != nil {
panic(err)
}
-
return buf.Bytes()
}
diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go
index 86292a597..2c20f1a98 100644
--- a/pkg/common/config/parse.go
+++ b/pkg/common/config/parse.go
@@ -21,9 +21,8 @@ import (
"path/filepath"
"github.com/OpenIMSDK/protocol/constant"
- "gopkg.in/yaml.v3"
-
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
+ "gopkg.in/yaml.v3"
)
//go:embed version
@@ -35,7 +34,7 @@ const (
DefaultFolderPath = "../config/"
)
-// getProjectRoot returns the absolute path of the project root directory.
+// getProjectRoot returns the absolute path of the project root directory
func GetProjectRoot() string {
b, _ := filepath.Abs(os.Args[0])
@@ -57,7 +56,6 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options {
opts = msgprocessor.WithOptions(opts, msgprocessor.WithHistory(true), msgprocessor.WithPersistent())
}
opts = msgprocessor.WithOptions(opts, msgprocessor.WithSendMsg(cfg.IsSendMsg))
-
return opts
}
@@ -78,7 +76,6 @@ func initConfig(config interface{}, configName, configFolderPath string) error {
return fmt.Errorf("unmarshal yaml error: %w", err)
}
fmt.Println("use config", configFolderPath)
-
return nil
}
@@ -96,5 +93,5 @@ func InitConfig(configFolderPath string) error {
return err
}
- return nil
+ return initConfig(&Config.Notification, NotificationFileName, configFolderPath)
}
diff --git a/pkg/common/convert/black.go b/pkg/common/convert/black.go
index 9c862d5b7..50c270dcb 100644
--- a/pkg/common/convert/black.go
+++ b/pkg/common/convert/black.go
@@ -18,6 +18,7 @@ import (
"context"
"github.com/OpenIMSDK/protocol/sdkws"
+ sdk "github.com/OpenIMSDK/protocol/sdkws"
"github.com/openimsdk/open-im-server/v3/pkg/common/db/table/relation"
)
@@ -26,11 +27,11 @@ func BlackDB2Pb(
ctx context.Context,
blackDBs []*relation.BlackModel,
f func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
-) (blackPbs []*sdkws.BlackInfo, err error) {
+) (blackPbs []*sdk.BlackInfo, err error) {
if len(blackDBs) == 0 {
return nil, nil
}
- userIDs := make([]string, 0, len(blackDBs))
+ var userIDs []string
for _, blackDB := range blackDBs {
userIDs = append(userIDs, blackDB.BlockUserID)
}
@@ -39,7 +40,7 @@ func BlackDB2Pb(
return nil, err
}
for _, blackDB := range blackDBs {
- blackPb := &sdkws.BlackInfo{
+ blackPb := &sdk.BlackInfo{
OwnerUserID: blackDB.OwnerUserID,
CreateTime: blackDB.CreateTime.Unix(),
AddSource: blackDB.AddSource,
@@ -54,6 +55,5 @@ func BlackDB2Pb(
}
blackPbs = append(blackPbs, blackPb)
}
-
return blackPbs, nil
}
diff --git a/pkg/common/convert/conversation.go b/pkg/common/convert/conversation.go
index 295ff4c82..165262b7f 100644
--- a/pkg/common/convert/conversation.go
+++ b/pkg/common/convert/conversation.go
@@ -27,7 +27,6 @@ func ConversationDB2Pb(conversationDB *relation.ConversationModel) *conversation
if err := utils.CopyStructFields(conversationPB, conversationDB); err != nil {
return nil
}
-
return conversationPB
}
@@ -40,7 +39,6 @@ func ConversationsDB2Pb(conversationsDB []*relation.ConversationModel) (conversa
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.Unix()
conversationsPB = append(conversationsPB, conversationPB)
}
-
return conversationsPB
}
@@ -49,7 +47,6 @@ func ConversationPb2DB(conversationPB *conversation.Conversation) *relation.Conv
if err := utils.CopyStructFields(conversationDB, conversationPB); err != nil {
return nil
}
-
return conversationDB
}
@@ -61,6 +58,5 @@ func ConversationsPb2DB(conversationsPB []*conversation.Conversation) (conversat
}
conversationsDB = append(conversationsDB, conversationDB)
}
-
return conversationsDB
}
diff --git a/pkg/common/convert/friend.go b/pkg/common/convert/friend.go
index 41907d5ca..7003c8aa6 100644
--- a/pkg/common/convert/friend.go
+++ b/pkg/common/convert/friend.go
@@ -16,7 +16,6 @@ package convert
import (
"context"
- "fmt"
"github.com/OpenIMSDK/protocol/sdkws"
"github.com/OpenIMSDK/tools/utils"
@@ -26,13 +25,9 @@ import (
func FriendPb2DB(friend *sdkws.FriendInfo) *relation.FriendModel {
dbFriend := &relation.FriendModel{}
- err := utils.CopyStructFields(dbFriend, friend)
- if err != nil {
- panic(err)
- }
+ utils.CopyStructFields(dbFriend, friend)
dbFriend.FriendUserID = friend.FriendUser.UserID
dbFriend.CreateTime = utils.UnixSecondToTime(friend.CreateTime)
-
return dbFriend
}
@@ -42,10 +37,7 @@ func FriendDB2Pb(
getUsers func(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error),
) (*sdkws.FriendInfo, error) {
pbfriend := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
- err := utils.CopyStructFields(pbfriend, friendDB)
- if err != nil {
- panic(err)
- }
+ utils.CopyStructFields(pbfriend, friendDB)
users, err := getUsers(ctx, []string{friendDB.FriendUserID})
if err != nil {
return nil, err
@@ -55,7 +47,6 @@ func FriendDB2Pb(
pbfriend.FriendUser.FaceURL = users[friendDB.FriendUserID].FaceURL
pbfriend.FriendUser.Ex = users[friendDB.FriendUserID].Ex
pbfriend.CreateTime = friendDB.CreateTime.Unix()
-
return pbfriend, nil
}
@@ -67,7 +58,7 @@ func FriendsDB2Pb(
if len(friendsDB) == 0 {
return nil, nil
}
- userID := make([]string, 0, len(friendsDB))
+ var userID []string
for _, friendDB := range friendsDB {
userID = append(userID, friendDB.FriendUserID)
}
@@ -77,8 +68,7 @@ func FriendsDB2Pb(
}
for _, friend := range friendsDB {
friendPb := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
- err2 := utils.CopyStructFields(friendPb, friend)
- err = fmt.Errorf("%w, %w", err, err2)
+ utils.CopyStructFields(friendPb, friend)
friendPb.FriendUser.UserID = users[friend.FriendUserID].UserID
friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname
friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL
@@ -86,8 +76,7 @@ func FriendsDB2Pb(
friendPb.CreateTime = friend.CreateTime.Unix()
friendsPb = append(friendsPb, friendPb)
}
-
- return friendsPb, err
+ return friendsPb, nil
}
func FriendRequestDB2Pb(
@@ -127,6 +116,5 @@ func FriendRequestDB2Pb(
Ex: friendRequest.Ex,
})
}
-
return res, nil
}
diff --git a/pkg/common/convert/msg.go b/pkg/common/convert/msg.go
index 23bd5dfea..56f71f018 100644
--- a/pkg/common/convert/msg.go
+++ b/pkg/common/convert/msg.go
@@ -55,7 +55,6 @@ func MsgPb2DB(msg *sdkws.MsgData) *unrelation.MsgDataModel {
msgDataModel.AtUserIDList = msg.AtUserIDList
msgDataModel.AttachedInfo = msg.AttachedInfo
msgDataModel.Ex = msg.Ex
-
return &msgDataModel
}
@@ -96,6 +95,5 @@ func MsgDB2Pb(msgModel *unrelation.MsgDataModel) *sdkws.MsgData {
msg.AtUserIDList = msgModel.AtUserIDList
msg.AttachedInfo = msgModel.AttachedInfo
msg.Ex = msgModel.Ex
-
return &msg
}
diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go
index 38496515f..abb3a2144 100644
--- a/pkg/common/convert/user.go
+++ b/pkg/common/convert/user.go
@@ -34,7 +34,6 @@ func UsersDB2Pb(users []*relationtb.UserModel) (result []*sdkws.UserInfo) {
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
result = append(result, &userPb)
}
-
return result
}
@@ -47,6 +46,5 @@ func UserPb2DB(user *sdkws.UserInfo) *relationtb.UserModel {
userDB.CreateTime = time.UnixMilli(user.CreateTime)
userDB.AppMangerLevel = user.AppMangerLevel
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
-
return &userDB
}
diff --git a/pkg/common/db/cache/black.go b/pkg/common/db/cache/black.go
index 5a70097ed..d1abe945c 100644
--- a/pkg/common/db/cache/black.go
+++ b/pkg/common/db/cache/black.go
@@ -62,7 +62,12 @@ func NewBlackCacheRedis(
}
func (b *BlackCacheRedis) NewCache() BlackCache {
- return &BlackCacheRedis{expireTime: b.expireTime, rcClient: b.rcClient, blackDB: b.blackDB, metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDelKeys()...)}
+ return &BlackCacheRedis{
+ expireTime: b.expireTime,
+ rcClient: b.rcClient,
+ blackDB: b.blackDB,
+ metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDelKeys()...),
+ }
}
func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
@@ -70,9 +75,15 @@ func (b *BlackCacheRedis) getBlackIDsKey(ownerUserID string) string {
}
func (b *BlackCacheRedis) GetBlackIDs(ctx context.Context, userID string) (blackIDs []string, err error) {
- return getCache(ctx, b.rcClient, b.getBlackIDsKey(userID), b.expireTime, func(ctx context.Context) ([]string, error) {
- return b.blackDB.FindBlackUserIDs(ctx, userID)
- })
+ return getCache(
+ ctx,
+ b.rcClient,
+ b.getBlackIDsKey(userID),
+ b.expireTime,
+ func(ctx context.Context) ([]string, error) {
+ return b.blackDB.FindBlackUserIDs(ctx, userID)
+ },
+ )
}
func (b *BlackCacheRedis) DelBlackIDs(ctx context.Context, userID string) BlackCache {
diff --git a/pkg/common/db/cache/friend.go b/pkg/common/db/cache/friend.go
index 28bb971b4..64a358984 100644
--- a/pkg/common/db/cache/friend.go
+++ b/pkg/common/db/cache/friend.go
@@ -53,9 +53,9 @@ type FriendCacheRedis struct {
rcClient *rockscache.Client
}
-func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationtb.FriendModelInterface, options rockscache.Options) FriendCache {
+func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationtb.FriendModelInterface,
+ options rockscache.Options) FriendCache {
rcClient := rockscache.NewClient(rdb, options)
-
return &FriendCacheRedis{
metaCache: NewMetaCacheRedis(rcClient),
friendDB: friendDB,
@@ -64,12 +64,12 @@ func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationtb.FriendMo
}
}
-func (c *FriendCacheRedis) NewCache() FriendCache {
+func (f *FriendCacheRedis) NewCache() FriendCache {
return &FriendCacheRedis{
- rcClient: c.rcClient,
- metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...),
- friendDB: c.friendDB,
- expireTime: c.expireTime,
+ rcClient: f.rcClient,
+ metaCache: NewMetaCacheRedis(f.rcClient, f.metaCache.GetPreDelKeys()...),
+ friendDB: f.friendDB,
+ expireTime: f.expireTime,
}
}
@@ -128,8 +128,10 @@ func (f *FriendCacheRedis) DelTwoWayFriendIDs(ctx context.Context, ownerUserID s
return newFriendCache
}
-func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relationtb.FriendModel, err error) {
- return getCache(ctx, f.rcClient, f.getFriendKey(ownerUserID, friendUserID), f.expireTime, func(ctx context.Context) (*relationtb.FriendModel, error) {
+func (f *FriendCacheRedis) GetFriend(ctx context.Context, ownerUserID,
+ friendUserID string) (friend *relationtb.FriendModel, err error) {
+ return getCache(ctx, f.rcClient, f.getFriendKey(ownerUserID,
+ friendUserID), f.expireTime, func(ctx context.Context) (*relationtb.FriendModel, error) {
return f.friendDB.Take(ctx, ownerUserID, friendUserID)
})
}
diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go
index d505772eb..6a4b57813 100644
--- a/pkg/common/db/cache/group.go
+++ b/pkg/common/db/cache/group.go
@@ -412,7 +412,12 @@ func (g *GroupCacheRedis) GetGroupMembersInfo(ctx context.Context, groupID strin
})
}
-func (g *GroupCacheRedis) GetGroupMembersPage(ctx context.Context, groupID string, userIDs []string, showNumber, pageNumber int32) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error) {
+func (g *GroupCacheRedis) GetGroupMembersPage(
+ ctx context.Context,
+ groupID string,
+ userIDs []string,
+ showNumber, pageNumber int32,
+) (total uint32, groupMembers []*relationtb.GroupMemberModel, err error) {
groupMemberIDs, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return 0, nil, err
diff --git a/pkg/common/db/cache/meta_cache.go b/pkg/common/db/cache/meta_cache.go
index 5cff3df7f..549a0ea69 100644
--- a/pkg/common/db/cache/meta_cache.go
+++ b/pkg/common/db/cache/meta_cache.go
@@ -154,7 +154,8 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
return t, nil
}
-//func batchGetCache[T any](ctx context.Context, rcClient *rockscache.Client, keys []string, expire time.Duration, keyIndexFn func(t T, keys []string) (int, error), fn func(ctx context.Context) ([]T, error)) ([]T, error) {
+// func batchGetCache[T any](ctx context.Context, rcClient *rockscache.Client, keys []string, expire time.Duration, keyIndexFn func(t T, keys []string) (int, error), fn func(ctx context.Context) ([]T,
+// error)) ([]T, error) {
// batchMap, err := rcClient.FetchBatch2(ctx, keys, expire, func(idxs []int) (m map[int]string, err error) {
// values := make(map[int]string)
// tArrays, err := fn(ctx)
@@ -191,7 +192,14 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
// return tArrays, nil
//}
-func batchGetCache2[T any, K comparable](ctx context.Context, rcClient *rockscache.Client, expire time.Duration, keys []K, keyFn func(key K) string, fns func(ctx context.Context, key K) (T, error)) ([]T, error) {
+func batchGetCache2[T any, K comparable](
+ ctx context.Context,
+ rcClient *rockscache.Client,
+ expire time.Duration,
+ keys []K,
+ keyFn func(key K) string,
+ fns func(ctx context.Context, key K) (T, error),
+) ([]T, error) {
if len(keys) == 0 {
return nil, nil
}
diff --git a/pkg/common/db/cache/msg.go b/pkg/common/db/cache/msg.go
index b55a76f62..2c869befb 100644
--- a/pkg/common/db/cache/msg.go
+++ b/pkg/common/db/cache/msg.go
@@ -17,11 +17,13 @@ package cache
import (
"context"
"errors"
- "github.com/dtm-labs/rockscache"
- unrelationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
"strconv"
"time"
+ "github.com/dtm-labs/rockscache"
+
+ unrelationtb "github.com/openimsdk/open-im-server/v3/pkg/common/db/table/unrelation"
+
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
"github.com/OpenIMSDK/tools/errs"
@@ -718,21 +720,11 @@ func (c *msgCache) SetMessageTypeKeyValue(
return errs.Wrap(c.rdb.HSet(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), typeKey, value).Err())
}
-func (c *msgCache) SetMessageReactionExpire(
- ctx context.Context,
- clientMsgID string,
- sessionType int32,
- expiration time.Duration,
-) (bool, error) {
+func (c *msgCache) SetMessageReactionExpire(ctx context.Context, clientMsgID string, sessionType int32, expiration time.Duration) (bool, error) {
return utils.Wrap2(c.rdb.Expire(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), expiration).Result())
}
-func (c *msgCache) GetMessageTypeKeyValue(
- ctx context.Context,
- clientMsgID string,
- sessionType int32,
- typeKey string,
-) (string, error) {
+func (c *msgCache) GetMessageTypeKeyValue(ctx context.Context, clientMsgID string, sessionType int32, typeKey string) (string, error) {
return utils.Wrap2(c.rdb.HGet(ctx, c.getMessageReactionExPrefix(clientMsgID, sessionType), typeKey).Result())
}
diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go
index 13d06a964..17b4a440d 100644
--- a/pkg/common/db/controller/auth.go
+++ b/pkg/common/db/controller/auth.go
@@ -69,9 +69,9 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
}
}
if len(deleteTokenKey) != 0 {
- err2 := a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
- if err2 != nil {
- return "", err2
+ err := a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
+ if err != nil {
+ return "", err
}
}
claims := tokenverify.BuildClaims(userID, platformID, a.accessExpire)
@@ -80,6 +80,5 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
if err != nil {
return "", utils.Wrap(err, "")
}
-
return tokenString, a.cache.AddTokenFlag(ctx, userID, platformID, tokenString, constant.NormalToken)
}
diff --git a/pkg/common/db/controller/black.go b/pkg/common/db/controller/black.go
index 38147e4e9..70e942a77 100644
--- a/pkg/common/db/controller/black.go
+++ b/pkg/common/db/controller/black.go
@@ -55,7 +55,6 @@ func (b *blackDatabase) Create(ctx context.Context, blacks []*relation.BlackMode
if err := b.black.Create(ctx, blacks); err != nil {
return err
}
-
return b.deleteBlackIDsCache(ctx, blacks)
}
@@ -64,7 +63,6 @@ func (b *blackDatabase) Delete(ctx context.Context, blacks []*relation.BlackMode
if err := b.black.Delete(ctx, blacks); err != nil {
return err
}
-
return b.deleteBlackIDsCache(ctx, blacks)
}
@@ -73,7 +71,6 @@ func (b *blackDatabase) deleteBlackIDsCache(ctx context.Context, blacks []*relat
for _, black := range blacks {
cache = cache.DelBlackIDs(ctx, black.OwnerUserID)
}
-
return cache.ExecDel(ctx)
}
@@ -100,7 +97,6 @@ func (b *blackDatabase) CheckIn(
return
}
log.ZDebug(ctx, "blackIDs", "user1BlackIDs", userID1BlackIDs, "user2BlackIDs", userID2BlackIDs)
-
return utils.IsContain(userID2, userID1BlackIDs), utils.IsContain(userID1, userID2BlackIDs), nil
}
diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go
index 29cd0d152..b93f0bf06 100644
--- a/pkg/common/db/controller/conversation.go
+++ b/pkg/common/db/controller/conversation.go
@@ -99,8 +99,8 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
now := time.Now()
for _, v := range NotUserIDs {
temp := new(relationtb.ConversationModel)
- if err2 := utils.CopyStructFields(temp, conversation); err2 != nil {
- return err2
+ if err := utils.CopyStructFields(temp, conversation); err != nil {
+ return err
}
temp.OwnerUserID = v
temp.CreateTime = now
@@ -113,12 +113,10 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context,
}
cache = cache.DelConversationIDs(NotUserIDs...).DelUserConversationIDsHash(NotUserIDs...).DelConversations(conversation.ConversationID, NotUserIDs...)
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -132,7 +130,6 @@ func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context,
if _, ok := args["recv_msg_opt"]; ok {
cache = cache.DelConversationNotReceiveMessageUserIDs(conversationID)
}
-
return cache.ExecDel(ctx)
}
@@ -140,14 +137,13 @@ func (c *conversationDatabase) CreateConversation(ctx context.Context, conversat
if err := c.conversationDB.Create(ctx, conversations); err != nil {
return err
}
- userIDs := make([]string, 0, len(conversations))
+ var userIDs []string
cache := c.cache.NewCache()
for _, conversation := range conversations {
cache = cache.DelConversations(conversation.OwnerUserID, conversation.ConversationID)
cache = cache.DelConversationNotReceiveMessageUserIDs(conversation.ConversationID)
userIDs = append(userIDs, conversation.OwnerUserID)
}
-
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
}
@@ -182,12 +178,10 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Con
}
}
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -240,15 +234,12 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs
if err != nil {
return err
}
- cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID)
- cache = cache.DelConversationNotReceiveMessageUserIDs(utils.Slice(notExistConversations, func(e *relationtb.ConversationModel) string { return e.ConversationID })...)
+ cache = cache.DelConversationIDs(ownerUserID).DelUserConversationIDsHash(ownerUserID).DelConversationNotReceiveMessageUserIDs(utils.Slice(notExistConversations, func(e *relationtb.ConversationModel) string { return e.ConversationID })...)
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -285,12 +276,10 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context,
for _, v := range existConversationUserIDs {
cache = cache.DelConversations(v, conversationID)
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go
index f35d6728b..7816ef935 100644
--- a/pkg/common/db/controller/friend.go
+++ b/pkg/common/db/controller/friend.go
@@ -16,7 +16,6 @@ package controller
import (
"context"
- "errors"
"time"
"gorm.io/gorm"
@@ -110,7 +109,6 @@ func (f *friendDatabase) CheckIn(
if err != nil {
return
}
-
return utils.IsContain(userID2, userID1FriendIDs), utils.IsContain(userID1, userID2FriendIDs), nil
}
@@ -123,8 +121,8 @@ func (f *friendDatabase) AddFriendRequest(
) (err error) {
return f.tx.Transaction(func(tx any) error {
_, err := f.friendRequest.NewTx(tx).Take(ctx, fromUserID, toUserID)
- // if there is a db error
- if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
+ // 有db错误
+ if err != nil && errs.Unwrap(err) != gorm.ErrRecordNotFound {
return err
}
// 无错误 则更新
@@ -138,14 +136,12 @@ func (f *friendDatabase) AddFriendRequest(
if err := f.friendRequest.NewTx(tx).UpdateByMap(ctx, fromUserID, toUserID, m); err != nil {
return err
}
-
return nil
}
// gorm.ErrRecordNotFound 错误,则新增
if err := f.friendRequest.NewTx(tx).Create(ctx, []*relation.FriendRequestModel{{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex, CreateTime: time.Now(), HandleTime: time.Unix(0, 0)}}); err != nil {
return err
}
-
return nil
})
}
@@ -158,11 +154,11 @@ func (f *friendDatabase) BecomeFriends(
addSource int32,
) (err error) {
cache := f.cache.NewCache()
- fn := func(tx any) error {
- // first,find and drop delete ones
- fs1, err2 := f.friend.NewTx(tx).FindFriends(ctx, ownerUserID, friendUserIDs)
- if err2 != nil {
- return err2
+ if err := f.tx.Transaction(func(tx any) error {
+ // 先find 找出重复的 去掉重复的
+ fs1, err := f.friend.NewTx(tx).FindFriends(ctx, ownerUserID, friendUserIDs)
+ if err != nil {
+ return err
}
opUserID := mcontext.GetOperationID(ctx)
for _, v := range friendUserIDs {
@@ -172,13 +168,13 @@ func (f *friendDatabase) BecomeFriends(
return e.FriendUserID
})
- err2 = f.friend.NewTx(tx).Create(ctx, fs11)
- if err2 != nil {
- return err2
+ err = f.friend.NewTx(tx).Create(ctx, fs11)
+ if err != nil {
+ return err
}
- fs2, err2 := f.friend.NewTx(tx).FindReversalFriends(ctx, ownerUserID, friendUserIDs)
- if err2 != nil {
- return err2
+ fs2, err := f.friend.NewTx(tx).FindReversalFriends(ctx, ownerUserID, friendUserIDs)
+ if err != nil {
+ return err
}
var newFriendIDs []string
for _, v := range friendUserIDs {
@@ -188,20 +184,16 @@ func (f *friendDatabase) BecomeFriends(
fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string {
return e.OwnerUserID
})
- err2 = f.friend.NewTx(tx).Create(ctx, fs22)
- if err2 != nil {
- return err2
+ err = f.friend.NewTx(tx).Create(ctx, fs22)
+ if err != nil {
+ return err
}
newFriendIDs = append(newFriendIDs, ownerUserID)
cache = cache.DelFriendIDs(newFriendIDs...)
-
+ return nil
+ }); err != nil {
return nil
}
- err = f.tx.Transaction(fn)
- if err != nil {
- return err
- }
-
return cache.ExecDel(ctx)
}
@@ -224,7 +216,6 @@ func (f *friendDatabase) RefuseFriendRequest(
if err != nil {
return err
}
-
return nil
}
@@ -260,7 +251,7 @@ func (f *friendDatabase) AgreeFriendRequest(
if err != nil {
return err
}
- } else if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
+ } else if err != nil && errs.Unwrap(err) != gorm.ErrRecordNotFound {
return err
}
@@ -299,7 +290,6 @@ func (f *friendDatabase) AgreeFriendRequest(
return err
}
}
-
return f.cache.DelFriendIDs(friendRequest.ToUserID, friendRequest.FromUserID).ExecDel(ctx)
})
}
@@ -309,7 +299,6 @@ func (f *friendDatabase) Delete(ctx context.Context, ownerUserID string, friendU
if err := f.friend.Delete(ctx, ownerUserID, friendUserIDs); err != nil {
return err
}
-
return f.cache.DelFriendIDs(append(friendUserIDs, ownerUserID)...).ExecDel(ctx)
}
@@ -318,7 +307,6 @@ func (f *friendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
if err := f.friend.UpdateRemark(ctx, ownerUserID, friendUserID, remark); err != nil {
return err
}
-
return f.cache.DelFriend(ownerUserID, friendUserID).ExecDel(ctx)
}
@@ -371,7 +359,6 @@ func (f *friendDatabase) FindFriendsWithError(
if len(friends) != len(friendUserIDs) {
err = errs.ErrRecordNotFound.Wrap()
}
-
return
}
diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go
index 0788429a8..194f3e8b2 100644
--- a/pkg/common/db/controller/group.go
+++ b/pkg/common/db/controller/group.go
@@ -102,7 +102,6 @@ func NewGroupDatabase(
cache: cache,
mongoDB: superGroup,
}
-
return database
}
@@ -110,7 +109,6 @@ func InitGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, database *mongo.D
rcOptions := rockscache.NewDefaultOptions()
rcOptions.StrongConsistency = true
rcOptions.RandomExpireAdjustment = 0.2
-
return NewGroupDatabase(
relation.NewGroupDB(db),
relation.NewGroupMemberDB(db),
@@ -153,7 +151,6 @@ func (g *groupDatabase) FindGroupMemberNum(ctx context.Context, groupID string)
if err != nil {
return 0, err
}
-
return uint32(num), nil
}
@@ -187,12 +184,10 @@ func (g *groupDatabase) CreateGroup(
cache = cache.DelJoinedGroupID(groupMember.UserID).DelGroupMembersInfo(groupMember.GroupID, groupMember.UserID)
}
cache = cache.DelGroupsInfo(createGroupIDs...)
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -216,7 +211,6 @@ func (g *groupDatabase) UpdateGroup(ctx context.Context, groupID string, data ma
if err := g.groupDB.UpdateMap(ctx, groupID, data); err != nil {
return err
}
-
return g.cache.DelGroupsInfo(groupID).ExecDel(ctx)
}
@@ -237,12 +231,10 @@ func (g *groupDatabase) DismissGroup(ctx context.Context, groupID string, delete
cache = cache.DelJoinedGroupID(userIDs...).DelGroupMemberIDs(groupID).DelGroupsMemberNum(groupID).DelGroupMembersHash(groupID)
}
cache = cache.DelGroupsInfo(groupID)
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -284,7 +276,6 @@ func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string,
}
res = append(res, v)
}
-
return res, nil
}
if len(roleLevels) == 0 {
@@ -295,10 +286,8 @@ func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string,
}
totalGroupMembers = append(totalGroupMembers, groupMembers...)
}
-
return totalGroupMembers, nil
}
-
return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels)
}
@@ -318,7 +307,6 @@ func (g *groupDatabase) PageGetJoinGroup(
}
totalGroupMembers = append(totalGroupMembers, groupMembers...)
}
-
return uint32(len(groupIDs)), totalGroupMembers, nil
}
@@ -339,7 +327,6 @@ func (g *groupDatabase) PageGetGroupMember(
if err != nil {
return 0, nil, err
}
-
return uint32(len(groupMemberIDs)), members, nil
}
@@ -391,7 +378,6 @@ func (g *groupDatabase) HandlerGroupRequest(
return err
}
}
-
return nil
})
}
@@ -400,7 +386,6 @@ func (g *groupDatabase) DeleteGroupMember(ctx context.Context, groupID string, u
if err := g.groupMemberDB.Delete(ctx, groupID, userIDs); err != nil {
return err
}
-
return g.cache.DelGroupMembersHash(groupID).
DelGroupMemberIDs(groupID).
DelGroupsMemberNum(groupID).
@@ -425,7 +410,6 @@ func (g *groupDatabase) MapGroupMemberNum(ctx context.Context, groupIDs []string
}
m[groupID] = uint32(num)
}
-
return m, nil
}
@@ -445,7 +429,6 @@ func (g *groupDatabase) TransferGroupOwner(ctx context.Context, groupID string,
if rowsAffected != 1 {
return utils.Wrap(fmt.Errorf("newOwnerUserID %s rowsAffected = %d", newOwnerUserID, rowsAffected), "")
}
-
return g.cache.DelGroupMembersInfo(groupID, oldOwnerUserID, newOwnerUserID).DelGroupMembersHash(groupID).ExecDel(ctx)
})
}
@@ -459,7 +442,6 @@ func (g *groupDatabase) UpdateGroupMember(
if err := g.groupMemberDB.Update(ctx, groupID, userID, data); err != nil {
return err
}
-
return g.cache.DelGroupMembersInfo(groupID, userID).ExecDel(ctx)
}
@@ -472,12 +454,10 @@ func (g *groupDatabase) UpdateGroupMembers(ctx context.Context, data []*relation
}
cache = cache.DelGroupMembersInfo(item.GroupID, item.UserID)
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -489,7 +469,6 @@ func (g *groupDatabase) CreateGroupRequest(ctx context.Context, requests []*rela
return err
}
}
-
return db.Create(ctx, requests)
})
}
@@ -525,7 +504,6 @@ func (g *groupDatabase) CreateSuperGroup(ctx context.Context, groupID string, in
if err := g.mongoDB.CreateSuperGroup(ctx, groupID, initMemberIDs); err != nil {
return err
}
-
return g.cache.DelSuperGroupMemberIDs(groupID).DelJoinedSuperGroupIDs(initMemberIDs...).ExecDel(ctx)
}
@@ -543,12 +521,10 @@ func (g *groupDatabase) DeleteSuperGroup(ctx context.Context, groupID string) er
if len(models) > 0 {
cache = cache.DelJoinedSuperGroupIDs(models[0].MemberIDs...)
}
-
return nil
}); err != nil {
return err
}
-
return cache.ExecDel(ctx)
}
@@ -556,7 +532,6 @@ func (g *groupDatabase) DeleteSuperGroupMember(ctx context.Context, groupID stri
if err := g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs); err != nil {
return err
}
-
return g.cache.DelSuperGroupMemberIDs(groupID).DelJoinedSuperGroupIDs(userIDs...).ExecDel(ctx)
}
@@ -564,7 +539,6 @@ func (g *groupDatabase) CreateSuperGroupMember(ctx context.Context, groupID stri
if err := g.mongoDB.AddUserToSuperGroup(ctx, groupID, userIDs); err != nil {
return err
}
-
return g.cache.DelSuperGroupMemberIDs(groupID).DelJoinedSuperGroupIDs(userIDs...).ExecDel(ctx)
}
diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go
index cda660afe..af678f92c 100644
--- a/pkg/common/db/controller/msg.go
+++ b/pkg/common/db/controller/msg.go
@@ -135,7 +135,6 @@ func InitCommonMsgDatabase(rdb redis.UniversalClient, database *mongo.Database)
cacheModel := cache.NewMsgCacheModel(rdb)
msgDocModel := unrelation.NewMsgMongoDriver(database)
CommonMsgDatabase := NewCommonMsgDatabase(msgDocModel, cacheModel)
-
return CommonMsgDatabase
}
@@ -151,17 +150,14 @@ type commonMsgDatabase struct {
func (db *commonMsgDatabase) MsgToMQ(ctx context.Context, key string, msg2mq *sdkws.MsgData) error {
_, _, err := db.producer.SendMessage(ctx, key, msg2mq)
-
return err
}
func (db *commonMsgDatabase) MsgToModifyMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData) error {
if len(messages) > 0 {
_, _, err := db.producerToModify.SendMessage(ctx, key, &pbmsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages})
-
return err
}
-
return nil
}
@@ -169,26 +165,26 @@ func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationI
partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbmsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
if err != nil {
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
-
return 0, 0, err
}
-
return partition, offset, nil
}
func (db *commonMsgDatabase) MsgToMongoMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData, lastSeq int64) error {
if len(messages) > 0 {
_, _, err := db.producerToMongo.SendMessage(ctx, key, &pbmsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages})
-
return err
}
-
return nil
}
-func checkTypeForBatchInsertBlock(fields []any, key int8, firstSeq int64) error {
+func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationID string, fields []any, key int8, firstSeq int64) error {
+ if len(fields) == 0 {
+ return nil
+ }
+ num := db.msg.GetSingleGocMsgNum()
// num = 100
- for i, field := range fields { // check type
+ for i, field := range fields { // 检查类型
var ok bool
switch key {
case updateKeyMsg:
@@ -206,106 +202,80 @@ func checkTypeForBatchInsertBlock(fields []any, key int8, firstSeq int64) error
return errs.ErrInternalServer.Wrap("field type is invalid")
}
}
-
- return nil
-}
-
-func (db *commonMsgDatabase) updateMsgModelForBatchInsertBlock(ctx context.Context, conversationID string, fields []any, key int8, seq int64, i int) (bool, error) {
- var (
- res *mongo.UpdateResult
- err error
- )
- docID := db.msg.GetDocID(conversationID, seq)
- index := db.msg.GetMsgIndex(seq)
- field := fields[i]
- switch key {
- case updateKeyMsg:
- res, err = db.msgDocDatabase.UpdateMsg(ctx, docID, index, "msg", field)
- case updateKeyRevoke:
- res, err = db.msgDocDatabase.UpdateMsg(ctx, docID, index, "revoke", field)
- }
- if err != nil {
- return false, err
- }
-
- return res.MatchedCount > 0, nil
-}
-
-func (db *commonMsgDatabase) newDocForBatchInsertBlock(conversationID string, fields []any, key int8, seq, firstSeq, num int64, i int) (unrelationtb.MsgDocModel, int) {
- doc := unrelationtb.MsgDocModel{
- DocID: db.msg.GetDocID(conversationID, seq),
- Msg: make([]*unrelationtb.MsgInfoModel, num),
- }
- var insert int // number of inserted
- for j := i; j < len(fields); j++ {
- seq = firstSeq + int64(j)
- if db.msg.GetDocID(conversationID, seq) != doc.DocID {
- break
- }
- insert++
+ // 返回值为true表示数据库存在该文档,false表示数据库不存在该文档
+ updateMsgModel := func(seq int64, i int) (bool, error) {
+ var (
+ res *mongo.UpdateResult
+ err error
+ )
+ docID := db.msg.GetDocID(conversationID, seq)
+ index := db.msg.GetMsgIndex(seq)
+ field := fields[i]
switch key {
case updateKeyMsg:
- doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
- Msg: fields[j].(*unrelationtb.MsgDataModel),
- }
+ res, err = db.msgDocDatabase.UpdateMsg(ctx, docID, index, "msg", field)
case updateKeyRevoke:
- doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
- Revoke: fields[j].(*unrelationtb.RevokeModel),
- }
- }
- }
- for i, model := range doc.Msg {
- if model == nil {
- model = &unrelationtb.MsgInfoModel{}
- doc.Msg[i] = model
+ res, err = db.msgDocDatabase.UpdateMsg(ctx, docID, index, "revoke", field)
}
- if model.DelList == nil {
- doc.Msg[i].DelList = []string{}
+ if err != nil {
+ return false, err
}
- }
-
- return doc, insert
-}
-
-func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationID string, fields []any, key int8, firstSeq int64) error {
- if len(fields) == 0 {
- return nil
- }
- num := db.msg.GetSingleGocMsgNum()
- // num = 100
- err := checkTypeForBatchInsertBlock(fields, key, firstSeq)
- if err != nil {
- return err
+ return res.MatchedCount > 0, nil
}
tryUpdate := true
for i := 0; i < len(fields); i++ {
- seq := firstSeq + int64(i) // current seq
- // try update
+ seq := firstSeq + int64(i) // 当前seq
if tryUpdate {
- matched, err := db.updateMsgModelForBatchInsertBlock(ctx, conversationID, fields, key, seq, i)
+ matched, err := updateMsgModel(seq, i)
if err != nil {
return err
}
if matched {
- continue // if matched,skip
+ continue // 匹配到了,继续下一个(不一定修改)
+ }
+ }
+ doc := unrelationtb.MsgDocModel{
+ DocID: db.msg.GetDocID(conversationID, seq),
+ Msg: make([]*unrelationtb.MsgInfoModel, num),
+ }
+ var insert int // 插入的数量
+ for j := i; j < len(fields); j++ {
+ seq = firstSeq + int64(j)
+ if db.msg.GetDocID(conversationID, seq) != doc.DocID {
+ break
+ }
+ insert++
+ switch key {
+ case updateKeyMsg:
+ doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
+ Msg: fields[j].(*unrelationtb.MsgDataModel),
+ }
+ case updateKeyRevoke:
+ doc.Msg[db.msg.GetMsgIndex(seq)] = &unrelationtb.MsgInfoModel{
+ Revoke: fields[j].(*unrelationtb.RevokeModel),
+ }
+ }
+ }
+ for i, model := range doc.Msg {
+ if model == nil {
+ model = &unrelationtb.MsgInfoModel{}
+ doc.Msg[i] = model
+ }
+ if model.DelList == nil {
+ doc.Msg[i].DelList = []string{}
}
}
- doc, insert := db.newDocForBatchInsertBlock(conversationID, fields, key, seq, firstSeq, num, i)
- // insert doc into db
if err := db.msgDocDatabase.Create(ctx, &doc); err != nil {
if mongo.IsDuplicateKeyError(err) {
- i-- // exists concurrent,
- tryUpdate = true // try update
-
+ i-- // 存在并发,重试当前数据
+ tryUpdate = true // 以修改模式
continue
}
-
return err
}
- tryUpdate = false // if insert success,change to insert mode
- i += insert - 1 // skip inserted data
+ tryUpdate = false // 当前以插入成功,下一块优先插入模式
+ i += insert - 1 // 跳过已插入的数据
}
-
return nil
}
@@ -352,7 +322,6 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
Ex: msg.Ex,
}
}
-
return db.BatchInsertBlock(ctx, conversationID, msgs, updateKeyMsg, msgList[0].Seq)
}
@@ -369,11 +338,9 @@ func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(ctx context.Context, userI
log.ZDebug(ctx, "MarkSingleChatMsgsAsRead", "userID", userID, "docID", docID, "indexes", indexes)
if err := db.msgDocDatabase.MarkSingleChatMsgsAsRead(ctx, userID, docID, indexes); err != nil {
log.ZError(ctx, "MarkSingleChatMsgsAsRead", err, "userID", userID, "docID", docID, "indexes", indexes)
-
return err
}
}
-
return nil
}
@@ -387,9 +354,8 @@ func (db *commonMsgDatabase) DelUserDeleteMsgsList(ctx context.Context, conversa
func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (seq int64, isNew bool, err error) {
currentMaxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
prome.Inc(prome.SeqGetFailedCounter)
-
return 0, false, err
}
prome.Inc(prome.SeqGetSuccessCounter)
@@ -400,7 +366,7 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
if lenList < 1 {
return 0, false, errors.New("too short as 0")
}
- if errors.Is(err, redis.Nil) {
+ if errs.Unwrap(err) == redis.Nil {
isNew = true
}
lastMaxSeq := currentMaxSeq
@@ -430,7 +396,6 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversa
} else {
prome.Inc(prome.SeqSetSuccessCounter)
}
-
return lastMaxSeq, isNew, utils.Wrap(err, "")
}
@@ -445,7 +410,6 @@ func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversat
totalMsgs = append(totalMsgs, convert.MsgDB2Pb(msg.Msg))
}
}
-
return totalMsgs, nil
}
@@ -456,7 +420,6 @@ func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID
msg.Msg.IsRead = true
}
}
-
return msgs, err
}
@@ -475,76 +438,16 @@ func (db *commonMsgDatabase) getMsgBySeqsRange(ctx context.Context, userID strin
seqMsgs = append(seqMsgs, convert.MsgDB2Pb(msg.Msg))
}
}
-
return seqMsgs, nil
}
-func (db *commonMsgDatabase) getCacheMsgForGetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin int64, seqs []int64) ([]*sdkws.MsgData, []int64, error) {
- newBegin := seqs[0]
- newEnd := seqs[len(seqs)-1]
- log.ZDebug(ctx, "GetMsgBySeqsRange", "first seqs", seqs, "newBegin", newBegin, "newEnd", newEnd)
- cachedMsgs, failedSeqs, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
- if err != nil {
- if !errors.Is(err, redis.Nil) {
- prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
- log.ZError(ctx, "get message from redis exception", err, "conversationID", conversationID, "seqs", seqs)
- }
- }
- var successMsgs []*sdkws.MsgData
- if len(cachedMsgs) == 0 {
- return successMsgs, failedSeqs, err
- }
- // if len(cachedMsgs) > 0
- delSeqs, err2 := db.cache.GetUserDelList(ctx, userID, conversationID)
- if err2 != nil && !errors.Is(err2, redis.Nil) {
- return nil, nil, err2
- }
- var cacheDelNum int
- for _, msg := range cachedMsgs {
- if !utils.Contain(msg.Seq, delSeqs...) {
- successMsgs = append(successMsgs, msg)
- } else {
- cacheDelNum += 1
- }
- }
- log.ZDebug(ctx, "get delSeqs from redis", "delSeqs", delSeqs, "userID", userID, "conversationID", conversationID, "cacheDelNum", cacheDelNum)
- var reGetSeqsCache []int64
- for i := 1; i <= cacheDelNum; {
- newSeq := newBegin - int64(i)
- if newSeq >= begin {
- if !utils.Contain(newSeq, delSeqs...) {
- log.ZDebug(ctx, "seq del in cache, a new seq in range append", "new seq", newSeq)
- reGetSeqsCache = append(reGetSeqsCache, newSeq)
- i++
- }
- } else {
- break
- }
- }
- if len(reGetSeqsCache) > 0 {
- log.ZDebug(ctx, "reGetSeqsCache", "reGetSeqsCache", reGetSeqsCache)
- cachedMsgs, failedSeqs2, err2 := db.cache.GetMessagesBySeq(ctx, conversationID, reGetSeqsCache)
- if err2 != nil {
- if !errors.Is(err2, redis.Nil) {
- prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs2))
- log.ZError(ctx, "get message from redis exception", err2, "conversationID", conversationID, "seqs", reGetSeqsCache)
- }
- }
- failedSeqs = append(failedSeqs, failedSeqs2...)
- successMsgs = append(successMsgs, cachedMsgs...)
- }
-
- return successMsgs, failedSeqs, err
-}
-
func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin, end, num, userMaxSeq int64) (int64, int64, []*sdkws.MsgData, error) {
- // 从缓存中获取最小和最大序列号,并根据给定的范围值进行调整
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
minSeq, err := db.cache.GetMinSeq(ctx, conversationID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
if userMinSeq > minSeq {
@@ -552,25 +455,18 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
}
if minSeq > end {
log.ZInfo(ctx, "minSeq > end", "minSeq", minSeq, "end", end)
-
return 0, 0, nil, nil
}
maxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
-
- // log out debug info
log.ZDebug(ctx, "GetMsgBySeqsRange", "userMinSeq", userMinSeq, "conMinSeq", minSeq, "conMaxSeq", maxSeq, "userMaxSeq", userMaxSeq)
-
- // adjust maxSeq according to userMaxSeq
if userMaxSeq != 0 {
if userMaxSeq < maxSeq {
maxSeq = userMaxSeq
}
}
-
- // adjust begin and end according to minSeq and maxSeq
if begin < minSeq {
begin = minSeq
}
@@ -580,8 +476,6 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
if end < begin {
return 0, 0, nil, errs.ErrArgs.Wrap("seq end < begin")
}
-
- // get seqs to search
var seqs []int64
for i := end; i > end-num; i-- {
if i >= begin {
@@ -593,24 +487,67 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
if len(seqs) == 0 {
return 0, 0, nil, nil
}
-
- // get info from cache,and filter deleted msg
- successMsgs, failedSeqs, err := db.getCacheMsgForGetMsgBySeqsRange(ctx, userID, conversationID, begin, seqs)
+ newBegin := seqs[0]
+ newEnd := seqs[len(seqs)-1]
+ log.ZDebug(ctx, "GetMsgBySeqsRange", "first seqs", seqs, "newBegin", newBegin, "newEnd", newEnd)
+ cachedMsgs, failedSeqs, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
if err != nil {
- return 0, 0, nil, err
+ if err != redis.Nil {
+ prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
+ log.ZError(ctx, "get message from redis exception", err, "conversationID", conversationID, "seqs", seqs)
+ }
+ }
+ var successMsgs []*sdkws.MsgData
+ if len(cachedMsgs) > 0 {
+ delSeqs, err := db.cache.GetUserDelList(ctx, userID, conversationID)
+ if err != nil && errs.Unwrap(err) != redis.Nil {
+ return 0, 0, nil, err
+ }
+ var cacheDelNum int
+ for _, msg := range cachedMsgs {
+ if !utils.Contain(msg.Seq, delSeqs...) {
+ successMsgs = append(successMsgs, msg)
+ } else {
+ cacheDelNum += 1
+ }
+ }
+ log.ZDebug(ctx, "get delSeqs from redis", "delSeqs", delSeqs, "userID", userID, "conversationID", conversationID, "cacheDelNum", cacheDelNum)
+ var reGetSeqsCache []int64
+ for i := 1; i <= cacheDelNum; {
+ newSeq := newBegin - int64(i)
+ if newSeq >= begin {
+ if !utils.Contain(newSeq, delSeqs...) {
+ log.ZDebug(ctx, "seq del in cache, a new seq in range append", "new seq", newSeq)
+ reGetSeqsCache = append(reGetSeqsCache, newSeq)
+ i++
+ }
+ } else {
+ break
+ }
+ }
+ if len(reGetSeqsCache) > 0 {
+ log.ZDebug(ctx, "reGetSeqsCache", "reGetSeqsCache", reGetSeqsCache)
+ cachedMsgs, failedSeqs2, err := db.cache.GetMessagesBySeq(ctx, conversationID, reGetSeqsCache)
+ if err != nil {
+ if err != redis.Nil {
+ prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs2))
+ log.ZError(ctx, "get message from redis exception", err, "conversationID", conversationID, "seqs", reGetSeqsCache)
+ }
+ }
+ failedSeqs = append(failedSeqs, failedSeqs2...)
+ successMsgs = append(successMsgs, cachedMsgs...)
+ }
}
- // log out debug info
log.ZDebug(ctx, "get msgs from cache", "successMsgs", successMsgs)
if len(failedSeqs) != 0 {
log.ZDebug(ctx, "msgs not exist in redis", "seqs", failedSeqs)
}
- // if not found in cache,find in mongo
+ // get from cache or db
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
if len(failedSeqs) > 0 {
mongoMsgs, err := db.getMsgBySeqsRange(ctx, userID, conversationID, failedSeqs, begin, end)
if err != nil {
prome.Add(prome.MsgPullFromMongoFailedCounter, len(failedSeqs))
-
return 0, 0, nil, err
}
prome.Add(prome.MsgPullFromMongoSuccessCounter, len(mongoMsgs))
@@ -622,15 +559,15 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) (int64, int64, []*sdkws.MsgData, error) {
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
minSeq, err := db.cache.GetMinSeq(ctx, conversationID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
maxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
- if err != nil && !errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return 0, 0, nil, err
}
if userMinSeq < minSeq {
@@ -644,7 +581,7 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co
}
successMsgs, failedSeqs, err := db.cache.GetMessagesBySeq(ctx, conversationID, newSeqs)
if err != nil {
- if !errors.Is(err, redis.Nil) {
+ if err != redis.Nil {
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID)
}
@@ -670,13 +607,11 @@ func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, co
mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs)
if err != nil {
prome.Add(prome.MsgPullFromMongoFailedCounter, len(failedSeqs))
-
return 0, 0, nil, err
}
prome.Add(prome.MsgPullFromMongoSuccessCounter, len(mongoMsgs))
successMsgs = append(successMsgs, mongoMsgs...)
}
-
return minSeq, maxSeq, successMsgs, nil
}
@@ -697,81 +632,61 @@ func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(ctx context.Cont
log.ZWarn(ctx, "CleanUpOneUserAllMsg", err, "conversationID", conversationID)
}
}
-
return db.cache.SetMinSeq(ctx, conversationID, minSeq)
}
-func processMsgDocModel(
- ctx context.Context,
- msgDocModel *unrelationtb.MsgDocModel,
- userID, conversationID string,
- index int64,
- destructTime int64,
- lastMsgDestructTime time.Time,
-) (seqs []int64, over bool) {
- if len(msgDocModel.Msg) > 0 {
- i := 0
- for _, msg := range msgDocModel.Msg {
- i++
- if msg != nil && msg.Msg != nil && msg.Msg.SendTime+destructTime*1000 <= time.Now().UnixMilli() {
- if msg.Msg.SendTime+destructTime*1000 > lastMsgDestructTime.UnixMilli() && !utils.Contain(userID, msg.DelList...) {
- seqs = append(seqs, msg.Msg.Seq)
- }
- } else {
- log.ZDebug(ctx, "all msg need destruct is found", "conversationID", conversationID, "userID", userID, "index", index, "stop index", i)
- over = true
-
- return seqs, over
- }
- }
- }
-
- return seqs, over
-}
-
-func (db *commonMsgDatabase) UserMsgsDestruct(ctx context.Context, userID, conversationID string, destructTime int64, lastMsgDestructTime time.Time) (seqs []int64, err error) {
+func (db *commonMsgDatabase) UserMsgsDestruct(ctx context.Context, userID string, conversationID string, destructTime int64, lastMsgDestructTime time.Time) (seqs []int64, err error) {
var index int64
-
- // refresh msg list
for {
- // from oldest to newest
- msgDocModel, err2 := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
- if err2 != nil || msgDocModel.DocID == "" {
- if err2 != nil {
- if errors.Is(err2, unrelation.ErrMsgListNotExist) {
+ // from oldest 2 newest
+ msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
+ if err != nil || msgDocModel.DocID == "" {
+ if err != nil {
+ if err == unrelation.ErrMsgListNotExist {
log.ZDebug(ctx, "not doc find", "conversationID", conversationID, "userID", userID, "index", index)
} else {
- log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err2, "conversationID", conversationID, "index", index)
+ log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
}
}
- // If there is an error or no message document is found, delete the message physically and return the sequence number, then end the recursion.
+ // 获取报错,或者获取不到了,物理删除并且返回seq delMongoMsgsPhysical(delStruct.delDocIDList), 结束递归
break
}
index++
//&& msgDocModel.Msg[0].Msg.SendTime > lastMsgDestructTime.UnixMilli()
- curSeqs, over := processMsgDocModel(ctx, msgDocModel, userID, conversationID, index, destructTime, lastMsgDestructTime)
- seqs = append(seqs, curSeqs...)
- if over {
- break
+ if len(msgDocModel.Msg) > 0 {
+ i := 0
+ var over bool
+ for _, msg := range msgDocModel.Msg {
+ i++
+ if msg != nil && msg.Msg != nil && msg.Msg.SendTime+destructTime*1000 <= time.Now().UnixMilli() {
+ if msg.Msg.SendTime+destructTime*1000 > lastMsgDestructTime.UnixMilli() && !utils.Contain(userID, msg.DelList...) {
+ seqs = append(seqs, msg.Msg.Seq)
+ }
+ } else {
+ log.ZDebug(ctx, "all msg need destruct is found", "conversationID", conversationID, "userID", userID, "index", index, "stop index", i)
+ over = true
+ break
+ }
+ }
+ if over {
+ break
+ }
}
}
- // Log the result of the function call.
+
log.ZDebug(ctx, "UserMsgsDestruct", "conversationID", conversationID, "userID", userID, "seqs", seqs)
- if len(seqs) == 0 {
- return seqs, nil
- }
- // if len(seqs) > 0
- userMinSeq := seqs[len(seqs)-1] + 1
- currentUserMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
- if err != nil && !errors.Is(err, redis.Nil) {
- return nil, err
- }
- if currentUserMinSeq < userMinSeq {
- if err := db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, userMinSeq); err != nil {
+ if len(seqs) > 0 {
+ userMinSeq := seqs[len(seqs)-1] + 1
+ currentUserMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
+ if err != nil && errs.Unwrap(err) != redis.Nil {
return nil, err
}
+ if currentUserMinSeq < userMinSeq {
+ if err := db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, userMinSeq); err != nil {
+ return nil, err
+ }
+ }
}
-
return seqs, nil
}
@@ -794,65 +709,45 @@ func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversatio
msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
if err != nil || msgDocModel.DocID == "" {
if err != nil {
- if errors.Is(err, unrelation.ErrMsgListNotExist) {
+ if err == unrelation.ErrMsgListNotExist {
log.ZDebug(ctx, "deleteMsgRecursion ErrMsgListNotExist", "conversationID", conversationID, "index:", index)
} else {
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
}
}
- // get error or miss content, delete physically and return minSeq,delMongoMsgsPhysical(delStruct.delDocIDList), end recursion
+ // 获取报错,或者获取不到了,物理删除并且返回seq delMongoMsgsPhysical(delStruct.delDocIDList), 结束递归
err = db.msgDocDatabase.DeleteDocs(ctx, delStruct.delDocIDs)
if err != nil {
return 0, err
}
-
return delStruct.getSetMinSeq() + 1, nil
}
-
log.ZDebug(ctx, "doc info", "conversationID", conversationID, "index", index, "docID", msgDocModel.DocID, "len", len(msgDocModel.Msg))
if int64(len(msgDocModel.Msg)) > db.msg.GetSingleGocMsgNum() {
log.ZWarn(ctx, "msgs too large", nil, "lenth", len(msgDocModel.Msg), "docID:", msgDocModel.DocID)
}
- fullAndExpired := msgDocModel.IsFull() && msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill()
- if fullAndExpired {
- handleFullAndExpiredForDeleteMsgRecursion(ctx, msgDocModel, delStruct)
+ if msgDocModel.IsFull() && msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill() {
+ log.ZDebug(ctx, "doc is full and all msg is expired", "docID", msgDocModel.DocID)
+ delStruct.delDocIDs = append(delStruct.delDocIDs, msgDocModel.DocID)
+ delStruct.minSeq = msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.Seq
} else {
- handleNotFullAndExpiredForDeleteMsgRecursion(ctx, msgDocModel, remainTime, index, conversationID, delStruct, db)
- }
- seq, err := db.deleteMsgRecursion(ctx, conversationID, index+1, delStruct, remainTime)
-
- return seq, err
-}
-
-func handleFullAndExpiredForDeleteMsgRecursion(ctx context.Context, msgDocModel *unrelationtb.MsgDocModel, delStruct *delMsgRecursionStruct) {
- log.ZDebug(ctx, "doc is full and all msg is expired", "docID", msgDocModel.DocID)
- delStruct.delDocIDs = append(delStruct.delDocIDs, msgDocModel.DocID)
- delStruct.minSeq = msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.Seq
-}
-
-func handleNotFullAndExpiredForDeleteMsgRecursion(
- ctx context.Context,
- msgDocModel *unrelationtb.MsgDocModel,
- remainTime, index int64,
- conversationID string,
- delStruct *delMsgRecursionStruct,
- db *commonMsgDatabase,
-) {
- var delMsgIndexs []int
- for i, MsgInfoModel := range msgDocModel.Msg {
- if MsgInfoModel != nil && MsgInfoModel.Msg != nil {
- if utils.GetCurrentTimestampByMill() > MsgInfoModel.Msg.SendTime+(remainTime*1000) {
- delMsgIndexs = append(delMsgIndexs, i)
+ var delMsgIndexs []int
+ for i, MsgInfoModel := range msgDocModel.Msg {
+ if MsgInfoModel != nil && MsgInfoModel.Msg != nil {
+ if utils.GetCurrentTimestampByMill() > MsgInfoModel.Msg.SendTime+(remainTime*1000) {
+ delMsgIndexs = append(delMsgIndexs, i)
+ }
}
}
- }
- if len(delMsgIndexs) > 0 {
- err2 := db.msgDocDatabase.DeleteMsgsInOneDocByIndex(ctx, msgDocModel.DocID, delMsgIndexs)
- if err2 != nil {
- log.ZError(ctx, "deleteMsgRecursion DeleteMsgsInOneDocByIndex failed", err2, "conversationID", conversationID, "index", index)
+ if len(delMsgIndexs) > 0 {
+ if err := db.msgDocDatabase.DeleteMsgsInOneDocByIndex(ctx, msgDocModel.DocID, delMsgIndexs); err != nil {
+ log.ZError(ctx, "deleteMsgRecursion DeleteMsgsInOneDocByIndex failed", err, "conversationID", conversationID, "index", index)
+ }
+ delStruct.minSeq = int64(msgDocModel.Msg[delMsgIndexs[len(delMsgIndexs)-1]].Msg.Seq)
}
- delStruct.minSeq = msgDocModel.Msg[delMsgIndexs[len(delMsgIndexs)-1]].Msg.Seq
}
+ seq, err := db.deleteMsgRecursion(ctx, conversationID, index+1, delStruct, remainTime)
+ return seq, err
}
func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(ctx context.Context, conversationID string, allSeqs []int64) error {
@@ -868,15 +763,13 @@ func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(ctx context.Context, conve
return err
}
}
-
return nil
}
func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) error {
cachedMsgs, _, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
- if err != nil && errors.Is(err, redis.Nil) {
+ if err != nil && errs.Unwrap(err) != redis.Nil {
log.ZWarn(ctx, "DeleteUserMsgsBySeqs", err, "conversationID", conversationID, "seqs", seqs)
-
return err
}
if len(cachedMsgs) > 0 {
@@ -896,7 +789,6 @@ func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(ctx context.Context, userID st
}
}
}
-
return nil
}
@@ -908,12 +800,11 @@ func (db *commonMsgDatabase) CleanUpUserConversationsMsgs(ctx context.Context, u
for _, conversationID := range conversationIDs {
maxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
if err != nil {
- if errors.Is(err, redis.Nil) {
+ if err == redis.Nil {
log.ZInfo(ctx, "max seq is nil", "conversationID", conversationID)
} else {
log.ZError(ctx, "get max seq failed", err, "conversationID", conversationID)
}
-
continue
}
if err := db.cache.SetMinSeq(ctx, conversationID, maxSeq+1); err != nil {
@@ -1007,7 +898,6 @@ func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(ctx context
if err != nil {
return
}
-
return
}
@@ -1026,7 +916,6 @@ func (db *commonMsgDatabase) GetMinMaxSeqMongo(ctx context.Context, conversation
return
}
maxSeqMongo = newestMsgMongo.Msg.Seq
-
return
}
@@ -1054,7 +943,7 @@ func (db *commonMsgDatabase) RangeGroupSendCount(
}
func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbmsg.SearchMessageReq) (total int32, msgData []*sdkws.MsgData, err error) {
- totalMsgs := make([]*sdkws.MsgData, 0)
+ var totalMsgs []*sdkws.MsgData
total, msgs, err := db.msgDocDatabase.SearchMessage(ctx, req)
if err != nil {
return 0, nil, err
@@ -1065,7 +954,6 @@ func (db *commonMsgDatabase) SearchMessage(ctx context.Context, req *pbmsg.Searc
}
totalMsgs = append(totalMsgs, convert.MsgDB2Pb(msg.Msg))
}
-
return total, totalMsgs, nil
}
diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go
index 15448674b..80e2db122 100644
--- a/pkg/common/db/controller/msg_test.go
+++ b/pkg/common/db/controller/msg_test.go
@@ -162,7 +162,6 @@ func GetDB() *commonMsgDatabase {
if err != nil {
panic(err)
}
-
return &commonMsgDatabase{
msgDocDatabase: unrelation.NewMsgMongoDriver(mongo.GetDatabase()),
}
diff --git a/pkg/common/db/controller/s3.go b/pkg/common/db/controller/s3.go
index f848f15a4..6ef3e73b3 100644
--- a/pkg/common/db/controller/s3.go
+++ b/pkg/common/db/controller/s3.go
@@ -89,6 +89,5 @@ func (s *s3Database) AccessURL(ctx context.Context, name string, expire time.Dur
if err != nil {
return time.Time{}, "", err
}
-
return expireTime, rawURL, nil
}
diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go
index d4a120f1c..9c6fdc5c4 100644
--- a/pkg/common/db/controller/user.go
+++ b/pkg/common/db/controller/user.go
@@ -90,7 +90,6 @@ func (u *userDatabase) InitOnce(ctx context.Context, users []*relation.UserModel
if len(miss) > 0 {
_ = u.userDB.Create(ctx, miss)
}
-
return nil
}
@@ -103,35 +102,30 @@ func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (use
if len(users) != len(userIDs) {
err = errs.ErrRecordNotFound.Wrap("userID not found")
}
-
return
}
// Find Get the information of the specified user. If the userID is not found, no error will be returned.
func (u *userDatabase) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
users, err = u.cache.GetUsersInfo(ctx, userIDs)
-
return
}
// Create Insert multiple external guarantees that the userID is not repeated and does not exist in the db.
func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) {
- err = u.tx.Transaction(func(tx any) error {
+ if err := u.tx.Transaction(func(tx any) error {
err = u.userDB.Create(ctx, users)
if err != nil {
return err
}
-
return nil
- })
- if err != nil {
+ }); err != nil {
return err
}
- userIDs := make([]string, 0, len(users))
+ var userIDs []string
for _, user := range users {
userIDs = append(userIDs, user.UserID)
}
-
return u.cache.DelUsersInfo(userIDs...).ExecDel(ctx)
}
@@ -140,7 +134,6 @@ func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (er
if err := u.userDB.Update(ctx, user); err != nil {
return err
}
-
return u.cache.DelUsersInfo(user.UserID).ExecDel(ctx)
}
@@ -149,7 +142,6 @@ func (u *userDatabase) UpdateByMap(ctx context.Context, userID string, args map[
if err := u.userDB.UpdateByMap(ctx, userID, args); err != nil {
return err
}
-
return u.cache.DelUsersInfo(userID).ExecDel(ctx)
}
@@ -170,7 +162,6 @@ func (u *userDatabase) IsExist(ctx context.Context, userIDs []string) (exist boo
if len(users) > 0 {
return true, nil
}
-
return false, nil
}
@@ -192,14 +183,12 @@ func (u *userDatabase) CountRangeEverydayTotal(ctx context.Context, start time.T
// SubscribeUsersStatus Subscribe or unsubscribe a user's presence status.
func (u *userDatabase) SubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
err := u.mongoDB.AddSubscriptionList(ctx, userID, userIDs)
-
return err
}
// UnsubscribeUsersStatus unsubscribe a user's presence status.
func (u *userDatabase) UnsubscribeUsersStatus(ctx context.Context, userID string, userIDs []string) error {
err := u.mongoDB.UnsubscriptionList(ctx, userID, userIDs)
-
return err
}
@@ -209,7 +198,6 @@ func (u *userDatabase) GetAllSubscribeList(ctx context.Context, userID string) (
if err != nil {
return nil, err
}
-
return list, nil
}
@@ -219,14 +207,12 @@ func (u *userDatabase) GetSubscribedList(ctx context.Context, userID string) ([]
if err != nil {
return nil, err
}
-
return list, nil
}
// GetUserStatus get user status.
func (u *userDatabase) GetUserStatus(ctx context.Context, userIDs []string) ([]*user.OnlineStatus, error) {
onlineStatusList, err := u.cache.GetUserStatus(ctx, userIDs)
-
return onlineStatusList, err
}
diff --git a/pkg/common/db/localcache/conversation.go b/pkg/common/db/localcache/conversation.go
index b43e58257..c40bcdbce 100644
--- a/pkg/common/db/localcache/conversation.go
+++ b/pkg/common/db/localcache/conversation.go
@@ -50,7 +50,6 @@ func (g *ConversationLocalCache) GetRecvMsgNotNotifyUserIDs(ctx context.Context,
if err != nil {
return nil, err
}
-
return resp.UserIDs, nil
}
diff --git a/pkg/common/db/localcache/group.go b/pkg/common/db/localcache/group.go
index 140c3aeaf..4958d91ee 100644
--- a/pkg/common/db/localcache/group.go
+++ b/pkg/common/db/localcache/group.go
@@ -57,7 +57,6 @@ func (g *GroupLocalCache) GetGroupMemberIDs(ctx context.Context, groupID string)
localHashInfo, ok := g.cache[groupID]
if ok && localHashInfo.memberListHash == resp.GroupAbstractInfos[0].GroupMemberListHash {
g.lock.Unlock()
-
return localHashInfo.userIDs, nil
}
g.lock.Unlock()
@@ -75,6 +74,5 @@ func (g *GroupLocalCache) GetGroupMemberIDs(ctx context.Context, groupID string)
memberListHash: resp.GroupAbstractInfos[0].GroupMemberListHash,
userIDs: groupMembersResp.UserIDs,
}
-
return g.cache[groupID].userIDs, nil
}
diff --git a/pkg/common/db/relation/black_model.go b/pkg/common/db/relation/black_model.go
index 58dae3745..34123c7a3 100644
--- a/pkg/common/db/relation/black_model.go
+++ b/pkg/common/db/relation/black_model.go
@@ -63,11 +63,10 @@ func (b *BlackGorm) Find(
ctx context.Context,
blacks []*relation.BlackModel,
) (blackList []*relation.BlackModel, err error) {
- where := make([][]interface{}, 0, len(blacks))
+ var where [][]interface{}
for _, black := range blacks {
where = append(where, []interface{}{black.OwnerUserID, black.BlockUserID})
}
-
return blackList, utils.Wrap(
b.db(ctx).Where("(owner_user_id, block_user_id) in ?", where).Find(&blackList).Error,
"",
@@ -76,7 +75,6 @@ func (b *BlackGorm) Find(
func (b *BlackGorm) Take(ctx context.Context, ownerUserID, blockUserID string) (black *relation.BlackModel, err error) {
black = &relation.BlackModel{}
-
return black, utils.Wrap(
b.db(ctx).Where("owner_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Take(black).Error,
"",
@@ -98,7 +96,6 @@ func (b *BlackGorm) FindOwnerBlacks(
showNumber,
)
total = int64(totalUint32)
-
return
}
diff --git a/pkg/common/db/relation/chat_log_model.go b/pkg/common/db/relation/chat_log_model.go
index f474a2d34..f183a543f 100644
--- a/pkg/common/db/relation/chat_log_model.go
+++ b/pkg/common/db/relation/chat_log_model.go
@@ -15,8 +15,6 @@
package relation
import (
-
- //nolint:staticcheck //tofix: SA1019: "github.com/golang/protobuf/jsonpb" is deprecated: Use the "google.golang.org/protobuf/encoding/protojson" package instead.
"github.com/golang/protobuf/jsonpb"
"github.com/jinzhu/copier"
"google.golang.org/protobuf/proto"
@@ -40,10 +38,7 @@ func NewChatLogGorm(db *gorm.DB) relation.ChatLogModelInterface {
func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error {
chatLog := new(relation.ChatLogModel)
- err := copier.Copy(chatLog, msg.MsgData)
- if err != nil {
- return err
- }
+ copier.Copy(chatLog, msg.MsgData)
switch msg.MsgData.SessionType {
case constant.GroupChatType, constant.SuperGroupChatType:
chatLog.RecvID = msg.MsgData.GroupID
@@ -64,6 +59,5 @@ func (c *ChatLogGorm) Create(msg *pbmsg.MsgDataToMQ) error {
}
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
-
return c.DB.Create(chatLog).Error
}
diff --git a/pkg/common/db/relation/conversation_model.go b/pkg/common/db/relation/conversation_model.go
index 37a4e02be..d5ca92ec2 100644
--- a/pkg/common/db/relation/conversation_model.go
+++ b/pkg/common/db/relation/conversation_model.go
@@ -54,7 +54,6 @@ func (c *ConversationGorm) UpdateByMap(
args map[string]interface{},
) (rows int64, err error) {
result := c.db(ctx).Where("owner_user_id IN (?) and conversation_id=?", userIDList, conversationID).Updates(args)
-
return result.RowsAffected, utils.Wrap(result.Error, "")
}
@@ -80,7 +79,6 @@ func (c *ConversationGorm) Find(
Error,
"",
)
-
return conversations, err
}
@@ -89,7 +87,6 @@ func (c *ConversationGorm) Take(
userID, conversationID string,
) (conversation *relation.ConversationModel, err error) {
cc := &relation.ConversationModel{}
-
return cc, utils.Wrap(
c.db(ctx).Where("conversation_id = ? And owner_user_id = ?", conversationID, userID).Take(cc).Error,
"",
@@ -172,7 +169,6 @@ func (c *ConversationGorm) GetUserRecvMsgOpt(
ownerUserID, conversationID string,
) (opt int, err error) {
var conversation relation.ConversationModel
-
return int(
conversation.RecvMsgOpt,
), utils.Wrap(
@@ -223,7 +219,6 @@ func (c *ConversationGorm) GetConversationIDsNeedDestruct(
func (c *ConversationGorm) GetConversationRecvMsgOpt(ctx context.Context, userID string, conversationID string) (int32, error) {
var recvMsgOpt int32
-
return recvMsgOpt, errs.Wrap(
c.db(ctx).
Model(&relation.ConversationModel{}).
@@ -235,7 +230,6 @@ func (c *ConversationGorm) GetConversationRecvMsgOpt(ctx context.Context, userID
func (c *ConversationGorm) GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error) {
var userIDs []string
-
return userIDs, errs.Wrap(
c.db(ctx).
Model(&relation.ConversationModel{}).
diff --git a/pkg/common/db/relation/friend_model.go b/pkg/common/db/relation/friend_model.go
index 103afd8aa..869254455 100644
--- a/pkg/common/db/relation/friend_model.go
+++ b/pkg/common/db/relation/friend_model.go
@@ -50,7 +50,6 @@ func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserI
Error,
"",
)
-
return err
}
@@ -85,7 +84,6 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
}
m := make(map[string]interface{}, 1)
m["remark"] = ""
-
return utils.Wrap(f.db(ctx).Where("owner_user_id = ?", ownerUserID).Updates(m).Error, "")
}
@@ -95,7 +93,6 @@ func (f *FriendGorm) Take(
ownerUserID, friendUserID string,
) (friend *relation.FriendModel, err error) {
friend = &relation.FriendModel{}
-
return friend, utils.Wrap(
f.db(ctx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error,
"",
@@ -159,7 +156,6 @@ func (f *FriendGorm) FindOwnerFriends(
Error,
"",
)
-
return
}
@@ -182,7 +178,6 @@ func (f *FriendGorm) FindInWhoseFriends(
Error,
"",
)
-
return
}
diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go
index 4fd372c0c..5678f7b7b 100644
--- a/pkg/common/db/relation/friend_request_model.go
+++ b/pkg/common/db/relation/friend_request_model.go
@@ -74,7 +74,6 @@ func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.
fr2 := *friendRequest
fr2.FromUserID = ""
fr2.ToUserID = ""
-
return utils.Wrap(
f.db(ctx).
Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID).
@@ -94,7 +93,6 @@ func (f *FriendRequestGorm) Find(
f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Find(friendRequest).Error,
"",
)
-
return friendRequest, err
}
@@ -107,7 +105,6 @@ func (f *FriendRequestGorm) Take(
f.db(ctx).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Take(friendRequest).Error,
"",
)
-
return friendRequest, err
}
@@ -130,7 +127,6 @@ func (f *FriendRequestGorm) FindToUserID(
Error,
"",
)
-
return
}
@@ -153,7 +149,6 @@ func (f *FriendRequestGorm) FindFromUserID(
Error,
"",
)
-
return
}
@@ -165,6 +160,5 @@ func (f *FriendRequestGorm) FindBothFriendRequests(ctx context.Context, fromUser
Error,
"",
)
-
return
}
diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go
index 48baea61c..312e32054 100644
--- a/pkg/common/db/relation/group_member_model.go
+++ b/pkg/common/db/relation/group_member_model.go
@@ -68,7 +68,6 @@ func (g *GroupMemberGorm) UpdateRoleLevel(
db := g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Updates(map[string]any{
"role_level": roleLevel,
})
-
return db.RowsAffected, utils.Wrap(db.Error, "")
}
@@ -88,7 +87,6 @@ func (g *GroupMemberGorm) Find(
if len(roleLevels) > 0 {
db = db.Where("role_level in (?)", roleLevels)
}
-
return groupMembers, utils.Wrap(db.Find(&groupMembers).Error, "")
}
@@ -98,7 +96,6 @@ func (g *GroupMemberGorm) Take(
userID string,
) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
-
return groupMember, utils.Wrap(
g.db(ctx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error,
"",
@@ -110,7 +107,6 @@ func (g *GroupMemberGorm) TakeOwner(
groupID string,
) (groupMember *relation.GroupMemberModel, err error) {
groupMember = &relation.GroupMemberModel{}
-
return groupMember, utils.Wrap(
g.db(ctx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error,
"",
@@ -129,7 +125,6 @@ func (g *GroupMemberGorm) SearchMember(
ormutil.GormIn(&db, "group_id", groupIDs)
ormutil.GormIn(&db, "user_id", userIDs)
ormutil.GormIn(&db, "role_level", roleLevels)
-
return ormutil.GormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber)
}
@@ -157,7 +152,6 @@ func (g *GroupMemberGorm) FindJoinUserID(
groupUsers[item.GroupID] = append(v, item.UserID)
}
}
-
return groupUsers, nil
}
@@ -188,7 +182,6 @@ func (g *GroupMemberGorm) FindUsersJoinedGroupID(ctx context.Context, userIDs []
result[groupMember.UserID] = append(v, groupMember.GroupID)
}
}
-
return result, nil
}
diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go
index 508a86f5f..7a8eee9f0 100644
--- a/pkg/common/db/relation/group_model.go
+++ b/pkg/common/db/relation/group_model.go
@@ -61,14 +61,12 @@ func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*rela
func (g *GroupGorm) Take(ctx context.Context, groupID string) (group *relation.GroupModel, err error) {
group = &relation.GroupModel{}
-
return group, utils.Wrap(g.DB.Where("group_id = ?", groupID).Take(group).Error, "")
}
func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupModel, err error) {
db := g.DB
db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed)
-
return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber)
}
@@ -84,7 +82,6 @@ func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count in
if err := db.Count(&count).Error; err != nil {
return 0, err
}
-
return count, nil
}
@@ -101,7 +98,6 @@ func (g *GroupGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time
for _, r := range res {
v[r.Date.Format("2006-01-02")] = r.Count
}
-
return v, nil
}
diff --git a/pkg/common/db/relation/group_request_model.go b/pkg/common/db/relation/group_request_model.go
index 691a83bb0..af3f277e8 100644
--- a/pkg/common/db/relation/group_request_model.go
+++ b/pkg/common/db/relation/group_request_model.go
@@ -80,7 +80,6 @@ func (g *GroupRequestGorm) Take(
userID string,
) (groupRequest *relation.GroupRequestModel, err error) {
groupRequest = &relation.GroupRequestModel{}
-
return groupRequest, utils.Wrap(
g.DB.WithContext(ctx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error,
utils.GetSelfFuncName(),
@@ -115,6 +114,5 @@ func (g *GroupRequestGorm) PageGroup(
func (g *GroupRequestGorm) FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (total int64, groupRequests []*relation.GroupRequestModel, err error) {
err = g.DB.WithContext(ctx).Where("group_id = ? and user_id in ?", groupID, userIDs).Find(&groupRequests).Error
-
return int64(len(groupRequests)), groupRequests, utils.Wrap(err, utils.GetSelfFuncName())
}
diff --git a/pkg/common/db/relation/log_model.go b/pkg/common/db/relation/log_model.go
index fc1a82cdb..53365ca5b 100644
--- a/pkg/common/db/relation/log_model.go
+++ b/pkg/common/db/relation/log_model.go
@@ -25,7 +25,6 @@ func (l *LogGorm) Search(ctx context.Context, keyword string, start time.Time, e
db = l.db.WithContext(ctx).Where("create_time <= ?", end)
}
db = db.Order("create_time desc")
-
return ormutil.GormSearch[relationtb.Log](db, []string{"user_id"}, keyword, pageNumber, showNumber)
}
@@ -33,7 +32,6 @@ func (l *LogGorm) Delete(ctx context.Context, logIDs []string, userID string) er
if userID == "" {
return errs.Wrap(l.db.WithContext(ctx).Where("log_id in ?", logIDs).Delete(&relationtb.Log{}).Error)
}
-
return errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Delete(&relationtb.Log{}).Error)
}
@@ -42,15 +40,10 @@ func (l *LogGorm) Get(ctx context.Context, logIDs []string, userID string) ([]*r
if userID == "" {
return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ?", logIDs).Find(&logs).Error)
}
-
return logs, errs.Wrap(l.db.WithContext(ctx).Where("log_id in ? and user_id=?", logIDs, userID).Find(&logs).Error)
}
func NewLogGorm(db *gorm.DB) relationtb.LogInterface {
- err := db.AutoMigrate(&relationtb.Log{})
- if err != nil {
- panic(err)
- }
-
+ db.AutoMigrate(&relationtb.Log{})
return &LogGorm{db: db}
}
diff --git a/pkg/common/db/relation/meta_db.go b/pkg/common/db/relation/meta_db.go
index 00c1b76bc..6ab980120 100644
--- a/pkg/common/db/relation/meta_db.go
+++ b/pkg/common/db/relation/meta_db.go
@@ -34,6 +34,5 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB {
func (g *MetaDB) db(ctx context.Context) *gorm.DB {
db := g.DB.WithContext(ctx).Model(g.table)
-
return db
}
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 550053ea2..0e5ea5e43 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -15,7 +15,6 @@
package relation
import (
- "errors"
"fmt"
"time"
@@ -83,7 +82,6 @@ func newMysqlGormDB() (*gorm.DB, error) {
sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.MaxLifeTime))
sqlDB.SetMaxOpenConns(config.Config.Mysql.MaxOpenConn)
sqlDB.SetMaxIdleConns(config.Config.Mysql.MaxIdleConn)
-
return db, nil
}
@@ -96,13 +94,11 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
if err == nil {
return db, nil
}
- var mysqlErr *mysqldriver.MySQLError
- if errors.As(err, &mysqlErr) && mysqlErr.Number == 1045 {
+ if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok && mysqlErr.Number == 1045 {
return nil, err
}
time.Sleep(time.Duration(1) * time.Second)
}
-
return nil, err
}
@@ -110,7 +106,6 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey)
-
return newMysqlGormDB()
}
@@ -118,15 +113,12 @@ func replaceDuplicateKey(err error) errs.CodeError {
if IsMysqlDuplicateKey(err) {
return errs.ErrDuplicateKey
}
-
return nil
}
func IsMysqlDuplicateKey(err error) bool {
- var mysqlErr *mysqldriver.MySQLError
- if errors.As(err, &mysqlErr) {
+ if mysqlErr, ok := err.(*mysqldriver.MySQLError); ok {
return mysqlErr.Number == 1062
}
-
return false
}
diff --git a/pkg/common/db/relation/object_model.go b/pkg/common/db/relation/object_model.go
index 34b511c6a..c5624a8d4 100644
--- a/pkg/common/db/relation/object_model.go
+++ b/pkg/common/db/relation/object_model.go
@@ -44,12 +44,10 @@ func (o *ObjectInfoGorm) SetObject(ctx context.Context, obj *relation.ObjectMode
if err := o.DB.WithContext(ctx).Where("name = ?", obj.Name).FirstOrCreate(obj).Error; err != nil {
return errs.Wrap(err)
}
-
return nil
}
func (o *ObjectInfoGorm) Take(ctx context.Context, name string) (info *relation.ObjectModel, err error) {
info = &relation.ObjectModel{}
-
return info, errs.Wrap(o.DB.WithContext(ctx).Where("name = ?", name).Take(info).Error)
}
diff --git a/pkg/common/db/relation/user_model.go b/pkg/common/db/relation/user_model.go
index ef605abd9..b04c29816 100644
--- a/pkg/common/db/relation/user_model.go
+++ b/pkg/common/db/relation/user_model.go
@@ -53,7 +53,6 @@ func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err er
// 获取指定用户信息 不存在,也不返回错误.
func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) {
err = utils.Wrap(u.db(ctx).Where("user_id in (?)", userIDs).Find(&users).Error, "")
-
return users, err
}
@@ -61,7 +60,6 @@ func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relatio
func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error) {
user = &relation.UserModel{}
err = utils.Wrap(u.db(ctx).Where("user_id = ?", userID).Take(&user).Error, "")
-
return user, err
}
@@ -83,7 +81,6 @@ func (u *UserGorm) Page(
Error,
"",
)
-
return
}
@@ -91,14 +88,13 @@ func (u *UserGorm) Page(
func (u *UserGorm) GetAllUserID(ctx context.Context, pageNumber, showNumber int32) (userIDs []string, err error) {
if pageNumber == 0 || showNumber == 0 {
return userIDs, errs.Wrap(u.db(ctx).Pluck("user_id", &userIDs).Error)
+ } else {
+ return userIDs, errs.Wrap(u.db(ctx).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Pluck("user_id", &userIDs).Error)
}
-
- return userIDs, errs.Wrap(u.db(ctx).Limit(int(showNumber)).Offset(int((pageNumber-1)*showNumber)).Pluck("user_id", &userIDs).Error)
}
func (u *UserGorm) GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error) {
err = u.db(ctx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Pluck("global_recv_msg_opt", &opt).Error
-
return opt, err
}
@@ -110,7 +106,6 @@ func (u *UserGorm) CountTotal(ctx context.Context, before *time.Time) (count int
if err := db.Count(&count).Error; err != nil {
return 0, err
}
-
return count, nil
}
@@ -137,6 +132,5 @@ func (u *UserGorm) CountRangeEverydayTotal(
for _, r := range res {
v[r.Date.Format("2006-01-02")] = r.Count
}
-
return v, nil
}
diff --git a/pkg/common/db/s3/cont/controller.go b/pkg/common/db/s3/cont/controller.go
index 7ff6fa755..6faa997a9 100644
--- a/pkg/common/db/s3/cont/controller.go
+++ b/pkg/common/db/s3/cont/controller.go
@@ -46,7 +46,6 @@ func (c *Controller) HashPath(md5 string) string {
func (c *Controller) NowPath() string {
now := time.Now()
-
return path.Join(
fmt.Sprintf("%04d", now.Year()),
fmt.Sprintf("%02d", now.Month()),
@@ -59,7 +58,6 @@ func (c *Controller) NowPath() string {
func (c *Controller) UUID() string {
id := uuid.New()
-
return hex.EncodeToString(id[:])
}
@@ -94,24 +92,20 @@ func (c *Controller) InitiateUpload(ctx context.Context, hash string, size int64
partNumber++
}
if maxParts > 0 && partNumber > 0 && partNumber < maxParts {
- return nil, fmt.Errorf("too few parts: %d", partNumber)
+ return nil, errors.New(fmt.Sprintf("too many parts: %d", partNumber))
}
- info, err := c.impl.StatObject(ctx, c.HashPath(hash))
- if err == nil {
+ if info, err := c.impl.StatObject(ctx, c.HashPath(hash)); err == nil {
return nil, &HashAlreadyExistsError{Object: info}
- }
- if !c.impl.IsNotFound(err) {
+ } else if !c.impl.IsNotFound(err) {
return nil, err
}
-
if size <= partSize {
// 预签名上传
key := path.Join(tempPath, c.NowPath(), fmt.Sprintf("%s_%d_%s.presigned", hash, size, c.UUID()))
- rawURL, err2 := c.impl.PresignedPutObject(ctx, key, expire)
- if err2 != nil {
- return nil, err2
+ rawURL, err := c.impl.PresignedPutObject(ctx, key, expire)
+ if err != nil {
+ return nil, err
}
-
return &InitiateUploadResult{
UploadID: newMultipartUploadID(multipartUploadID{
Type: UploadTypePresigned,
@@ -130,39 +124,38 @@ func (c *Controller) InitiateUpload(ctx context.Context, hash string, size int64
},
},
}, nil
- }
-
- // 分片上传
- upload, err := c.impl.InitiateMultipartUpload(ctx, c.HashPath(hash))
- if err != nil {
- return nil, err
- }
- if maxParts < 0 {
- maxParts = partNumber
- }
- var authSign *s3.AuthSignResult
- if maxParts > 0 {
- partNumbers := make([]int, partNumber)
- for i := 0; i < maxParts; i++ {
- partNumbers[i] = i + 1
- }
- authSign, err = c.impl.AuthSign(ctx, upload.UploadID, upload.Key, time.Hour*24, partNumbers)
+ } else {
+ // 分片上传
+ upload, err := c.impl.InitiateMultipartUpload(ctx, c.HashPath(hash))
if err != nil {
return nil, err
}
+ if maxParts < 0 {
+ maxParts = partNumber
+ }
+ var authSign *s3.AuthSignResult
+ if maxParts > 0 {
+ partNumbers := make([]int, partNumber)
+ for i := 0; i < maxParts; i++ {
+ partNumbers[i] = i + 1
+ }
+ authSign, err = c.impl.AuthSign(ctx, upload.UploadID, upload.Key, time.Hour*24, partNumbers)
+ if err != nil {
+ return nil, err
+ }
+ }
+ return &InitiateUploadResult{
+ UploadID: newMultipartUploadID(multipartUploadID{
+ Type: UploadTypeMultipart,
+ ID: upload.UploadID,
+ Key: upload.Key,
+ Size: size,
+ Hash: hash,
+ }),
+ PartSize: partSize,
+ Sign: authSign,
+ }, nil
}
-
- return &InitiateUploadResult{
- UploadID: newMultipartUploadID(multipartUploadID{
- Type: UploadTypeMultipart,
- ID: upload.UploadID,
- Key: upload.Key,
- Size: size,
- Hash: hash,
- }),
- PartSize: partSize,
- Sign: authSign,
- }, nil
}
func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHashs []string) (*UploadResult, error) {
@@ -171,10 +164,8 @@ func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHa
if err != nil {
return nil, err
}
- //nolint:gosec //tofix G401: Use of weak cryptographic primitive
if md5Sum := md5.Sum([]byte(strings.Join(partHashs, partSeparator))); hex.EncodeToString(md5Sum[:]) != upload.Hash {
fmt.Println("CompleteUpload sum:", hex.EncodeToString(md5Sum[:]), "upload hash:", upload.Hash)
-
return nil, errors.New("md5 mismatching")
}
if info, err := c.impl.StatObject(ctx, c.HashPath(upload.Hash)); err == nil {
@@ -202,7 +193,7 @@ func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHa
ETag: part,
}
}
- // todo: verify size
+ // todo: 验证大小
result, err := c.impl.CompleteMultipartUpload(ctx, upload.ID, upload.Key, parts)
if err != nil {
return nil, err
@@ -217,12 +208,11 @@ func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHa
if uploadInfo.Size != upload.Size {
return nil, errors.New("upload size mismatching")
}
- //nolint:gosec //G401: Use of weak cryptographic primitive
md5Sum := md5.Sum([]byte(strings.Join([]string{uploadInfo.ETag}, partSeparator)))
if md5val := hex.EncodeToString(md5Sum[:]); md5val != upload.Hash {
return nil, errs.ErrArgs.Wrap(fmt.Sprintf("md5 mismatching %s != %s", md5val, upload.Hash))
}
- // Prevent concurrent operations at this time to avoid file overwrite
+ // 防止在这个时候,并发操作,导致文件被覆盖
copyInfo, err := c.impl.CopyObject(ctx, uploadInfo.Key, upload.Key+"."+c.UUID())
if err != nil {
return nil, err
@@ -240,7 +230,6 @@ func (c *Controller) CompleteUpload(ctx context.Context, uploadID string, partHa
default:
return nil, errors.New("invalid upload id type")
}
-
return &UploadResult{
Key: targetKey,
Size: upload.Size,
@@ -272,6 +261,5 @@ func (c *Controller) AccessURL(ctx context.Context, name string, expire time.Dur
opt.Filename = ""
opt.ContentType = ""
}
-
return c.impl.AccessURL(ctx, name, expire, opt)
}
diff --git a/pkg/common/db/s3/cont/id.go b/pkg/common/db/s3/cont/id.go
index a2b723b83..47f37d4aa 100644
--- a/pkg/common/db/s3/cont/id.go
+++ b/pkg/common/db/s3/cont/id.go
@@ -33,7 +33,6 @@ func newMultipartUploadID(id multipartUploadID) string {
if err != nil {
panic(err)
}
-
return base64.StdEncoding.EncodeToString(data)
}
@@ -46,6 +45,5 @@ func parseMultipartUploadID(id string) (*multipartUploadID, error) {
if err := json.Unmarshal(data, &upload); err != nil {
return nil, fmt.Errorf("invalid multipart upload id: %w", err)
}
-
return &upload, nil
}
diff --git a/pkg/common/db/s3/cos/cos.go b/pkg/common/db/s3/cos/cos.go
index 5484778a5..7add88487 100644
--- a/pkg/common/db/s3/cos/cos.go
+++ b/pkg/common/db/s3/cos/cos.go
@@ -44,6 +44,11 @@ const (
imageWebp = "webp"
)
+const (
+ videoSnapshotImagePng = "png"
+ videoSnapshotImageJpg = "jpg"
+)
+
func NewCos() (s3.Interface, error) {
conf := config.Config.Object.Cos
u, err := url.Parse(conf.BucketURL)
@@ -57,7 +62,6 @@ func NewCos() (s3.Interface, error) {
SessionToken: conf.SessionToken,
},
})
-
return &Cos{
copyURL: u.Host + "/",
client: client,
@@ -88,7 +92,6 @@ func (c *Cos) InitiateMultipartUpload(ctx context.Context, name string) (*s3.Ini
if err != nil {
return nil, err
}
-
return &s3.InitiateMultipartUploadResult{
UploadID: result.UploadID,
Bucket: result.Bucket,
@@ -110,7 +113,6 @@ func (c *Cos) CompleteMultipartUpload(ctx context.Context, uploadID string, name
if err != nil {
return nil, err
}
-
return &s3.CompleteMultipartUploadResult{
Location: result.Location,
Bucket: result.Bucket,
@@ -133,7 +135,6 @@ func (c *Cos) PartSize(ctx context.Context, size int64) (int64, error) {
if size%maxNumSize != 0 {
partSize++
}
-
return partSize, nil
}
@@ -156,7 +157,6 @@ func (c *Cos) AuthSign(ctx context.Context, uploadID string, name string, expire
Query: url.Values{"partNumber": {strconv.Itoa(partNumber)}},
}
}
-
return &result, nil
}
@@ -165,13 +165,11 @@ func (c *Cos) PresignedPutObject(ctx context.Context, name string, expire time.D
if err != nil {
return "", err
}
-
return rawURL.String(), nil
}
func (c *Cos) DeleteObject(ctx context.Context, name string) error {
_, err := c.client.Object.Delete(ctx, name)
-
return err
}
@@ -187,26 +185,25 @@ func (c *Cos) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, erro
if res.ETag = strings.ToLower(strings.ReplaceAll(info.Header.Get("ETag"), `"`, "")); res.ETag == "" {
return nil, errors.New("StatObject etag not found")
}
- contentLengthStr := info.Header.Get("Content-Length")
- if contentLengthStr == "" {
+ if contentLengthStr := info.Header.Get("Content-Length"); contentLengthStr == "" {
return nil, errors.New("StatObject content-length not found")
+ } else {
+ res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)
+ if err != nil {
+ return nil, fmt.Errorf("StatObject content-length parse error: %w", err)
+ }
+ if res.Size < 0 {
+ return nil, errors.New("StatObject content-length must be greater than 0")
+ }
}
- res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)
- if err != nil {
- return nil, fmt.Errorf("StatObject content-length parse error: %w", err)
- }
- if res.Size < 0 {
- return nil, errors.New("StatObject content-length must be greater than 0")
- }
- lastModified := info.Header.Get("Last-Modified")
- if lastModified == "" {
+ if lastModified := info.Header.Get("Last-Modified"); lastModified == "" {
return nil, errors.New("StatObject last-modified not found")
+ } else {
+ res.LastModified, err = time.Parse(http.TimeFormat, lastModified)
+ if err != nil {
+ return nil, fmt.Errorf("StatObject last-modified parse error: %w", err)
+ }
}
- res.LastModified, err = time.Parse(http.TimeFormat, lastModified)
- if err != nil {
- return nil, fmt.Errorf("StatObject last-modified parse error: %w", err)
- }
-
return res, nil
}
@@ -216,7 +213,6 @@ func (c *Cos) CopyObject(ctx context.Context, src string, dst string) (*s3.CopyO
if err != nil {
return nil, err
}
-
return &s3.CopyObjectInfo{
Key: dst,
ETag: strings.ReplaceAll(result.ETag, `"`, ``),
@@ -224,17 +220,16 @@ func (c *Cos) CopyObject(ctx context.Context, src string, dst string) (*s3.CopyO
}
func (c *Cos) IsNotFound(err error) bool {
- var cosErr *cos.ErrorResponse
- if errors.As(err, &cosErr) {
- return cosErr.Response.StatusCode == http.StatusNotFound || cosErr.Code == "NoSuchKey"
+ switch e := err.(type) {
+ case *cos.ErrorResponse:
+ return e.Response.StatusCode == http.StatusNotFound || e.Code == "NoSuchKey"
+ default:
+ return false
}
-
- return false
}
func (c *Cos) AbortMultipartUpload(ctx context.Context, uploadID string, name string) error {
_, err := c.client.Object.AbortMultipartUpload(ctx, name, uploadID)
-
return err
}
@@ -262,59 +257,46 @@ func (c *Cos) ListUploadedParts(ctx context.Context, uploadID string, name strin
Size: part.Size,
}
}
-
return res, nil
}
func (c *Cos) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
var imageMogr string
var option cos.PresignedURLOptions
- getImageMogr := func(opt *s3.AccessURLOption) (imageMogr string) {
- if opt.Image == nil {
- return imageMogr
- }
- // https://cloud.tencent.com/document/product/436/44880
- style := make([]string, 0, 2)
- wh := make([]string, 2)
- if opt.Image.Width > 0 {
- wh[0] = strconv.Itoa(opt.Image.Width)
- }
- if opt.Image.Height > 0 {
- wh[1] = strconv.Itoa(opt.Image.Height)
- }
- if opt.Image.Width > 0 || opt.Image.Height > 0 {
- style = append(style, strings.Join(wh, "x"))
- }
- switch opt.Image.Format {
- case
- imagePng,
- imageJpg,
- imageJpeg,
- imageGif,
- imageWebp:
- style = append(style, "format/"+opt.Image.Format)
- }
- if len(style) > 0 {
- imageMogr = "imageMogr2/thumbnail/" + strings.Join(style, "/") + "/ignore-error/1"
+ if opt != nil {
+ query := make(url.Values)
+ if opt.Image != nil {
+ // https://cloud.tencent.com/document/product/436/44880
+ style := make([]string, 0, 2)
+ wh := make([]string, 2)
+ if opt.Image.Width > 0 {
+ wh[0] = strconv.Itoa(opt.Image.Width)
+ }
+ if opt.Image.Height > 0 {
+ wh[1] = strconv.Itoa(opt.Image.Height)
+ }
+ if opt.Image.Width > 0 || opt.Image.Height > 0 {
+ style = append(style, strings.Join(wh, "x"))
+ }
+ switch opt.Image.Format {
+ case
+ imagePng,
+ imageJpg,
+ imageJpeg,
+ imageGif,
+ imageWebp:
+ style = append(style, "format/"+opt.Image.Format)
+ }
+ if len(style) > 0 {
+ imageMogr = "imageMogr2/thumbnail/" + strings.Join(style, "/") + "/ignore-error/1"
+ }
}
-
- return imageMogr
- }
- getQuery := func(opt *s3.AccessURLOption) (query url.Values) {
- query = make(url.Values)
if opt.ContentType != "" {
query.Set("response-content-type", opt.ContentType)
}
if opt.Filename != "" {
query.Set("response-content-disposition", `attachment; filename=`+strconv.Quote(opt.Filename))
}
-
- return query
- }
-
- if opt != nil {
- imageMogr = getImageMogr(opt)
- query := getQuery(opt)
if len(query) > 0 {
option.Query = &query
}
@@ -335,7 +317,6 @@ func (c *Cos) AccessURL(ctx context.Context, name string, expire time.Duration,
rawURL.RawQuery = rawURL.RawQuery + "&" + imageMogr
}
}
-
return rawURL.String(), nil
}
@@ -343,6 +324,5 @@ func (c *Cos) getPresignedURL(ctx context.Context, name string, expire time.Dura
if !config.Config.Object.Cos.PublicRead {
return c.client.Object.GetPresignedURL(ctx, http.MethodGet, name, c.credential.SecretID, c.credential.SecretKey, expire, opt)
}
-
return c.client.Object.GetObjectURL(name), nil
}
diff --git a/pkg/common/db/s3/minio/image.go b/pkg/common/db/s3/minio/image.go
index 4812f47ca..71db1ea51 100644
--- a/pkg/common/db/s3/minio/image.go
+++ b/pkg/common/db/s3/minio/image.go
@@ -39,7 +39,6 @@ func ImageStat(reader io.Reader) (image.Image, string, error) {
func ImageWidthHeight(img image.Image) (int, int) {
bounds := img.Bounds().Max
-
return bounds.X, bounds.Y
}
@@ -48,27 +47,27 @@ func resizeImage(img image.Image, maxWidth, maxHeight int) image.Image {
imgWidth := bounds.Max.X
imgHeight := bounds.Max.Y
- // Calculate scaling ratio
+ // 计算缩放比例
scaleWidth := float64(maxWidth) / float64(imgWidth)
scaleHeight := float64(maxHeight) / float64(imgHeight)
- // If both maxWidth and maxHeight are 0, return the original image
+ // 如果都为0,则不缩放,返回原始图片
if maxWidth == 0 && maxHeight == 0 {
return img
}
- // If both maxWidth and maxHeight are greater than 0, choose the smaller scaling ratio to maintain aspect ratio
+ // 如果宽度和高度都大于0,则选择较小的缩放比例,以保持宽高比
if maxWidth > 0 && maxHeight > 0 {
scale := scaleWidth
if scaleHeight < scaleWidth {
scale = scaleHeight
}
- // Calculate thumbnail size
+ // 计算缩略图尺寸
thumbnailWidth := int(float64(imgWidth) * scale)
thumbnailHeight := int(float64(imgHeight) * scale)
- // Generate thumbnail using the Resample method of the "image" library
+ // 使用"image"库的Resample方法生成缩略图
thumbnail := image.NewRGBA(image.Rect(0, 0, thumbnailWidth, thumbnailHeight))
for y := 0; y < thumbnailHeight; y++ {
for x := 0; x < thumbnailWidth; x++ {
@@ -81,12 +80,12 @@ func resizeImage(img image.Image, maxWidth, maxHeight int) image.Image {
return thumbnail
}
- // If only maxWidth or maxHeight is specified, generate thumbnail according to the "max not exceed" rule
+ // 如果只指定了宽度或高度,则根据最大不超过的规则生成缩略图
if maxWidth > 0 {
thumbnailWidth := maxWidth
thumbnailHeight := int(float64(imgHeight) * scaleWidth)
- // Generate thumbnail using the Resample method of the "image" library
+ // 使用"image"库的Resample方法生成缩略图
thumbnail := image.NewRGBA(image.Rect(0, 0, thumbnailWidth, thumbnailHeight))
for y := 0; y < thumbnailHeight; y++ {
for x := 0; x < thumbnailWidth; x++ {
@@ -103,7 +102,7 @@ func resizeImage(img image.Image, maxWidth, maxHeight int) image.Image {
thumbnailWidth := int(float64(imgWidth) * scaleHeight)
thumbnailHeight := maxHeight
- // Generate thumbnail using the Resample method of the "image" library
+ // 使用"image"库的Resample方法生成缩略图
thumbnail := image.NewRGBA(image.Rect(0, 0, thumbnailWidth, thumbnailHeight))
for y := 0; y < thumbnailHeight; y++ {
for x := 0; x < thumbnailWidth; x++ {
@@ -116,6 +115,6 @@ func resizeImage(img image.Image, maxWidth, maxHeight int) image.Image {
return thumbnail
}
- // By default, return the original image
+ // 默认情况下,返回原始图片
return img
}
diff --git a/pkg/common/db/s3/minio/minio.go b/pkg/common/db/s3/minio/minio.go
index 78ed381d5..7984df5a0 100644
--- a/pkg/common/db/s3/minio/minio.go
+++ b/pkg/common/db/s3/minio/minio.go
@@ -111,7 +111,6 @@ func NewMinio() (s3.Interface, error) {
if err := m.initMinio(ctx); err != nil {
fmt.Println("init minio error:", err)
}
-
return m, nil
}
@@ -142,9 +141,8 @@ func (m *Minio) initMinio(ctx context.Context) error {
return fmt.Errorf("check bucket exists error: %w", err)
}
if !exists {
- err2 := m.core.Client.MakeBucket(ctx, conf.Bucket, minio.MakeBucketOptions{})
- if err2 != nil {
- return fmt.Errorf("make bucket error: %w", err2)
+ if err := m.core.Client.MakeBucket(ctx, conf.Bucket, minio.MakeBucketOptions{}); err != nil {
+ return fmt.Errorf("make bucket error: %w", err)
}
}
if conf.PublicRead {
@@ -152,9 +150,8 @@ func (m *Minio) initMinio(ctx context.Context) error {
`{"Version": "2012-10-17","Statement": [{"Action": ["s3:GetObject","s3:PutObject"],"Effect": "Allow","Principal": {"AWS": ["*"]},"Resource": ["arn:aws:s3:::%s/*"],"Sid": ""}]}`,
conf.Bucket,
)
- err2 := m.core.Client.SetBucketPolicy(ctx, conf.Bucket, policy)
- if err2 != nil {
- return err2
+ if err := m.core.Client.SetBucketPolicy(ctx, conf.Bucket, policy); err != nil {
+ return err
}
}
m.location, err = m.core.Client.GetBucketLocation(ctx, conf.Bucket)
@@ -185,7 +182,6 @@ func (m *Minio) initMinio(ctx context.Context) error {
vblc.Elem().Elem().Interface().(interface{ Set(string, string) }).Set(conf.Bucket, m.location)
}()
m.init = true
-
return nil
}
@@ -209,7 +205,6 @@ func (m *Minio) InitiateMultipartUpload(ctx context.Context, name string) (*s3.I
if err != nil {
return nil, err
}
-
return &s3.InitiateMultipartUploadResult{
Bucket: m.bucket,
Key: name,
@@ -232,7 +227,6 @@ func (m *Minio) CompleteMultipartUpload(ctx context.Context, uploadID string, na
if err != nil {
return nil, err
}
-
return &s3.CompleteMultipartUploadResult{
Location: upload.Location,
Bucket: upload.Bucket,
@@ -255,7 +249,6 @@ func (m *Minio) PartSize(ctx context.Context, size int64) (int64, error) {
if size%maxNumSize != 0 {
partSize++
}
-
return partSize, nil
}
@@ -289,7 +282,6 @@ func (m *Minio) AuthSign(ctx context.Context, uploadID string, name string, expi
if m.prefix != "" {
result.URL = m.signEndpoint + m.prefix + "/" + m.bucket + "/" + name
}
-
return &result, nil
}
@@ -304,7 +296,6 @@ func (m *Minio) PresignedPutObject(ctx context.Context, name string, expire time
if m.prefix != "" {
rawURL.Path = path.Join(m.prefix, rawURL.Path)
}
-
return rawURL.String(), nil
}
@@ -312,7 +303,6 @@ func (m *Minio) DeleteObject(ctx context.Context, name string) error {
if err := m.initMinio(ctx); err != nil {
return err
}
-
return m.core.Client.RemoveObject(ctx, m.bucket, name, minio.RemoveObjectOptions{})
}
@@ -324,7 +314,6 @@ func (m *Minio) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, er
if err != nil {
return nil, err
}
-
return &s3.ObjectInfo{
ETag: strings.ToLower(info.ETag),
Key: info.Key,
@@ -347,7 +336,6 @@ func (m *Minio) CopyObject(ctx context.Context, src string, dst string) (*s3.Cop
if err != nil {
return nil, err
}
-
return &s3.CopyObjectInfo{
Key: dst,
ETag: strings.ToLower(result.ETag),
@@ -358,23 +346,20 @@ func (m *Minio) IsNotFound(err error) bool {
if err == nil {
return false
}
- var minioErr minio.ErrorResponse
- if errors.As(err, &minio.ErrorResponse{}) {
- return minioErr.StatusCode == http.StatusNotFound || minioErr.Code == "NoSuchKey"
- }
- var minioErr2 *minio.ErrorResponse
- if errors.As(err, &minioErr2) {
- return minioErr2.StatusCode == http.StatusNotFound || minioErr2.Code == "NoSuchKey"
+ switch e := err.(type) {
+ case minio.ErrorResponse:
+ return e.StatusCode == http.StatusNotFound || e.Code == "NoSuchKey"
+ case *minio.ErrorResponse:
+ return e.StatusCode == http.StatusNotFound || e.Code == "NoSuchKey"
+ default:
+ return false
}
-
- return false
}
func (m *Minio) AbortMultipartUpload(ctx context.Context, uploadID string, name string) error {
if err := m.initMinio(ctx); err != nil {
return err
}
-
return m.core.AbortMultipartUpload(ctx, m.bucket, name, uploadID)
}
@@ -401,7 +386,6 @@ func (m *Minio) ListUploadedParts(ctx context.Context, uploadID string, name str
Size: part.Size,
}
}
-
return res, nil
}
@@ -426,17 +410,14 @@ func (m *Minio) presignedGetObject(ctx context.Context, name string, expire time
if m.prefix != "" {
rawURL.Path = path.Join(m.prefix, rawURL.Path)
}
-
return rawURL.String(), nil
}
-func (m *Minio) getImageInfoForAccessURL(
- ctx context.Context,
- name string,
- expire time.Duration,
- opt *s3.AccessURLOption,
- reqParams url.Values,
-) (fileInfo *s3.ObjectInfo, objectInfoPath, msg string, err error) {
+func (m *Minio) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
+ if err := m.initMinio(ctx); err != nil {
+ return "", err
+ }
+ reqParams := make(url.Values)
if opt != nil {
if opt.ContentType != "" {
reqParams.Set("response-content-type", opt.ContentType)
@@ -446,47 +427,35 @@ func (m *Minio) getImageInfoForAccessURL(
}
}
if opt.Image == nil || (opt.Image.Width < 0 && opt.Image.Height < 0 && opt.Image.Format == "") || (opt.Image.Width > maxImageWidth || opt.Image.Height > maxImageHeight) {
- msg, err = m.presignedGetObject(ctx, name, expire, reqParams)
-
- return nil, "", msg, err
+ return m.presignedGetObject(ctx, name, expire, reqParams)
}
- fileInfo, err = m.StatObject(ctx, name)
- objectInfoPath = path.Join(pathInfo, fileInfo.ETag, "image.json")
+ fileInfo, err := m.StatObject(ctx, name)
if err != nil {
- return nil, "", msg, err
+ return "", err
}
if fileInfo.Size > maxImageSize {
- return nil, "", "", errors.New("file size too large")
+ return "", errors.New("file size too large")
}
-
- return fileInfo, objectInfoPath, "", nil
-}
-
-func (m *Minio) loadImgDataForAccessURL(objectInfoPath string, ctx context.Context, name string, info *minioImageInfo) (img image.Image, msg string, err error) {
- var data []byte
- data, err = m.getObjectData(ctx, objectInfoPath, 1024)
-
- //nolint:nestif //easy enough to understand
+ objectInfoPath := path.Join(pathInfo, fileInfo.ETag, "image.json")
+ var (
+ img image.Image
+ info minioImageInfo
+ )
+ data, err := m.getObjectData(ctx, objectInfoPath, 1024)
if err == nil {
- err = json.Unmarshal(data, &info)
- if err != nil {
- return nil, "", fmt.Errorf("unmarshal minio image info.json error: %w", err)
+ if err := json.Unmarshal(data, &info); err != nil {
+ return "", fmt.Errorf("unmarshal minio image info.json error: %w", err)
}
if info.NotImage {
- return nil, "", errors.New("not image")
+ return "", errors.New("not image")
}
} else if m.IsNotFound(err) {
- var reader *minio.Object
- reader, err = m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{})
+ reader, err := m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{})
if err != nil {
- return img, msg, err
+ return "", err
}
defer reader.Close()
- var (
- imageInfo image.Image
- format string
- )
- imageInfo, format, err = ImageStat(reader)
+ imageInfo, format, err := ImageStat(reader)
if err == nil {
info.NotImage = false
info.Format = format
@@ -495,22 +464,16 @@ func (m *Minio) loadImgDataForAccessURL(objectInfoPath string, ctx context.Conte
} else {
info.NotImage = true
}
-
- data, err = json.Marshal(&info)
+ data, err := json.Marshal(&info)
if err != nil {
- return img, msg, err
+ return "", err
}
-
- _, err = m.core.Client.PutObject(ctx, m.bucket, objectInfoPath, bytes.NewReader(data), int64(len(data)), minio.PutObjectOptions{})
- if err != nil {
- return img, msg, err
+ if _, err := m.core.Client.PutObject(ctx, m.bucket, objectInfoPath, bytes.NewReader(data), int64(len(data)), minio.PutObjectOptions{}); err != nil {
+ return "", err
}
+ } else {
+ return "", err
}
-
- return img, msg, err
-}
-
-func (m *Minio) formatImgInfoForAccessURL(opt *s3.AccessURLOption, info *minioImageInfo, reqParams url.Values) {
if opt.Image.Width > info.Width || opt.Image.Width <= 0 {
opt.Image.Width = info.Width
}
@@ -533,24 +496,24 @@ func (m *Minio) formatImgInfoForAccessURL(opt *s3.AccessURLOption, info *minioIm
}
}
reqParams.Set("response-content-type", "image/"+opt.Image.Format)
-}
-
-func (m *Minio) cacheImgInfoForAccessURL(ctx context.Context, name, cacheKey string, img image.Image, expire time.Duration, opt *s3.AccessURLOption, reqParams url.Values) (string, error) {
- _, err := m.core.Client.StatObject(ctx, m.bucket, cacheKey, minio.StatObjectOptions{})
- if err == nil {
+ if opt.Image.Width == info.Width && opt.Image.Height == info.Height && opt.Image.Format == info.Format {
+ return m.presignedGetObject(ctx, name, expire, reqParams)
+ }
+ cacheKey := filepath.Join(pathInfo, fileInfo.ETag, fmt.Sprintf("image_w%d_h%d.%s", opt.Image.Width, opt.Image.Height, opt.Image.Format))
+ if _, err := m.core.Client.StatObject(ctx, m.bucket, cacheKey, minio.StatObjectOptions{}); err == nil {
return m.presignedGetObject(ctx, cacheKey, expire, reqParams)
} else if !m.IsNotFound(err) {
return "", err
}
if img == nil {
- reader, err2 := m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{})
- if err2 != nil {
- return "", err2
+ reader, err := m.core.Client.GetObject(ctx, m.bucket, name, minio.GetObjectOptions{})
+ if err != nil {
+ return "", err
}
defer reader.Close()
- img, _, err2 = ImageStat(reader)
- if err2 != nil {
- return "", err2
+ img, _, err = ImageStat(reader)
+ if err != nil {
+ return "", err
}
}
thumbnail := resizeImage(img, opt.Image.Width, opt.Image.Height)
@@ -563,48 +526,9 @@ func (m *Minio) cacheImgInfoForAccessURL(ctx context.Context, name, cacheKey str
case formatGif:
err = gif.Encode(buf, thumbnail, nil)
}
- if err != nil {
- return "", err
- }
if _, err := m.core.Client.PutObject(ctx, m.bucket, cacheKey, buf, int64(buf.Len()), minio.PutObjectOptions{}); err != nil {
return "", err
}
-
- return "", nil
-}
-
-func (m *Minio) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
- errInit := m.initMinio(ctx)
- if errInit != nil {
- return "", errInit
- }
- reqParams := make(url.Values)
- fileInfo, objectInfoPath, msg, err := m.getImageInfoForAccessURL(ctx, name, expire, opt, reqParams)
- if err != nil {
- return msg, err
- }
- // load-cache img data
- var (
- img image.Image
- info minioImageInfo
- )
- img, msg, err = m.loadImgDataForAccessURL(objectInfoPath, ctx, name, &info)
- if err != nil {
- return msg, err
- }
- // format img info
- m.formatImgInfoForAccessURL(opt, &info, reqParams)
- // no need resize
- if opt.Image.Width == info.Width && opt.Image.Height == info.Height && opt.Image.Format == info.Format {
- return m.presignedGetObject(ctx, name, expire, reqParams)
- }
- // cache img
- cacheKey := filepath.Join(pathInfo, fileInfo.ETag, fmt.Sprintf("image_w%d_h%d.%s", opt.Image.Width, opt.Image.Height, opt.Image.Format))
- msg, err = m.cacheImgInfoForAccessURL(ctx, name, cacheKey, img, expire, opt, reqParams)
- if err != nil {
- return msg, err
- }
- // return cache img
return m.presignedGetObject(ctx, cacheKey, expire, reqParams)
}
@@ -617,6 +541,5 @@ func (m *Minio) getObjectData(ctx context.Context, name string, limit int64) ([]
if limit < 0 {
return io.ReadAll(object)
}
-
return io.ReadAll(io.LimitReader(object, 1024))
}
diff --git a/pkg/common/db/s3/oss/oss.go b/pkg/common/db/s3/oss/oss.go
index 4f7f37497..6a728127b 100755
--- a/pkg/common/db/s3/oss/oss.go
+++ b/pkg/common/db/s3/oss/oss.go
@@ -45,6 +45,11 @@ const (
imageWebp = "webp"
)
+const (
+ videoSnapshotImagePng = "png"
+ videoSnapshotImageJpg = "jpg"
+)
+
func NewOSS() (s3.Interface, error) {
conf := config.Config.Object.Oss
if conf.BucketURL == "" {
@@ -61,7 +66,6 @@ func NewOSS() (s3.Interface, error) {
if conf.BucketURL[len(conf.BucketURL)-1] != '/' {
conf.BucketURL += "/"
}
-
return &OSS{
bucketURL: conf.BucketURL,
bucket: bucket,
@@ -94,7 +98,6 @@ func (o *OSS) InitiateMultipartUpload(ctx context.Context, name string) (*s3.Ini
if err != nil {
return nil, err
}
-
return &s3.InitiateMultipartUploadResult{
UploadID: result.UploadID,
Bucket: result.Bucket,
@@ -118,7 +121,6 @@ func (o *OSS) CompleteMultipartUpload(ctx context.Context, uploadID string, name
if err != nil {
return nil, err
}
-
return &s3.CompleteMultipartUploadResult{
Location: result.Location,
Bucket: result.Bucket,
@@ -141,7 +143,6 @@ func (o *OSS) PartSize(ctx context.Context, size int64) (int64, error) {
if size%maxNumSize != 0 {
partSize++
}
-
return partSize, nil
}
@@ -154,7 +155,7 @@ func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire
}
for i, partNumber := range partNumbers {
rawURL := fmt.Sprintf(`%s%s?partNumber=%d&uploadId=%s`, o.bucketURL, name, partNumber, uploadID)
- request, err := http.NewRequestWithContext(context.Background(), http.MethodPut, rawURL, nil)
+ request, err := http.NewRequest(http.MethodPut, rawURL, nil)
if err != nil {
return nil, err
}
@@ -174,7 +175,6 @@ func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire
Header: request.Header,
}
}
-
return &result, nil
}
@@ -191,26 +191,25 @@ func (o *OSS) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, erro
if res.ETag = strings.ToLower(strings.ReplaceAll(header.Get("ETag"), `"`, ``)); res.ETag == "" {
return nil, errors.New("StatObject etag not found")
}
- contentLengthStr := header.Get("Content-Length")
- if contentLengthStr == "" {
+ if contentLengthStr := header.Get("Content-Length"); contentLengthStr == "" {
return nil, errors.New("StatObject content-length not found")
+ } else {
+ res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)
+ if err != nil {
+ return nil, fmt.Errorf("StatObject content-length parse error: %w", err)
+ }
+ if res.Size < 0 {
+ return nil, errors.New("StatObject content-length must be greater than 0")
+ }
}
- res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)
- if err != nil {
- return nil, fmt.Errorf("StatObject content-length parse error: %w", err)
- }
- if res.Size < 0 {
- return nil, errors.New("StatObject content-length must be greater than 0")
- }
- lastModified := header.Get("Last-Modified")
- if lastModified == "" {
+ if lastModified := header.Get("Last-Modified"); lastModified == "" {
return nil, errors.New("StatObject last-modified not found")
+ } else {
+ res.LastModified, err = time.Parse(http.TimeFormat, lastModified)
+ if err != nil {
+ return nil, fmt.Errorf("StatObject last-modified parse error: %w", err)
+ }
}
- res.LastModified, err = time.Parse(http.TimeFormat, lastModified)
- if err != nil {
- return nil, fmt.Errorf("StatObject last-modified parse error: %w", err)
- }
-
return res, nil
}
@@ -223,7 +222,6 @@ func (o *OSS) CopyObject(ctx context.Context, src string, dst string) (*s3.CopyO
if err != nil {
return nil, err
}
-
return &s3.CopyObjectInfo{
Key: dst,
ETag: strings.ToLower(strings.ReplaceAll(result.ETag, `"`, ``)),
@@ -231,7 +229,6 @@ func (o *OSS) CopyObject(ctx context.Context, src string, dst string) (*s3.CopyO
}
func (o *OSS) IsNotFound(err error) bool {
- //nolint:errorlint //this is exactly what we want,there is no risk for no wrapped errors
switch e := err.(type) {
case oss.ServiceError:
return e.StatusCode == http.StatusNotFound || e.Code == "NoSuchKey"
@@ -274,7 +271,6 @@ func (o *OSS) ListUploadedParts(ctx context.Context, uploadID string, name strin
Size: int64(part.Size),
}
}
-
return res, nil
}
@@ -282,7 +278,39 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration,
publicRead := config.Config.Object.Oss.PublicRead
var opts []oss.Option
if opt != nil {
- opts = optsForAccessURL(opt, opts, publicRead)
+ if opt.Image != nil {
+ // 文档地址: https://help.aliyun.com/zh/oss/user-guide/resize-images-4?spm=a2c4g.11186623.0.0.4b3b1e4fWW6yji
+ var format string
+ switch opt.Image.Format {
+ case
+ imagePng,
+ imageJpg,
+ imageJpeg,
+ imageGif,
+ imageWebp:
+ format = opt.Image.Format
+ default:
+ opt.Image.Format = imageJpg
+ }
+ // https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,h_100,m_lfit
+ process := "image/resize,m_lfit"
+ if opt.Image.Width > 0 {
+ process += ",w_" + strconv.Itoa(opt.Image.Width)
+ }
+ if opt.Image.Height > 0 {
+ process += ",h_" + strconv.Itoa(opt.Image.Height)
+ }
+ process += ",format," + format
+ opts = append(opts, oss.Process(process))
+ }
+ if !publicRead {
+ if opt.ContentType != "" {
+ opts = append(opts, oss.ResponseContentType(opt.ContentType))
+ }
+ if opt.Filename != "" {
+ opts = append(opts, oss.ResponseContentDisposition(`attachment; filename=`+strconv.Quote(opt.Filename)))
+ }
+ }
}
if expire <= 0 {
expire = time.Hour * 24 * 365 * 99 // 99 years
@@ -297,44 +325,5 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration,
return "", err
}
params := getURLParams(*o.bucket.Client.Conn, rawParams)
-
return getURL(o.um, o.bucket.BucketName, name, params).String(), nil
}
-
-func optsForAccessURL(opt *s3.AccessURLOption, opts []oss.Option, publicRead bool) []oss.Option {
- if opt.Image != nil {
- // 文档地址: https://help.aliyun.com/zh/oss/user-guide/resize-images-4?spm=a2c4g.11186623.0.0.4b3b1e4fWW6yji
- var format string
- switch opt.Image.Format {
- case
- imagePng,
- imageJpg,
- imageJpeg,
- imageGif,
- imageWebp:
- format = opt.Image.Format
- default:
- opt.Image.Format = imageJpg
- }
- // https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=image/resize,h_100,m_lfit
- process := "image/resize,m_lfit"
- if opt.Image.Width > 0 {
- process += ",w_" + strconv.Itoa(opt.Image.Width)
- }
- if opt.Image.Height > 0 {
- process += ",h_" + strconv.Itoa(opt.Image.Height)
- }
- process += ",format," + format
- opts = append(opts, oss.Process(process))
- }
- if !publicRead {
- if opt.ContentType != "" {
- opts = append(opts, oss.ResponseContentType(opt.ContentType))
- }
- if opt.Filename != "" {
- opts = append(opts, oss.ResponseContentDisposition(`attachment; filename=`+strconv.Quote(opt.Filename)))
- }
- }
-
- return opts
-}
diff --git a/pkg/common/db/table/relation/group.go b/pkg/common/db/table/relation/group.go
index 309114ee2..6759e0d35 100644
--- a/pkg/common/db/table/relation/group.go
+++ b/pkg/common/db/table/relation/group.go
@@ -30,7 +30,7 @@ type GroupModel struct {
Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
- Ex string `gorm:"column:ex;size:1024" json:"ex"`
+ Ex string `gorm:"column:ex" json:"ex;size:1024"`
Status int32 `gorm:"column:status"`
CreatorUserID string `gorm:"column:creator_user_id;size:64"`
GroupType int32 `gorm:"column:group_type"`
diff --git a/pkg/common/db/table/relation/utils.go b/pkg/common/db/table/relation/utils.go
index bc2639e1a..c944eae8b 100644
--- a/pkg/common/db/table/relation/utils.go
+++ b/pkg/common/db/table/relation/utils.go
@@ -15,8 +15,6 @@
package relation
import (
- "errors"
-
"gorm.io/gorm"
"github.com/OpenIMSDK/tools/utils"
@@ -34,5 +32,5 @@ type GroupSimpleUserID struct {
}
func IsNotFound(err error) bool {
- return errors.Is(utils.Unwrap(err), gorm.ErrRecordNotFound)
+ return utils.Unwrap(err) == gorm.ErrRecordNotFound
}
diff --git a/pkg/common/db/table/unrelation/msg.go b/pkg/common/db/table/unrelation/msg.go
index 542f318ad..c95b211a8 100644
--- a/pkg/common/db/table/unrelation/msg.go
+++ b/pkg/common/db/table/unrelation/msg.go
@@ -150,7 +150,6 @@ func (m *MsgDocModel) IsFull() bool {
func (m MsgDocModel) GetDocID(conversationID string, seq int64) string {
seqSuffix := (seq - 1) / singleGocMsgNum
-
return m.indexGen(conversationID, seqSuffix)
}
@@ -165,7 +164,6 @@ func (m MsgDocModel) GetDocIDSeqsMap(conversationID string, seqs []int64) map[st
t[docID] = append(value, seqs[i])
}
}
-
return t
}
@@ -183,6 +181,5 @@ func (MsgDocModel) GenExceptionMessageBySeqs(seqs []int64) (exceptionMsg []*sdkw
msgModel.Seq = v
exceptionMsg = append(exceptionMsg, msgModel)
}
-
return exceptionMsg
}
diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go
index 8a90a2a2c..09e3e904e 100755
--- a/pkg/common/db/unrelation/mongo.go
+++ b/pkg/common/db/unrelation/mongo.go
@@ -16,7 +16,6 @@ package unrelation
import (
"context"
- "errors"
"fmt"
"strings"
"time"
@@ -45,12 +44,27 @@ type Mongo struct {
// NewMongo Initialize MongoDB connection.
func NewMongo() (*Mongo, error) {
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
- // uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
- var uri string
+ uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
if config.Config.Mongo.Uri != "" {
uri = config.Config.Mongo.Uri
} else {
- uri = defaultMongoUriForNewMongo()
+ mongodbHosts := ""
+ for i, v := range config.Config.Mongo.Address {
+ if i == len(config.Config.Mongo.Address)-1 {
+ mongodbHosts += v
+ } else {
+ mongodbHosts += v + ","
+ }
+ }
+ if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" {
+ uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
+ config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts,
+ config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize)
+ } else {
+ uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin",
+ mongodbHosts, config.Config.Mongo.Database,
+ config.Config.Mongo.MaxPoolSize)
+ }
}
fmt.Println("mongo:", uri)
var mongoClient *mongo.Client
@@ -62,41 +76,17 @@ func NewMongo() (*Mongo, error) {
if err == nil {
return &Mongo{db: mongoClient}, nil
}
- var cmdErr mongo.CommandError
- if errors.As(err, &cmdErr) {
+ if cmdErr, ok := err.(mongo.CommandError); ok {
if cmdErr.Code == 13 || cmdErr.Code == 18 {
return nil, err
+ } else {
+ fmt.Printf("Failed to connect to MongoDB: %s\n", err)
}
- fmt.Printf("Failed to connect to MongoDB: %s\n", err)
}
}
-
return nil, err
}
-func defaultMongoUriForNewMongo() string {
- var uri string
- mongodbHosts := ""
- for i, v := range config.Config.Mongo.Address {
- if i == len(config.Config.Mongo.Address)-1 {
- mongodbHosts += v
- } else {
- mongodbHosts += v + ","
- }
- }
- if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" {
- uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
- config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts,
- config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize)
- } else {
- uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin",
- mongodbHosts, config.Config.Mongo.Database,
- config.Config.Mongo.MaxPoolSize)
- }
-
- return uri
-}
-
func (m *Mongo) GetClient() *mongo.Client {
return m.db
}
@@ -116,7 +106,6 @@ func (m *Mongo) CreateSuperGroupIndex() error {
if err := m.createMongoIndex(unrelation.CUserToSuperGroup, true, "user_id"); err != nil {
return err
}
-
return nil
}
@@ -150,6 +139,5 @@ func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...strin
if err != nil {
return utils.Wrap(err, result)
}
-
return nil
}
diff --git a/pkg/common/db/unrelation/msg.go b/pkg/common/db/unrelation/msg.go
index afa2f81e4..9b461dd1f 100755
--- a/pkg/common/db/unrelation/msg.go
+++ b/pkg/common/db/unrelation/msg.go
@@ -49,7 +49,6 @@ type MsgMongoDriver struct {
func NewMsgMongoDriver(database *mongo.Database) table.MsgDocModelInterface {
collection := database.Collection(table.MsgDocModel{}.TableName())
-
return &MsgMongoDriver{MsgCollection: collection}
}
@@ -60,7 +59,6 @@ func (m *MsgMongoDriver) PushMsgsToDoc(ctx context.Context, docID string, msgsTo
func (m *MsgMongoDriver) Create(ctx context.Context, model *table.MsgDocModel) error {
_, err := m.MsgCollection.InsertOne(ctx, model)
-
return err
}
@@ -83,7 +81,6 @@ func (m *MsgMongoDriver) UpdateMsg(
if err != nil {
return nil, utils.Wrap(err, "")
}
-
return res, nil
}
@@ -111,7 +108,6 @@ func (m *MsgMongoDriver) PushUnique(
if err != nil {
return nil, utils.Wrap(err, "")
}
-
return res, nil
}
@@ -124,7 +120,6 @@ func (m *MsgMongoDriver) UpdateMsgContent(ctx context.Context, docID string, ind
if err != nil {
return utils.Wrap(err, "")
}
-
return nil
}
@@ -148,14 +143,12 @@ func (m *MsgMongoDriver) UpdateMsgStatusByIndexInOneDoc(
if err != nil {
return utils.Wrap(err, "")
}
-
return nil
}
func (m *MsgMongoDriver) FindOneByDocID(ctx context.Context, docID string) (*table.MsgDocModel, error) {
doc := &table.MsgDocModel{}
err := m.MsgCollection.FindOne(ctx, bson.M{"doc_id": docID}).Decode(doc)
-
return doc, err
}
@@ -184,7 +177,6 @@ func (m *MsgMongoDriver) GetMsgDocModelByIndex(
if len(msgs) > 0 {
return &msgs[0], nil
}
-
return nil, ErrMsgListNotExist
}
@@ -233,7 +225,6 @@ func (m *MsgMongoDriver) DeleteMsgsInOneDocByIndex(ctx context.Context, docID st
if err != nil {
return utils.Wrap(err, "")
}
-
return nil
}
@@ -242,7 +233,6 @@ func (m *MsgMongoDriver) DeleteDocs(ctx context.Context, docIDs []string) error
return nil
}
_, err := m.MsgCollection.DeleteMany(ctx, bson.M{"doc_id": bson.M{"$in": docIDs}})
-
return err
}
@@ -256,7 +246,6 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(
for _, seq := range seqs {
indexs = append(indexs, m.model.GetMsgIndex(seq))
}
- //nolint:govet //This is already the officially recommended standard practice.
pipeline := mongo.Pipeline{
{
{"$match", bson.D{
@@ -347,7 +336,6 @@ func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(
}
msgs = append(msgs, msg)
}
-
return msgs, nil
}
@@ -356,7 +344,6 @@ func (m *MsgMongoDriver) IsExistDocID(ctx context.Context, docID string) (bool,
if err != nil {
return false, errs.Wrap(err)
}
-
return count > 0, nil
}
@@ -385,7 +372,6 @@ func (m *MsgMongoDriver) MarkSingleChatMsgsAsRead(
updates = append(updates, updateModel)
}
_, err := m.MsgCollection.BulkWrite(ctx, updates)
-
return err
}
@@ -625,39 +611,7 @@ func (m *MsgMongoDriver) RangeUserSendCount(
},
)
}
- pipeline := buildPiplineForRangeUserSendCount(or, start, end, sort, pageNumber, showNumber)
- cur, err := m.MsgCollection.Aggregate(ctx, pipeline, options.Aggregate().SetAllowDiskUse(true))
- if err != nil {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- defer cur.Close(ctx)
- var result []Result
- if err = cur.All(ctx, &result); err != nil {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- if len(result) == 0 {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- users = make([]*table.UserCount, len(result[0].Users))
- for i, r := range result[0].Users {
- users[i] = &table.UserCount{
- UserID: r.UserID,
- Count: r.Count,
- }
- }
- dateCount = make(map[string]int64)
- for _, r := range result[0].Dates {
- dateCount[r.Date] = r.Count
- }
-
- return result[0].MsgCount, result[0].UserCount, users, dateCount, nil
-}
-
-//nolint:funlen // it need to be such long
-func buildPiplineForRangeUserSendCount(or bson.A, start time.Time,
- end time.Time, sort int, pageNumber, showNumber int32,
-) bson.A {
- return bson.A{
+ pipeline := bson.A{
bson.M{
"$match": bson.M{
"$and": bson.A{
@@ -841,6 +795,30 @@ func buildPiplineForRangeUserSendCount(or bson.A, start time.Time,
},
},
}
+ cur, err := m.MsgCollection.Aggregate(ctx, pipeline, options.Aggregate().SetAllowDiskUse(true))
+ if err != nil {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ defer cur.Close(ctx)
+ var result []Result
+ if err := cur.All(ctx, &result); err != nil {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ if len(result) == 0 {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ users = make([]*table.UserCount, len(result[0].Users))
+ for i, r := range result[0].Users {
+ users[i] = &table.UserCount{
+ UserID: r.UserID,
+ Count: r.Count,
+ }
+ }
+ dateCount = make(map[string]int64)
+ for _, r := range result[0].Dates {
+ dateCount[r.Date] = r.Count
+ }
+ return result[0].MsgCount, result[0].UserCount, users, dateCount, nil
}
func (m *MsgMongoDriver) RangeGroupSendCount(
@@ -869,39 +847,7 @@ func (m *MsgMongoDriver) RangeGroupSendCount(
Count int64 `bson:"count"`
} `bson:"dates"`
}
- pipeline := buildPiplineForRangeGroupSendCount(start, end, sort, pageNumber, showNumber)
- cur, err := m.MsgCollection.Aggregate(ctx, pipeline, options.Aggregate().SetAllowDiskUse(true))
- if err != nil {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- defer cur.Close(ctx)
- var result []Result
- if err = cur.All(ctx, &result); err != nil {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- if len(result) == 0 {
- return 0, 0, nil, nil, errs.Wrap(err)
- }
- groups = make([]*table.GroupCount, len(result[0].Groups))
- for i, r := range result[0].Groups {
- groups[i] = &table.GroupCount{
- GroupID: r.GroupID,
- Count: r.Count,
- }
- }
- dateCount = make(map[string]int64)
- for _, r := range result[0].Dates {
- dateCount[r.Date] = r.Count
- }
-
- return result[0].MsgCount, result[0].UserCount, groups, dateCount, nil
-}
-
-//nolint:funlen //it need to has such length
-func buildPiplineForRangeGroupSendCount(start time.Time,
- end time.Time, sort int, pageNumber, showNumber int32,
-) bson.A {
- return bson.A{
+ pipeline := bson.A{
bson.M{
"$match": bson.M{
"$and": bson.A{
@@ -1098,6 +1044,30 @@ func buildPiplineForRangeGroupSendCount(start time.Time,
},
},
}
+ cur, err := m.MsgCollection.Aggregate(ctx, pipeline, options.Aggregate().SetAllowDiskUse(true))
+ if err != nil {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ defer cur.Close(ctx)
+ var result []Result
+ if err := cur.All(ctx, &result); err != nil {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ if len(result) == 0 {
+ return 0, 0, nil, nil, errs.Wrap(err)
+ }
+ groups = make([]*table.GroupCount, len(result[0].Groups))
+ for i, r := range result[0].Groups {
+ groups[i] = &table.GroupCount{
+ GroupID: r.GroupID,
+ Count: r.Count,
+ }
+ }
+ dateCount = make(map[string]int64)
+ for _, r := range result[0].Dates {
+ dateCount[r.Date] = r.Count
+ }
+ return result[0].MsgCount, result[0].UserCount, groups, dateCount, nil
}
func (m *MsgMongoDriver) SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (int32, []*table.MsgInfoModel, error) {
@@ -1105,7 +1075,6 @@ func (m *MsgMongoDriver) SearchMessage(ctx context.Context, req *msg.SearchMessa
if err != nil {
return 0, nil, err
}
-
return total, msgs, nil
}
@@ -1150,7 +1119,7 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa
},
},
)
- //nolint:govet //this is already standard
+
pipe = mongo.Pipeline{
{
{"$match", bson.D{
@@ -1245,6 +1214,5 @@ func (m *MsgMongoDriver) searchMessage(ctx context.Context, req *msg.SearchMessa
} else {
msgs = msgs[start:]
}
-
return n, msgs, nil
}
diff --git a/pkg/common/db/unrelation/msg_convert.go b/pkg/common/db/unrelation/msg_convert.go
index a5b28a5c7..810b4f419 100644
--- a/pkg/common/db/unrelation/msg_convert.go
+++ b/pkg/common/db/unrelation/msg_convert.go
@@ -31,14 +31,12 @@ func (m *MsgMongoDriver) ConvertMsgsDocLen(ctx context.Context, conversationIDs
cursor, err := m.MsgCollection.Find(ctx, bson.M{"doc_id": regex})
if err != nil {
log.ZError(ctx, "convertAll find msg doc failed", err, "conversationID", conversationID)
-
continue
}
var msgDocs []table.MsgDocModel
err = cursor.All(ctx, &msgDocs)
if err != nil {
log.ZError(ctx, "convertAll cursor all failed", err, "conversationID", conversationID)
-
continue
}
if len(msgDocs) < 1 {
@@ -46,45 +44,39 @@ func (m *MsgMongoDriver) ConvertMsgsDocLen(ctx context.Context, conversationIDs
}
log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(msgDocs)", len(msgDocs))
if len(msgDocs[0].Msg) == int(m.model.GetSingleGocMsgNum5000()) {
- convertMsgDocs(m, ctx, msgDocs, conversationID, regex)
- }
- }
-}
-
-func convertMsgDocs(m *MsgMongoDriver, ctx context.Context, msgDocs []table.MsgDocModel, conversationID string, regex primitive.Regex) {
- var err error
- if _, err = m.MsgCollection.DeleteMany(ctx, bson.M{"doc_id": regex}); err != nil {
- log.ZError(ctx, "convertAll delete many failed", err, "conversationID", conversationID)
-
- return
- }
- var newMsgDocs []interface{}
- for _, msgDoc := range msgDocs {
- if int64(len(msgDoc.Msg)) == m.model.GetSingleGocMsgNum() {
- continue
- }
- var index int64
- for index < int64(len(msgDoc.Msg)) {
- msg := msgDoc.Msg[index]
- if msg != nil && msg.Msg != nil {
- msgDocModel := table.MsgDocModel{DocID: m.model.GetDocID(conversationID, msg.Msg.Seq)}
- end := index + m.model.GetSingleGocMsgNum()
- if int(end) >= len(msgDoc.Msg) {
- msgDocModel.Msg = msgDoc.Msg[index:]
- } else {
- msgDocModel.Msg = msgDoc.Msg[index:end]
+ if _, err := m.MsgCollection.DeleteMany(ctx, bson.M{"doc_id": regex}); err != nil {
+ log.ZError(ctx, "convertAll delete many failed", err, "conversationID", conversationID)
+ continue
+ }
+ var newMsgDocs []interface{}
+ for _, msgDoc := range msgDocs {
+ if int64(len(msgDoc.Msg)) == m.model.GetSingleGocMsgNum() {
+ continue
}
- newMsgDocs = append(newMsgDocs, msgDocModel)
- index = end
+ var index int64
+ for index < int64(len(msgDoc.Msg)) {
+ msg := msgDoc.Msg[index]
+ if msg != nil && msg.Msg != nil {
+ msgDocModel := table.MsgDocModel{DocID: m.model.GetDocID(conversationID, msg.Msg.Seq)}
+ end := index + m.model.GetSingleGocMsgNum()
+ if int(end) >= len(msgDoc.Msg) {
+ msgDocModel.Msg = msgDoc.Msg[index:]
+ } else {
+ msgDocModel.Msg = msgDoc.Msg[index:end]
+ }
+ newMsgDocs = append(newMsgDocs, msgDocModel)
+ index = end
+ } else {
+ break
+ }
+ }
+ }
+ _, err = m.MsgCollection.InsertMany(ctx, newMsgDocs)
+ if err != nil {
+ log.ZError(ctx, "convertAll insert many failed", err, "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
} else {
- break
+ log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
}
}
}
- _, err = m.MsgCollection.InsertMany(ctx, newMsgDocs)
- if err != nil {
- log.ZError(ctx, "convertAll insert many failed", err, "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
- } else {
- log.ZInfo(ctx, "msg doc convert", "conversationID", conversationID, "len(newMsgDocs)", len(newMsgDocs))
- }
}
diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go
index 7f9aecfd6..c762140a2 100644
--- a/pkg/common/db/unrelation/super_group.go
+++ b/pkg/common/db/unrelation/super_group.go
@@ -59,7 +59,6 @@ func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID st
return err
}
}
-
return nil
}
@@ -70,7 +69,6 @@ func (s *SuperGroupMongoDriver) TakeSuperGroup(
if err := s.superGroupCollection.FindOne(ctx, bson.M{"group_id": groupID}).Decode(&group); err != nil {
return nil, utils.Wrap(err, "")
}
-
return group, nil
}
@@ -88,7 +86,6 @@ func (s *SuperGroupMongoDriver) FindSuperGroup(
if err := cursor.All(ctx, &groups); err != nil {
return nil, utils.Wrap(err, "")
}
-
return groups, nil
}
@@ -116,7 +113,6 @@ func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID
return utils.Wrap(err, "transaction failed")
}
}
-
return nil
}
@@ -133,7 +129,6 @@ func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, g
if err != nil {
return err
}
-
return nil
}
@@ -143,7 +138,6 @@ func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(
) (*unrelation.UserToSuperGroupModel, error) {
var user unrelation.UserToSuperGroupModel
err := s.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
-
return &user, utils.Wrap(err, "")
}
@@ -155,7 +149,6 @@ func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID st
if _, err := s.superGroupCollection.DeleteOne(ctx, bson.M{"group_id": groupID}); err != nil {
return utils.Wrap(err, "")
}
-
return s.RemoveGroupFromUser(ctx, groupID, group.MemberIDs)
}
@@ -165,6 +158,5 @@ func (s *SuperGroupMongoDriver) RemoveGroupFromUser(ctx context.Context, groupID
bson.M{"user_id": bson.M{"$in": userIDs}},
bson.M{"$pull": bson.M{"group_id_list": groupID}},
)
-
return utils.Wrap(err, "")
}
diff --git a/pkg/common/db/unrelation/user.go b/pkg/common/db/unrelation/user.go
index ad02968bd..4b4a78c79 100755
--- a/pkg/common/db/unrelation/user.go
+++ b/pkg/common/db/unrelation/user.go
@@ -16,7 +16,6 @@ package unrelation
import (
"context"
- "errors"
"github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/utils"
@@ -51,7 +50,6 @@ type UserMongoDriver struct {
// AddSubscriptionList Subscriber's handling of thresholds.
func (u *UserMongoDriver) AddSubscriptionList(ctx context.Context, userID string, userIDList []string) error {
// Check the number of lists in the key.
- //nolint:govet //this has already been the standard format for mongo.Pipeline
pipeline := mongo.Pipeline{
{{"$match", bson.D{{"user_id", SubscriptionPrefix + userID}}}},
{{"$project", bson.D{{"count", bson.D{{"$size", "$user_id_list"}}}}}},
@@ -67,7 +65,7 @@ func (u *UserMongoDriver) AddSubscriptionList(ctx context.Context, userID string
}
// iterate over aggregated results
for cursor.Next(ctx) {
- err = cursor.Decode(&cnt)
+ err := cursor.Decode(&cnt)
if err != nil {
return errs.Wrap(err)
}
@@ -124,7 +122,6 @@ func (u *UserMongoDriver) AddSubscriptionList(ctx context.Context, userID string
return utils.Wrap(err, "transaction failed")
}
}
-
return nil
}
@@ -142,7 +139,6 @@ func (u *UserMongoDriver) UnsubscriptionList(ctx context.Context, userID string,
if err != nil {
return errs.Wrap(err)
}
-
return nil
}
@@ -156,7 +152,6 @@ func (u *UserMongoDriver) RemoveSubscribedListFromUser(ctx context.Context, user
bson.M{"$pull": bson.M{"user_id_list": userID}},
)
}
-
return errs.Wrap(err)
}
@@ -168,13 +163,12 @@ func (u *UserMongoDriver) GetAllSubscribeList(ctx context.Context, userID string
bson.M{"user_id": SubscriptionPrefix + userID})
err = cursor.Decode(&user)
if err != nil {
- if errors.Is(err, mongo.ErrNoDocuments) {
+ if err == mongo.ErrNoDocuments {
return []string{}, nil
+ } else {
+ return nil, errs.Wrap(err)
}
-
- return nil, errs.Wrap(err)
}
-
return user.UserIDList, nil
}
@@ -186,12 +180,11 @@ func (u *UserMongoDriver) GetSubscribedList(ctx context.Context, userID string)
bson.M{"user_id": SubscribedPrefix + userID})
err = cursor.Decode(&user)
if err != nil {
- if errors.Is(err, mongo.ErrNoDocuments) {
+ if err == mongo.ErrNoDocuments {
return []string{}, nil
+ } else {
+ return nil, errs.Wrap(err)
}
-
- return nil, errs.Wrap(err)
}
-
return user.UserIDList, nil
}
diff --git a/pkg/common/discovery_register/k8s_discovery_register.go b/pkg/common/discovery_register/k8s_discovery_register.go
index 72179fdbd..70f9f39f3 100644
--- a/pkg/common/discovery_register/k8s_discovery_register.go
+++ b/pkg/common/discovery_register/k8s_discovery_register.go
@@ -4,14 +4,12 @@ import (
"context"
"errors"
"fmt"
- "time"
-
"github.com/OpenIMSDK/tools/discoveryregistry"
openkeeper "github.com/OpenIMSDK/tools/discoveryregistry/zookeeper"
"github.com/OpenIMSDK/tools/log"
- "google.golang.org/grpc"
-
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
+ "google.golang.org/grpc"
+ "time"
)
func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistry, error) {
@@ -30,7 +28,6 @@ func NewDiscoveryRegister(envType string) (discoveryregistry.SvcDiscoveryRegistr
client = nil
err = errors.New("envType not correct")
}
-
return client, err
}
@@ -45,51 +42,47 @@ func NewK8sDiscoveryRegister() (discoveryregistry.SvcDiscoveryRegistry, error) {
func (cli *K8sDR) Register(serviceName, host string, port int, opts ...grpc.DialOption) error {
cli.rpcRegisterAddr = serviceName
-
return nil
}
-
func (cli *K8sDR) UnRegister() error {
+
return nil
}
-
func (cli *K8sDR) CreateRpcRootNodes(serviceNames []string) error {
+
return nil
}
-
func (cli *K8sDR) RegisterConf2Registry(key string, conf []byte) error {
+
return nil
}
func (cli *K8sDR) GetConfFromRegistry(key string) ([]byte, error) {
+
return nil, nil
}
-
func (cli *K8sDR) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]*grpc.ClientConn, error) {
- conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
+ conn, err := grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
return []*grpc.ClientConn{conn}, err
}
-
func (cli *K8sDR) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
+
return grpc.DialContext(ctx, serviceName, append(cli.options, opts...)...)
}
-
func (cli *K8sDR) GetSelfConnTarget() string {
+
return cli.rpcRegisterAddr
}
-
func (cli *K8sDR) AddOption(opts ...grpc.DialOption) {
cli.options = append(cli.options, opts...)
}
-
func (cli *K8sDR) CloseConn(conn *grpc.ClientConn) {
conn.Close()
}
-// do not use this method for call rpc.
+// do not use this method for call rpc
func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn {
fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!")
-
return nil
}
diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go
index 579643964..2d7c24c77 100644
--- a/pkg/common/http/http_client.go
+++ b/pkg/common/http/http_client.go
@@ -34,21 +34,16 @@ import (
var client http.Client
func Get(url string) (response []byte, err error) {
- clientGet := http.Client{Timeout: 5 * time.Second}
- req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)
+ client := http.Client{Timeout: 5 * time.Second}
+ resp, err := client.Get(url)
if err != nil {
return nil, err
}
- resp, err2 := clientGet.Do(req)
- if err2 != nil {
- return nil, err
- }
defer resp.Body.Close()
- body, err3 := io.ReadAll(resp.Body)
- if err3 != nil {
+ body, err := io.ReadAll(resp.Body)
+ if err != nil {
return nil, err
}
-
return body, nil
}
@@ -88,7 +83,6 @@ func Post(
if err != nil {
return nil, err
}
-
return result, nil
}
@@ -104,7 +98,6 @@ func PostReturn(
return err
}
err = json.Unmarshal(b, output)
-
return err
}
@@ -123,22 +116,17 @@ func callBackPostReturn(
if err != nil {
if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue {
log.ZWarn(ctx, "callback failed but continue", err, "url", url)
-
return errs.ErrCallbackContinue
}
-
return errs.ErrNetwork.Wrap(err.Error())
}
if err = json.Unmarshal(b, output); err != nil {
if callbackConfig.CallbackFailedContinue != nil && *callbackConfig.CallbackFailedContinue {
log.ZWarn(ctx, "callback failed but continue", err, "url", url)
-
return errs.ErrCallbackContinue
}
-
return errs.ErrData.Wrap(err.Error())
}
-
return output.Parse()
}
diff --git a/pkg/common/kafka/consumer_group.go b/pkg/common/kafka/consumer_group.go
index c5ec69533..1eb7b522a 100644
--- a/pkg/common/kafka/consumer_group.go
+++ b/pkg/common/kafka/consumer_group.go
@@ -51,7 +51,6 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addrs []str
if err != nil {
panic(err.Error())
}
-
return &MConsumerGroup{
consumerGroup,
groupID,
diff --git a/pkg/common/kafka/producer.go b/pkg/common/kafka/producer.go
index b4545af9b..4a52d2bef 100644
--- a/pkg/common/kafka/producer.go
+++ b/pkg/common/kafka/producer.go
@@ -67,7 +67,6 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
producer, err = sarama.NewSyncProducer(p.addr, p.config) // Initialize the client
if err == nil {
p.producer = producer
-
return &p
}
//TODO If the password is wrong, exit directly
@@ -84,7 +83,6 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
panic(err.Error())
}
p.producer = producer
-
return &p
}
@@ -93,7 +91,6 @@ func GetMQHeaderWithContext(ctx context.Context) ([]sarama.RecordHeader, error)
if err != nil {
return nil, err
}
-
return []sarama.RecordHeader{
{Key: []byte(constant.OperationID), Value: []byte(operationID)},
{Key: []byte(constant.OpUserID), Value: []byte(opUserID)},
@@ -103,11 +100,10 @@ func GetMQHeaderWithContext(ctx context.Context) ([]sarama.RecordHeader, error)
}
func GetContextWithMQHeader(header []*sarama.RecordHeader) context.Context {
- values := make([]string, 0, len(header))
+ var values []string
for _, recordHeader := range header {
values = append(values, string(recordHeader.Value))
}
-
return mcontext.WithMustInfoCtx(values) // TODO
}
@@ -138,6 +134,5 @@ func (p *Producer) SendMessage(ctx context.Context, key string, msg proto.Messag
if err == nil {
prome.Inc(prome.SendMsgCounter)
}
-
return partition, offset, utils.Wrap(err, "")
}
diff --git a/pkg/common/locker/message_locker.go b/pkg/common/locker/message_locker.go
index 108dbbd48..55241eb5f 100644
--- a/pkg/common/locker/message_locker.go
+++ b/pkg/common/locker/message_locker.go
@@ -42,13 +42,11 @@ func (l *LockerMessage) LockMessageTypeKey(ctx context.Context, clientMsgID, typ
err = l.cache.LockMessageTypeKey(ctx, clientMsgID, typeKey)
if err != nil {
time.Sleep(time.Millisecond * 100)
-
continue
} else {
break
}
}
-
return err
}
@@ -57,13 +55,11 @@ func (l *LockerMessage) LockGlobalMessage(ctx context.Context, clientMsgID strin
err = l.cache.LockMessageTypeKey(ctx, clientMsgID, GlOBALLOCK)
if err != nil {
time.Sleep(time.Millisecond * 100)
-
continue
} else {
break
}
}
-
return err
}
diff --git a/pkg/common/prome/gather.go b/pkg/common/prome/gather.go
index 184034e25..eb4bc6c3b 100644
--- a/pkg/common/prome/gather.go
+++ b/pkg/common/prome/gather.go
@@ -79,7 +79,6 @@ var (
ConversationCreateFailedCounter prometheus.Counter
)
-//nolint:promlinter //no idea to fix it
func NewUserLoginCounter() {
if UserLoginCounter != nil {
return
@@ -90,7 +89,6 @@ func NewUserLoginCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewUserRegisterCounter() {
if UserRegisterCounter != nil {
return
@@ -101,7 +99,6 @@ func NewUserRegisterCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSeqGetSuccessCounter() {
if SeqGetSuccessCounter != nil {
return
@@ -112,7 +109,6 @@ func NewSeqGetSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSeqGetFailedCounter() {
if SeqGetFailedCounter != nil {
return
@@ -123,7 +119,6 @@ func NewSeqGetFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSeqSetSuccessCounter() {
if SeqSetSuccessCounter != nil {
return
@@ -134,7 +129,6 @@ func NewSeqSetSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSeqSetFailedCounter() {
if SeqSetFailedCounter != nil {
return
@@ -145,7 +139,6 @@ func NewSeqSetFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewApiRequestCounter() {
if ApiRequestCounter != nil {
return
@@ -156,7 +149,6 @@ func NewApiRequestCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewApiRequestSuccessCounter() {
if ApiRequestSuccessCounter != nil {
return
@@ -167,7 +159,6 @@ func NewApiRequestSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewApiRequestFailedCounter() {
if ApiRequestFailedCounter != nil {
return
@@ -178,7 +169,6 @@ func NewApiRequestFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGrpcRequestCounter() {
if GrpcRequestCounter != nil {
return
@@ -189,7 +179,6 @@ func NewGrpcRequestCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGrpcRequestSuccessCounter() {
if GrpcRequestSuccessCounter != nil {
return
@@ -200,7 +189,6 @@ func NewGrpcRequestSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGrpcRequestFailedCounter() {
if GrpcRequestFailedCounter != nil {
return
@@ -211,7 +199,6 @@ func NewGrpcRequestFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSendMsgCount() {
if SendMsgCounter != nil {
return
@@ -222,7 +209,6 @@ func NewSendMsgCount() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgInsertRedisSuccessCounter() {
if MsgInsertRedisSuccessCounter != nil {
return
@@ -233,7 +219,6 @@ func NewMsgInsertRedisSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix its
func NewMsgInsertRedisFailedCounter() {
if MsgInsertRedisFailedCounter != nil {
return
@@ -244,7 +229,6 @@ func NewMsgInsertRedisFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgInsertMongoSuccessCounter() {
if MsgInsertMongoSuccessCounter != nil {
return
@@ -255,7 +239,6 @@ func NewMsgInsertMongoSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgInsertMongoFailedCounter() {
if MsgInsertMongoFailedCounter != nil {
return
@@ -266,7 +249,6 @@ func NewMsgInsertMongoFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgPullFromRedisSuccessCounter() {
if MsgPullFromRedisSuccessCounter != nil {
return
@@ -277,7 +259,6 @@ func NewMsgPullFromRedisSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgPullFromRedisFailedCounter() {
if MsgPullFromRedisFailedCounter != nil {
return
@@ -288,7 +269,6 @@ func NewMsgPullFromRedisFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgPullFromMongoSuccessCounter() {
if MsgPullFromMongoSuccessCounter != nil {
return
@@ -299,7 +279,6 @@ func NewMsgPullFromMongoSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgPullFromMongoFailedCounter() {
if MsgPullFromMongoFailedCounter != nil {
return
@@ -340,7 +319,6 @@ func NewPullMsgBySeqListTotalCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSingleChatMsgRecvSuccessCounter() {
if SingleChatMsgRecvSuccessCounter != nil {
return
@@ -351,7 +329,6 @@ func NewSingleChatMsgRecvSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGroupChatMsgRecvSuccessCounter() {
if GroupChatMsgRecvSuccessCounter != nil {
return
@@ -362,7 +339,6 @@ func NewGroupChatMsgRecvSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewWorkSuperGroupChatMsgRecvSuccessCounter() {
if WorkSuperGroupChatMsgRecvSuccessCounter != nil {
return
@@ -383,7 +359,6 @@ func NewOnlineUserGauges() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSingleChatMsgProcessSuccessCounter() {
if SingleChatMsgProcessSuccessCounter != nil {
return
@@ -394,7 +369,6 @@ func NewSingleChatMsgProcessSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewSingleChatMsgProcessFailedCounter() {
if SingleChatMsgProcessFailedCounter != nil {
return
@@ -405,7 +379,6 @@ func NewSingleChatMsgProcessFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGroupChatMsgProcessSuccessCounter() {
if GroupChatMsgProcessSuccessCounter != nil {
return
@@ -416,7 +389,6 @@ func NewGroupChatMsgProcessSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewGroupChatMsgProcessFailedCounter() {
if GroupChatMsgProcessFailedCounter != nil {
return
@@ -427,7 +399,6 @@ func NewGroupChatMsgProcessFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewWorkSuperGroupChatMsgProcessSuccessCounter() {
if WorkSuperGroupChatMsgProcessSuccessCounter != nil {
return
@@ -438,7 +409,6 @@ func NewWorkSuperGroupChatMsgProcessSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewWorkSuperGroupChatMsgProcessFailedCounter() {
if WorkSuperGroupChatMsgProcessFailedCounter != nil {
return
@@ -449,7 +419,6 @@ func NewWorkSuperGroupChatMsgProcessFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgOnlinePushSuccessCounter() {
if MsgOnlinePushSuccessCounter != nil {
return
@@ -460,7 +429,6 @@ func NewMsgOnlinePushSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgOfflinePushSuccessCounter() {
if MsgOfflinePushSuccessCounter != nil {
return
@@ -471,7 +439,6 @@ func NewMsgOfflinePushSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewMsgOfflinePushFailedCounter() {
if MsgOfflinePushFailedCounter != nil {
return
@@ -482,7 +449,6 @@ func NewMsgOfflinePushFailedCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewConversationCreateSuccessCounter() {
if ConversationCreateSuccessCounter != nil {
return
@@ -493,7 +459,6 @@ func NewConversationCreateSuccessCounter() {
})
}
-//nolint:promlinter //no idea to fix it
func NewConversationCreateFailedCounter() {
if ConversationCreateFailedCounter != nil {
return
diff --git a/pkg/common/prome/prometheus.go b/pkg/common/prome/prometheus.go
index 60df5b0af..254a6c9ea 100644
--- a/pkg/common/prome/prometheus.go
+++ b/pkg/common/prome/prometheus.go
@@ -30,16 +30,13 @@ func StartPrometheusSrv(prometheusPort int) error {
if config.Config.Prometheus.Enable {
http.Handle("/metrics", promhttp.Handler())
err := http.ListenAndServe(":"+strconv.Itoa(prometheusPort), nil)
-
return err
}
-
return nil
}
func PrometheusHandler() gin.HandlerFunc {
h := promhttp.Handler()
-
return func(c *gin.Context) {
h.ServeHTTP(c.Writer, c.Request)
}
@@ -52,7 +49,6 @@ type responseBodyWriter struct {
func (r responseBodyWriter) Write(b []byte) (int, error) {
r.body.Write(b)
-
return r.ResponseWriter.Write(b)
}
diff --git a/pkg/common/tls/tls.go b/pkg/common/tls/tls.go
index 7b3e9033e..3bf91beb9 100755
--- a/pkg/common/tls/tls.go
+++ b/pkg/common/tls/tls.go
@@ -24,7 +24,6 @@ import (
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
)
-//nolint:staticcheck //we have not time looking for a replacement for x509 to fix the security valnerability
func decryptPEM(data []byte, passphrase []byte) ([]byte, error) {
if len(passphrase) == 0 {
return data, nil
@@ -34,7 +33,6 @@ func decryptPEM(data []byte, passphrase []byte) ([]byte, error) {
if err != nil {
return nil, err
}
-
return pem.EncodeToMemory(&pem.Block{
Type: b.Type,
Bytes: d,
@@ -46,7 +44,6 @@ func readEncryptablePEMBlock(path string, pwd []byte) ([]byte, error) {
if err != nil {
return nil, err
}
-
return decryptPEM(data, pwd)
}
diff --git a/pkg/msgprocessor/conversation.go b/pkg/msgprocessor/conversation.go
index 559994eaf..ca77438ea 100644
--- a/pkg/msgprocessor/conversation.go
+++ b/pkg/msgprocessor/conversation.go
@@ -28,7 +28,6 @@ func GetNotificationConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.SingleChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
-
return "n_" + strings.Join(l, "_")
case constant.GroupChatType:
return "n_" + msg.GroupID
@@ -37,7 +36,6 @@ func GetNotificationConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.NotificationChatType:
return "n_" + msg.SendID + "_" + msg.RecvID
}
-
return ""
}
@@ -46,7 +44,6 @@ func GetChatConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.SingleChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
-
return "si_" + strings.Join(l, "_")
case constant.GroupChatType:
return "g_" + msg.GroupID
@@ -55,7 +52,6 @@ func GetChatConversationIDByMsg(msg *sdkws.MsgData) string {
case constant.NotificationChatType:
return "sn_" + msg.SendID + "_" + msg.RecvID
}
-
return ""
}
@@ -64,12 +60,10 @@ func GenConversationUniqueKey(msg *sdkws.MsgData) string {
case constant.SingleChatType, constant.NotificationChatType:
l := []string{msg.SendID, msg.RecvID}
sort.Strings(l)
-
return strings.Join(l, "_")
case constant.SuperGroupChatType:
return msg.GroupID
}
-
return ""
}
@@ -82,28 +76,23 @@ func GetConversationIDByMsg(msg *sdkws.MsgData) string {
if !options.IsNotNotification() {
return "n_" + strings.Join(l, "_")
}
-
return "si_" + strings.Join(l, "_") // single chat
case constant.GroupChatType:
if !options.IsNotNotification() {
return "n_" + msg.GroupID // group chat
}
-
return "g_" + msg.GroupID // group chat
case constant.SuperGroupChatType:
if !options.IsNotNotification() {
return "n_" + msg.GroupID // super group chat
}
-
return "sg_" + msg.GroupID // super group chat
case constant.NotificationChatType:
if !options.IsNotNotification() {
return "n_" + msg.SendID + "_" + msg.RecvID // super group chat
}
-
return "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
}
-
return ""
}
@@ -122,7 +111,6 @@ func GetConversationIDBySessionType(sessionType int, ids ...string) string {
case constant.NotificationChatType:
return "sn_" + ids[0] // server notification chat
}
-
return ""
}
@@ -130,11 +118,10 @@ func GetNotificationConversationIDByConversationID(conversationID string) string
l := strings.Split(conversationID, "_")
if len(l) > 1 {
l[0] = "n"
-
return strings.Join(l, "_")
+ } else {
+ return ""
}
-
- return ""
}
func GetNotificationConversationID(sessionType int, ids ...string) string {
@@ -148,7 +135,6 @@ func GetNotificationConversationID(sessionType int, ids ...string) string {
case constant.SuperGroupChatType:
return "n_" + ids[0] // super group chat
}
-
return ""
}
@@ -169,22 +155,18 @@ func ParseConversationID(msg *sdkws.MsgData) (isNotification bool, conversationI
if !options.IsNotNotification() {
return true, "n_" + strings.Join(l, "_")
}
-
return false, "si_" + strings.Join(l, "_") // single chat
case constant.SuperGroupChatType:
if !options.IsNotNotification() {
return true, "n_" + msg.GroupID // super group chat
}
-
return false, "sg_" + msg.GroupID // super group chat
case constant.NotificationChatType:
if !options.IsNotNotification() {
return true, "n_" + msg.SendID + "_" + msg.RecvID // super group chat
}
-
return false, "sn_" + msg.SendID + "_" + msg.RecvID // server notification chat
}
-
return false, ""
}
@@ -207,7 +189,6 @@ func Pb2String(pb proto.Message) (string, error) {
if err != nil {
return "", err
}
-
return string(s), nil
}
diff --git a/pkg/msgprocessor/options.go b/pkg/msgprocessor/options.go
index 27bbb839a..c17c7cb05 100644
--- a/pkg/msgprocessor/options.go
+++ b/pkg/msgprocessor/options.go
@@ -38,14 +38,12 @@ func NewOptions(opts ...OptionsOpt) Options {
for _, opt := range opts {
opt(options)
}
-
return options
}
func NewMsgOptions() Options {
options := make(map[string]bool, 11)
options[constant.IsOfflinePush] = false
-
return make(map[string]bool)
}
@@ -53,7 +51,6 @@ func WithOptions(options Options, opts ...OptionsOpt) Options {
for _, opt := range opts {
opt(options)
}
-
return options
}
@@ -134,7 +131,6 @@ func (o Options) Is(notification string) bool {
if !ok || v {
return true
}
-
return false
}
diff --git a/pkg/rpcclient/auth.go b/pkg/rpcclient/auth.go
index 4859e541d..0ee021de1 100644
--- a/pkg/rpcclient/auth.go
+++ b/pkg/rpcclient/auth.go
@@ -31,7 +31,6 @@ func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
panic(err)
}
client := auth.NewAuthClient(conn)
-
return &Auth{discov: discov, conn: conn, Client: client}
}
diff --git a/pkg/rpcclient/conversation.go b/pkg/rpcclient/conversation.go
index df01bcb8f..3ba8dd8c0 100644
--- a/pkg/rpcclient/conversation.go
+++ b/pkg/rpcclient/conversation.go
@@ -60,8 +60,7 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
}
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID,
- conversationID string, conversationType int32,
-) error {
+ conversationID string, conversationType int32) error {
_, err := c.Client.CreateSingleChatConversations(ctx,
&pbconversation.CreateSingleChatConversationsReq{
RecvID: recvID, SendID: sendID, ConversationID: conversationID,
@@ -72,19 +71,16 @@ func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Co
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
_, err := c.Client.CreateGroupChatConversations(ctx, &pbconversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
-
return err
}
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
_, err := c.Client.SetConversationMaxSeq(ctx, &pbconversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
-
return err
}
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbconversation.ConversationReq) error {
_, err := c.Client.SetConversations(ctx, &pbconversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
-
return err
}
@@ -93,7 +89,6 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
if err != nil {
return nil, err
}
-
return resp.ConversationIDs, nil
}
@@ -102,7 +97,6 @@ func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID
if err != nil {
return nil, err
}
-
return resp.Conversation, nil
}
@@ -117,7 +111,6 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
if len(resp.Conversations) == 0 {
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("conversationIDs: %v not found", conversationIDs))
}
-
return resp.Conversations, nil
}
@@ -136,6 +129,5 @@ func (c *ConversationRpcClient) GetConversations(
if err != nil {
return nil, err
}
-
return resp.Conversations, nil
}
diff --git a/pkg/rpcclient/friend.go b/pkg/rpcclient/friend.go
index 6b214aaf2..b84db40d4 100644
--- a/pkg/rpcclient/friend.go
+++ b/pkg/rpcclient/friend.go
@@ -38,7 +38,6 @@ func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
panic(err)
}
client := friend.NewFriendClient(conn)
-
return &Friend{discov: discov, conn: conn, Client: client}
}
@@ -60,7 +59,6 @@ func (f *FriendRpcClient) GetFriendsInfo(
return nil, err
}
resp = r.FriendsInfo[0]
-
return
}
@@ -70,7 +68,6 @@ func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, us
if err != nil {
return false, err
}
-
return resp.InUser1Friends, nil
}
@@ -80,7 +77,6 @@ func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string)
if err != nil {
return nil, err
}
-
return resp.FriendIDs, nil
}
@@ -89,6 +85,5 @@ func (b *FriendRpcClient) IsBlocked(ctx context.Context, possibleBlackUserID, us
if err != nil {
return false, err
}
-
return r.InUser2Blacks, nil
}
diff --git a/pkg/rpcclient/group.go b/pkg/rpcclient/group.go
index 5a340875b..bf0efe60c 100644
--- a/pkg/rpcclient/group.go
+++ b/pkg/rpcclient/group.go
@@ -42,7 +42,6 @@ func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
panic(err)
}
client := group.NewGroupClient(conn)
-
return &Group{discov: discov, conn: conn, Client: client}
}
@@ -70,7 +69,6 @@ func (g *GroupRpcClient) GetGroupInfos(
return nil, errs.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
}
}
-
return resp.GroupInfos, nil
}
@@ -79,7 +77,6 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
if err != nil {
return nil, err
}
-
return groups[0], nil
}
@@ -92,7 +89,6 @@ func (g *GroupRpcClient) GetGroupInfoMap(
if err != nil {
return nil, err
}
-
return utils.SliceToMap(groups, func(e *sdkws.GroupInfo) string {
return e.GroupID
}), nil
@@ -118,7 +114,6 @@ func (g *GroupRpcClient) GetGroupMemberInfos(
return nil, errs.ErrNotInGroupYet.Wrap(strings.Join(ids, ","))
}
}
-
return resp.Members, nil
}
@@ -131,7 +126,6 @@ func (g *GroupRpcClient) GetGroupMemberInfo(
if err != nil {
return nil, err
}
-
return members[0], nil
}
@@ -145,7 +139,6 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(
if err != nil {
return nil, err
}
-
return utils.SliceToMap(members, func(e *sdkws.GroupMemberFullInfo) string {
return e.UserID
}), nil
@@ -162,7 +155,6 @@ func (g *GroupRpcClient) GetOwnerAndAdminInfos(
if err != nil {
return nil, err
}
-
return resp.Members, nil
}
@@ -171,7 +163,6 @@ func (g *GroupRpcClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdk
GroupID: groupID,
RoleLevels: []int32{constant.GroupOwner},
})
-
return resp.Members[0], err
}
@@ -182,7 +173,6 @@ func (g *GroupRpcClient) GetGroupMemberIDs(ctx context.Context, groupID string)
if err != nil {
return nil, err
}
-
return resp.UserIDs, nil
}
@@ -193,7 +183,6 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
if err != nil {
return nil, err
}
-
return resp.GroupInfo, nil
}
@@ -209,7 +198,6 @@ func (g *GroupRpcClient) GetGroupMemberCache(
if err != nil {
return nil, err
}
-
return resp.Member, nil
}
@@ -218,7 +206,6 @@ func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error
GroupID: groupID,
DeleteMember: true,
})
-
return err
}
@@ -226,6 +213,5 @@ func (g *GroupRpcClient) NotificationUserInfoUpdate(ctx context.Context, userID
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
UserID: userID,
})
-
return err
}
diff --git a/pkg/rpcclient/msg.go b/pkg/rpcclient/msg.go
index 00b0fa3f1..3b09b5062 100644
--- a/pkg/rpcclient/msg.go
+++ b/pkg/rpcclient/msg.go
@@ -136,7 +136,6 @@ func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
panic(err)
}
client := msg.NewMsgClient(conn)
-
return &Message{discov: discov, conn: conn, Client: client}
}
@@ -148,19 +147,16 @@ func NewMessageRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) MessageR
func (m *MessageRpcClient) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
resp, err := m.Client.SendMsg(ctx, req)
-
return resp, err
}
func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
resp, err := m.Client.GetMaxSeq(ctx, req)
-
return resp, err
}
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
resp, err := m.Client.PullMessageBySeqs(ctx, req)
-
return resp, err
}
@@ -169,7 +165,6 @@ func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversati
if err != nil {
return 0, err
}
-
return resp.MaxSeq, nil
}
@@ -205,7 +200,6 @@ func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSende
for _, opt := range opts {
opt(notificationSender)
}
-
return notificationSender
}
@@ -221,13 +215,11 @@ func WithRpcGetUserName() NotificationOptions {
}
}
-func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string,
- contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
+func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
content, err := json.Marshal(&n)
if err != nil {
- log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID",
- sendID, "recvID", recvID, "contentType", contentType, "msg", m)
+ log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
return err
}
notificationOpt := ¬ificationOpt{}
@@ -276,7 +268,6 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
} else {
log.ZError(ctx, "MsgClient Notification SendMsg failed", err, "req", &req)
}
-
return err
}
diff --git a/pkg/rpcclient/notification/friend.go b/pkg/rpcclient/notification/friend.go
index 9dae27c6e..b061a24ae 100644
--- a/pkg/rpcclient/notification/friend.go
+++ b/pkg/rpcclient/notification/friend.go
@@ -57,7 +57,6 @@ func WithDBFunc(
for _, user := range users {
result = append(result, user)
}
-
return result, nil
}
s.getUsersInfo = f
@@ -76,7 +75,6 @@ func WithRpcFunc(
for _, user := range users {
result = append(result, user)
}
-
return result, err
}
s.getUsersInfo = f
@@ -93,7 +91,6 @@ func NewFriendNotificationSender(
for _, opt := range opts {
opt(f)
}
-
return f
}
@@ -109,13 +106,22 @@ func (f *FriendNotificationSender) getUsersInfoMap(
for _, user := range users {
result[user.GetUserID()] = user.(*sdkws.UserInfo)
}
-
return result, nil
}
+func (f *FriendNotificationSender) getFromToUserNickname(
+ ctx context.Context,
+ fromUserID, toUserID string,
+) (string, string, error) {
+ users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
+ if err != nil {
+ return "", "", nil
+ }
+ return users[fromUserID].Nickname, users[toUserID].Nickname, nil
+}
+
func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, changedUserID string) error {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
-
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
}
@@ -127,7 +133,6 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}}
-
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
}
@@ -139,7 +144,6 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg}
-
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
}
@@ -151,7 +155,6 @@ func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg}
-
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
}
@@ -176,7 +179,6 @@ func (f *FriendNotificationSender) FriendAddedNotification(
if err != nil {
return err
}
-
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
}
@@ -185,7 +187,6 @@ func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context
FromUserID: req.OwnerUserID,
ToUserID: req.FriendUserID,
}}
-
return f.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
}
@@ -193,7 +194,6 @@ func (f *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Conte
tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = fromUserID
tips.FromToUserID.ToUserID = toUserID
-
return f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
}
@@ -201,7 +201,6 @@ func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, r
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = req.OwnerUserID
tips.FromToUserID.ToUserID = req.BlackUserID
-
return f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
}
@@ -210,10 +209,7 @@ func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
FromUserID: req.OwnerUserID,
ToUserID: req.BlackUserID,
}}
- err := f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
- if err != nil {
- panic(err)
- }
+ f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
}
func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
@@ -222,8 +218,5 @@ func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
needNotifiedUserID string,
) {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
- err := f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
- if err != nil {
- panic(err)
- }
+ f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
}
diff --git a/pkg/rpcclient/notification/group.go b/pkg/rpcclient/notification/group.go
index 23341af70..8e71f61c3 100755
--- a/pkg/rpcclient/notification/group.go
+++ b/pkg/rpcclient/notification/group.go
@@ -60,7 +60,6 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
if len(users) == 0 {
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("user %s not found", userID))
}
-
return &sdkws.PublicUserInfo{
UserID: users[0].GetUserID(),
Nickname: users[0].GetNickname(),
@@ -69,23 +68,6 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
}, nil
}
-func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
- return &sdkws.GroupMemberFullInfo{
- GroupID: member.GroupID,
- UserID: member.UserID,
- RoleLevel: member.RoleLevel,
- JoinTime: member.JoinTime.UnixMilli(),
- Nickname: member.Nickname,
- FaceURL: member.FaceURL,
- AppMangerLevel: appMangerLevel,
- JoinSource: member.JoinSource,
- OperatorUserID: member.OperatorUserID,
- Ex: member.Ex,
- MuteEndTime: member.MuteEndTime.UnixMilli(),
- InviterUserID: member.InviterUserID,
- }
-}
-
func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
gm, err := g.db.TakeGroup(ctx, groupID)
if err != nil {
@@ -99,7 +81,6 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
if err != nil {
return nil, err
}
-
return &sdkws.GroupInfo{
GroupID: gm.GroupID,
GroupName: gm.GroupName,
@@ -167,7 +148,6 @@ func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID
for i, member := range members {
m[member.UserID] = members[i]
}
-
return m, nil
}
@@ -179,7 +159,6 @@ func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID st
if len(members) == 0 {
return nil, errs.ErrInternalServer.Wrap(fmt.Sprintf("group %s member %s not found", groupID, userID))
}
-
return members[0], nil
}
@@ -189,10 +168,48 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
return nil, err
}
fn := func(e *relation.GroupMemberModel) string { return e.UserID }
-
return utils.Slice(members, fn), nil
}
+func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
+ return &sdkws.GroupInfo{
+ GroupID: group.GroupID,
+ GroupName: group.GroupName,
+ Notification: group.Notification,
+ Introduction: group.Introduction,
+ FaceURL: group.FaceURL,
+ OwnerUserID: ownerUserID,
+ CreateTime: group.CreateTime.UnixMilli(),
+ MemberCount: memberCount,
+ Ex: group.Ex,
+ Status: group.Status,
+ CreatorUserID: group.CreatorUserID,
+ GroupType: group.GroupType,
+ NeedVerification: group.NeedVerification,
+ LookMemberInfo: group.LookMemberInfo,
+ ApplyMemberFriend: group.ApplyMemberFriend,
+ NotificationUpdateTime: group.NotificationUpdateTime.UnixMilli(),
+ NotificationUserID: group.NotificationUserID,
+ }
+}
+
+func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
+ return &sdkws.GroupMemberFullInfo{
+ GroupID: member.GroupID,
+ UserID: member.UserID,
+ RoleLevel: member.RoleLevel,
+ JoinTime: member.JoinTime.UnixMilli(),
+ Nickname: member.Nickname,
+ FaceURL: member.FaceURL,
+ AppMangerLevel: appMangerLevel,
+ JoinSource: member.JoinSource,
+ OperatorUserID: member.OperatorUserID,
+ Ex: member.Ex,
+ MuteEndTime: member.MuteEndTime.UnixMilli(),
+ InviterUserID: member.InviterUserID,
+ }
+}
+
func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
users, err := g.getUsersInfo(ctx, userIDs)
if err != nil {
@@ -202,7 +219,6 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
for _, user := range users {
result[user.GetUserID()] = user.(*sdkws.UserInfo)
}
-
return result, nil
}
@@ -220,31 +236,21 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
return nil
}
userID := mcontext.GetOpUserID(ctx)
- getOpUser := func(g *GroupNotificationSender, groupID, userID string) (opUser *sdkws.GroupMemberFullInfo, err error) {
+ if groupID != "" {
if authverify.IsManagerUserID(userID) {
- opUser = &sdkws.GroupMemberFullInfo{
+ *opUser = &sdkws.GroupMemberFullInfo{
GroupID: groupID,
UserID: userID,
RoleLevel: constant.GroupAdmin,
AppMangerLevel: constant.AppAdmin,
}
-
- return opUser, nil
- }
- var member *relation.GroupMemberModel
- member, err = g.db.TakeGroupMember(ctx, groupID, userID)
- if err == nil {
- opUser = g.groupMemberDB2PB(member, 0)
- } else if !errs.ErrRecordNotFound.Is(err) {
- return nil, err
- }
-
- return opUser, nil
- }
- if groupID != "" {
- *opUser, err = getOpUser(g, groupID, userID)
- if err != nil {
- return err
+ } else {
+ member, err := g.db.TakeGroupMember(ctx, groupID, userID)
+ if err == nil {
+ *opUser = g.groupMemberDB2PB(member, 0)
+ } else if !errs.ErrRecordNotFound.Is(err) {
+ return err
+ }
}
}
user, err := g.getUser(ctx, userID)
@@ -267,7 +273,6 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
(*opUser).FaceURL = user.FaceURL
}
}
-
return nil
}
@@ -281,7 +286,6 @@ func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context,
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
}
@@ -295,7 +299,6 @@ func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context,
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
}
@@ -309,7 +312,6 @@ func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Conte
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
}
@@ -323,7 +325,6 @@ func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx conte
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
}
@@ -354,7 +355,6 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
}
}
-
return nil
}
@@ -370,7 +370,6 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
return err
}
tips := &sdkws.MemberQuitTips{Group: group, QuitUser: member}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
}
@@ -390,8 +389,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
return err
}
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg, ReceiverAs: 1}
- err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
- if err != nil {
+ if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
@@ -400,7 +398,6 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
log.ZError(ctx, "failed", err)
}
}
-
return nil
}
@@ -420,8 +417,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
return err
}
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
- err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
- if err != nil {
+ if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
@@ -430,7 +426,6 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
log.ZError(ctx, "failed", err)
}
}
-
return nil
}
@@ -454,7 +449,6 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
}
@@ -468,7 +462,6 @@ func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context,
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
}
@@ -494,7 +487,6 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
}
@@ -514,7 +506,6 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, g
return err
}
tips := &sdkws.MemberEnterTips{Group: group, EntrantUser: user}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
}
@@ -528,7 +519,6 @@ func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
}
@@ -554,7 +544,6 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
}
@@ -577,7 +566,6 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
}
@@ -603,7 +591,6 @@ func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, gr
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
}
@@ -629,7 +616,6 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
}
@@ -652,7 +638,6 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
}
@@ -675,7 +660,6 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
}
@@ -698,7 +682,6 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
-
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
}
@@ -710,6 +693,5 @@ func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, se
}
}()
err = g.Notification(ctx, sendID, recvID, constant.SuperGroupUpdateNotification, nil)
-
return err
}
diff --git a/pkg/rpcclient/notification/msg.go b/pkg/rpcclient/notification/msg.go
index 6e367ac04..60fa64f40 100644
--- a/pkg/rpcclient/notification/msg.go
+++ b/pkg/rpcclient/notification/msg.go
@@ -37,7 +37,6 @@ func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context,
ConversationID: conversationID,
Seqs: seqs,
}
-
return m.Notification(ctx, userID, userID, constant.DeleteMsgsNotification, &tips)
}
@@ -48,6 +47,5 @@ func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conv
Seqs: seqs,
HasReadSeq: hasReadSeq,
}
-
return m.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
}
diff --git a/pkg/rpcclient/notification/user.go b/pkg/rpcclient/notification/user.go
index f6e592d18..4feebf7b9 100644
--- a/pkg/rpcclient/notification/user.go
+++ b/pkg/rpcclient/notification/user.go
@@ -52,7 +52,6 @@ func WithUserFunc(
for _, user := range users {
result = append(result, user)
}
-
return result, nil
}
u.getUsersInfo = f
@@ -69,37 +68,34 @@ func NewUserNotificationSender(
for _, opt := range opts {
opt(f)
}
-
return f
}
-// func (u *UserNotificationSender) getUsersInfoMap(
-// ctx context.Context,
-// userIDs []string,
-// ) (map[string]*sdkws.UserInfo, error) {
-// users, err := u.getUsersInfo(ctx, userIDs)
-// if err != nil {
-// return nil, err
-// }
-// result := make(map[string]*sdkws.UserInfo)
-// for _, user := range users {
-// result[user.GetUserID()] = user.(*sdkws.UserInfo)
-// }
-
-// return result, nil
-// }
-
-// func (u *UserNotificationSender) getFromToUserNickname(
-// ctx context.Context,
-// fromUserID, toUserID string,
-// ) (string, string, error) {
-// users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
-// if err != nil {
-// return "", "", err
-// }
+func (u *UserNotificationSender) getUsersInfoMap(
+ ctx context.Context,
+ userIDs []string,
+) (map[string]*sdkws.UserInfo, error) {
+ users, err := u.getUsersInfo(ctx, userIDs)
+ if err != nil {
+ return nil, err
+ }
+ result := make(map[string]*sdkws.UserInfo)
+ for _, user := range users {
+ result[user.GetUserID()] = user.(*sdkws.UserInfo)
+ }
+ return result, nil
+}
-// return users[fromUserID].Nickname, users[toUserID].Nickname, nil
-// }
+func (u *UserNotificationSender) getFromToUserNickname(
+ ctx context.Context,
+ fromUserID, toUserID string,
+) (string, string, error) {
+ users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
+ if err != nil {
+ return "", "", nil
+ }
+ return users[fromUserID].Nickname, users[toUserID].Nickname, nil
+}
func (u *UserNotificationSender) UserStatusChangeNotification(
ctx context.Context,
diff --git a/pkg/rpcclient/push.go b/pkg/rpcclient/push.go
index 7733572bf..6d0876972 100644
--- a/pkg/rpcclient/push.go
+++ b/pkg/rpcclient/push.go
@@ -36,7 +36,6 @@ func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
if err != nil {
panic(err)
}
-
return &Push{
discov: discov,
conn: conn,
diff --git a/pkg/rpcclient/third.go b/pkg/rpcclient/third.go
index 2bb761450..48a537112 100755
--- a/pkg/rpcclient/third.go
+++ b/pkg/rpcclient/third.go
@@ -42,13 +42,14 @@ func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
panic(err)
}
client := third.NewThirdClient(conn)
- minioClient, _ := minioInit()
-
+ minioClient, err := minioInit()
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
}
func minioInit() (*minio.Client, error) {
- initUrl := config.Config.Object.Minio.Endpoint
+ minioClient := &minio.Client{}
+ var initUrl string
+ initUrl = config.Config.Object.Minio.Endpoint
minioUrl, err := url.Parse(initUrl)
if err != nil {
return nil, err
@@ -62,11 +63,9 @@ func minioInit() (*minio.Client, error) {
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
- var minioClient *minio.Client
minioClient, err = minio.New(minioUrl.Host, opts)
if err != nil {
return nil, err
}
-
return minioClient, nil
}
diff --git a/pkg/rpcclient/user.go b/pkg/rpcclient/user.go
index dfd93fb0b..c40d95727 100644
--- a/pkg/rpcclient/user.go
+++ b/pkg/rpcclient/user.go
@@ -45,7 +45,6 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
panic(err)
}
client := user.NewUserClient(conn)
-
return &User{Discov: discov, Client: client, conn: conn}
}
@@ -55,7 +54,6 @@ type UserRpcClient User
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
func NewUserRpcClientByUser(user *User) *UserRpcClient {
rpc := UserRpcClient(*user)
-
return &rpc
}
@@ -77,7 +75,6 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
})); len(ids) > 0 {
return nil, errs.ErrUserIDNotFound.Wrap(strings.Join(ids, ","))
}
-
return resp.UsersInfo, nil
}
@@ -87,7 +84,6 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
if err != nil {
return nil, err
}
-
return users[0], nil
}
@@ -97,7 +93,6 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
if err != nil {
return nil, err
}
-
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
return e.UserID
}), nil
@@ -113,7 +108,6 @@ func (u *UserRpcClient) GetPublicUserInfos(
if err != nil {
return nil, err
}
-
return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo {
return &sdkws.PublicUserInfo{
UserID: e.UserID,
@@ -130,7 +124,6 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
if err != nil {
return nil, err
}
-
return users[0], nil
}
@@ -144,7 +137,6 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
if err != nil {
return nil, err
}
-
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
return e.UserID
}), nil
@@ -158,7 +150,6 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
if err != nil {
return 0, err
}
-
return resp.GlobalRecvMsgOpt, nil
}
@@ -168,7 +159,6 @@ func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
if err != nil {
return err
}
-
return authverify.CheckAccessV3(ctx, ownerUserID)
}
@@ -178,7 +168,6 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
if err != nil {
return nil, err
}
-
return resp.UserIDs, nil
}
@@ -188,6 +177,5 @@ func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status
UserID: userID,
Status: status, PlatformID: int32(platformID),
})
-
return err
}
diff --git a/pkg/statistics/statistics.go b/pkg/statistics/statistics.go
index 080933c73..de6d04fec 100644
--- a/pkg/statistics/statistics.go
+++ b/pkg/statistics/statistics.go
@@ -36,8 +36,9 @@ func (s *Statistics) output() {
var timeIntervalNum uint64
for {
sum = *s.AllCount
- <-t.C
-
+ select {
+ case <-t.C:
+ }
if *s.AllCount-sum <= 0 {
intervalCount = 0
} else {
@@ -65,6 +66,5 @@ func (s *Statistics) output() {
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: uint64(sleepTime), PrintArgs: printArgs}
go p.output()
-
return p
}
diff --git a/tools/url2im/pkg/buffer.go b/tools/url2im/pkg/buffer.go
index 008400926..8ccc5c52f 100644
--- a/tools/url2im/pkg/buffer.go
+++ b/tools/url2im/pkg/buffer.go
@@ -15,7 +15,7 @@ func NewReader(r io.Reader, max int64, path string) (ReadSeekSizeCloser, error)
buf := make([]byte, max+1)
n, err := io.ReadFull(r, buf)
if err == nil {
- f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0666)
+ f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o666)
if err != nil {
return nil, err
}
diff --git a/tools/yamlfmt/yamlfmt.go b/tools/yamlfmt/yamlfmt.go
index 38004bfde..a8d3a76f6 100644
--- a/tools/yamlfmt/yamlfmt.go
+++ b/tools/yamlfmt/yamlfmt.go
@@ -39,7 +39,7 @@ func main() {
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
}
- writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
+ writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o666)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
continue
From 38ab3e0ed791a9d981494ce6b5726f616b0043f4 Mon Sep 17 00:00:00 2001
From: Gordon <46924906+FGadvancer@users.noreply.github.com>
Date: Thu, 26 Oct 2023 12:22:43 +0800
Subject: [PATCH 2/7] fix: zk add close to avoid zk block. (#1284)
* fix: zk add close to avoid zk block.
* fix: zk add close to avoid zk block.
* fix: zk add close to avoid zk block.
* fix: zk add close to avoid zk block.
---
go.mod | 2 +-
internal/rpc/msg/sync_msg.go | 11 +++++++++++
.../k8s_discovery_register.go | 3 +++
pkg/common/startrpc/start.go | 17 ++++++-----------
4 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/go.mod b/go.mod
index 4bd7999b7..4d4ed879b 100644
--- a/go.mod
+++ b/go.mod
@@ -38,7 +38,7 @@ require github.com/google/uuid v1.3.1
require (
github.com/IBM/sarama v1.41.3
github.com/OpenIMSDK/protocol v0.0.30
- github.com/OpenIMSDK/tools v0.0.14
+ github.com/OpenIMSDK/tools v0.0.15
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
github.com/go-redis/redis v6.15.9+incompatible
github.com/go-sql-driver/mysql v1.7.1
diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go
index aaafb45bb..7c67ff05f 100644
--- a/internal/rpc/msg/sync_msg.go
+++ b/internal/rpc/msg/sync_msg.go
@@ -62,6 +62,11 @@ func (m *msgServer) PullMessageBySeqs(
case sdkws.PullOrder_PullOrderDesc:
isEnd = seq.Begin <= minSeq
}
+ if len(msgs) == 0 {
+ log.ZWarn(ctx, "not have msgs", nil, "conversationID", seq.ConversationID, "seq", seq)
+
+ continue
+ }
resp.Msgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: msgs, IsEnd: isEnd}
} else {
var seqs []int64
@@ -71,6 +76,7 @@ func (m *msgServer) PullMessageBySeqs(
minSeq, maxSeq, notificationMsgs, err := m.MsgDatabase.GetMsgBySeqs(ctx, req.UserID, seq.ConversationID, seqs)
if err != nil {
log.ZWarn(ctx, "GetMsgBySeqs error", err, "conversationID", seq.ConversationID, "seq", seq)
+
continue
}
var isEnd bool
@@ -80,6 +86,11 @@ func (m *msgServer) PullMessageBySeqs(
case sdkws.PullOrder_PullOrderDesc:
isEnd = seq.Begin <= minSeq
}
+ if len(notificationMsgs) == 0 {
+ log.ZWarn(ctx, "not have notificationMsgs", nil, "conversationID", seq.ConversationID, "seq", seq)
+
+ continue
+ }
resp.NotificationMsgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: notificationMsgs, IsEnd: isEnd}
}
}
diff --git a/pkg/common/discovery_register/k8s_discovery_register.go b/pkg/common/discovery_register/k8s_discovery_register.go
index 70f9f39f3..811d35b96 100644
--- a/pkg/common/discovery_register/k8s_discovery_register.go
+++ b/pkg/common/discovery_register/k8s_discovery_register.go
@@ -86,3 +86,6 @@ func (cli *K8sDR) GetClientLocalConns() map[string][]*grpc.ClientConn {
fmt.Println("should not call this function!!!!!!!!!!!!!!!!!!!!!!!!!")
return nil
}
+func (cli *K8sDR) Close() {
+ return
+}
diff --git a/pkg/common/startrpc/start.go b/pkg/common/startrpc/start.go
index 2aeff3cf0..f04ab2508 100644
--- a/pkg/common/startrpc/start.go
+++ b/pkg/common/startrpc/start.go
@@ -51,17 +51,12 @@ func Start(
return err
}
defer listener.Close()
- zkClient, err := discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
- /*
- zkClient, err := zookeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
- zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword(
- config.Config.Zookeeper.Username,
- config.Config.Zookeeper.Password,
- ), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
+ client, err := discovery_register.NewDiscoveryRegister(config.Config.Envs.Discovery)
+ if err != nil {
return utils.Wrap1(err)
}
- // defer zkClient.CloseZK()
- zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
+ defer client.Close()
+ client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
if err != nil {
return err
@@ -81,11 +76,11 @@ func Start(
}
srv := grpc.NewServer(options...)
defer srv.GracefulStop()
- err = rpcFn(zkClient, srv)
+ err = rpcFn(client, srv)
if err != nil {
return utils.Wrap1(err)
}
- err = zkClient.Register(
+ err = client.Register(
rpcRegisterName,
registerIP,
rpcPort,
From 7722714251399be7026a1c7610f45d835e4c8970 Mon Sep 17 00:00:00 2001
From: kvii <56432636+kvii@users.noreply.github.com>
Date: Sun, 29 Oct 2023 21:56:24 +0800
Subject: [PATCH 3/7] fix: create database name (#1285)
---
pkg/common/db/relation/mysql_init.go | 108 ++++++++++++-------
pkg/common/db/relation/mysql_init_test.go | 121 ++++++++++++++++++++++
2 files changed, 191 insertions(+), 38 deletions(-)
create mode 100644 pkg/common/db/relation/mysql_init_test.go
diff --git a/pkg/common/db/relation/mysql_init.go b/pkg/common/db/relation/mysql_init.go
index 0e5ea5e43..16b8c99fa 100644
--- a/pkg/common/db/relation/mysql_init.go
+++ b/pkg/common/db/relation/mysql_init.go
@@ -18,15 +18,12 @@ import (
"fmt"
"time"
- mysqldriver "github.com/go-sql-driver/mysql"
- "gorm.io/driver/mysql"
-
"github.com/OpenIMSDK/tools/errs"
"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"
)
@@ -35,56 +32,80 @@ const (
maxRetry = 100 // number of retries
)
-// newMysqlGormDB Initialize the database connection.
-func newMysqlGormDB() (*gorm.DB, error) {
- dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
- config.Config.Mysql.Username, config.Config.Mysql.Password, config.Config.Mysql.Address[0], "mysql")
+type option struct {
+ Username string
+ Password string
+ Address []string
+ Database string
+ LogLevel int
+ SlowThreshold int
+ MaxLifeTime int
+ MaxOpenConn int
+ MaxIdleConn int
+ Connect func(dsn string, maxRetry int) (*gorm.DB, error)
+}
- db, err := connectToDatabase(dsn, maxRetry)
- if err != nil {
- panic(err.Error() + " Open failed " + dsn)
- }
- sqlDB, err := db.DB()
+// newMysqlGormDB Initialize the database connection.
+func newMysqlGormDB(o *option) (*gorm.DB, error) {
+ err := maybeCreateTable(o)
if err != nil {
return nil, err
}
- defer sqlDB.Close()
- sql := fmt.Sprintf(
- "CREATE DATABASE IF NOT EXISTS %s default charset utf8mb4 COLLATE utf8mb4_unicode_ci;",
- config.Config.Mysql.Database,
- )
- err = db.Exec(sql).Error
- if err != nil {
- return nil, fmt.Errorf("init db %w", err)
- }
- dsn = fmt.Sprintf(
- "%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
- config.Config.Mysql.Username,
- config.Config.Mysql.Password,
- config.Config.Mysql.Address[0],
- config.Config.Mysql.Database,
- )
+ dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
+ o.Username, o.Password, o.Address[0], o.Database)
sqlLogger := log.NewSqlLogger(
- logger.LogLevel(config.Config.Mysql.LogLevel),
+ logger.LogLevel(o.LogLevel),
true,
- time.Duration(config.Config.Mysql.SlowThreshold)*time.Millisecond,
+ time.Duration(o.SlowThreshold)*time.Millisecond,
)
- db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
+ db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: sqlLogger,
})
if err != nil {
return nil, err
}
- sqlDB, err = db.DB()
+ sqlDB, err := db.DB()
if err != nil {
return nil, err
}
- sqlDB.SetConnMaxLifetime(time.Second * time.Duration(config.Config.Mysql.MaxLifeTime))
- sqlDB.SetMaxOpenConns(config.Config.Mysql.MaxOpenConn)
- sqlDB.SetMaxIdleConns(config.Config.Mysql.MaxIdleConn)
+ sqlDB.SetConnMaxLifetime(time.Second * time.Duration(o.MaxLifeTime))
+ sqlDB.SetMaxOpenConns(o.MaxOpenConn)
+ sqlDB.SetMaxIdleConns(o.MaxIdleConn)
return db, nil
}
+// maybeCreateTable creates a database if it does not exists.
+func maybeCreateTable(o *option) error {
+ dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
+ o.Username, o.Password, o.Address[0], "mysql")
+
+ var db *gorm.DB
+ var err error
+ if f := o.Connect; f != nil {
+ db, err = f(dsn, maxRetry)
+ } else {
+ db, err = connectToDatabase(dsn, maxRetry)
+ }
+ if err != nil {
+ panic(err.Error() + " Open failed " + dsn)
+ }
+
+ sqlDB, err := db.DB()
+ if err != nil {
+ return err
+ }
+ defer sqlDB.Close()
+ sql := fmt.Sprintf(
+ "CREATE DATABASE IF NOT EXISTS `%s` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ o.Database,
+ )
+ err = db.Exec(sql).Error
+ if err != nil {
+ return fmt.Errorf("init db %w", err)
+ }
+ return nil
+}
+
// connectToDatabase Connection retry for mysql.
func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
var db *gorm.DB
@@ -106,7 +127,18 @@ func connectToDatabase(dsn string, maxRetry int) (*gorm.DB, error) {
func NewGormDB() (*gorm.DB, error) {
specialerror.AddReplace(gorm.ErrRecordNotFound, errs.ErrRecordNotFound)
specialerror.AddErrHandler(replaceDuplicateKey)
- return newMysqlGormDB()
+
+ return newMysqlGormDB(&option{
+ Username: config.Config.Mysql.Username,
+ Password: config.Config.Mysql.Password,
+ Address: config.Config.Mysql.Address,
+ Database: config.Config.Mysql.Database,
+ LogLevel: config.Config.Mysql.LogLevel,
+ SlowThreshold: config.Config.Mysql.SlowThreshold,
+ MaxLifeTime: config.Config.Mysql.MaxLifeTime,
+ MaxOpenConn: config.Config.Mysql.MaxOpenConn,
+ MaxIdleConn: config.Config.Mysql.MaxIdleConn,
+ })
}
func replaceDuplicateKey(err error) errs.CodeError {
diff --git a/pkg/common/db/relation/mysql_init_test.go b/pkg/common/db/relation/mysql_init_test.go
new file mode 100644
index 000000000..c321dfd9f
--- /dev/null
+++ b/pkg/common/db/relation/mysql_init_test.go
@@ -0,0 +1,121 @@
+package relation
+
+import (
+ "context"
+ "database/sql"
+ "database/sql/driver"
+ "errors"
+ "fmt"
+ "reflect"
+ "testing"
+
+ "gorm.io/driver/mysql"
+ "gorm.io/gorm"
+ "gorm.io/gorm/logger"
+)
+
+func TestMaybeCreateTable(t *testing.T) {
+ t.Run("normal", func(t *testing.T) {
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "openIM_v3",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ query: "CREATE DATABASE IF NOT EXISTS `openIM_v3` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ args: nil,
+ }),
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ })
+
+ t.Run("im-db", func(t *testing.T) {
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "im-db",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ query: "CREATE DATABASE IF NOT EXISTS `im-db` default charset utf8mb4 COLLATE utf8mb4_unicode_ci",
+ args: nil,
+ }),
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ })
+
+ t.Run("err", func(t *testing.T) {
+ e := errors.New("e")
+ err := maybeCreateTable(&option{
+ Username: "root",
+ Password: "openIM123",
+ Address: []string{"172.28.0.1:13306"},
+ Database: "openIM_v3",
+ LogLevel: 4,
+ SlowThreshold: 500,
+ MaxOpenConn: 1000,
+ MaxIdleConn: 100,
+ MaxLifeTime: 60,
+ Connect: connect(expectExec{
+ err: e,
+ }),
+ })
+ if !errors.Is(err, e) {
+ t.Fatalf("err not is e: %v", err)
+ }
+ })
+}
+
+func connect(e expectExec) func(string, int) (*gorm.DB, error) {
+ return func(string, int) (*gorm.DB, error) {
+ return gorm.Open(mysql.New(mysql.Config{
+ SkipInitializeWithVersion: true,
+ Conn: sql.OpenDB(e),
+ }), &gorm.Config{
+ Logger: logger.Discard,
+ })
+ }
+}
+
+type expectExec struct {
+ err error
+ query string
+ args []driver.NamedValue
+}
+
+func (c expectExec) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
+ if c.err != nil {
+ return nil, c.err
+ }
+ if query != c.query {
+ return nil, fmt.Errorf("query mismatch. expect: %s, got: %s", c.query, query)
+ }
+ if reflect.DeepEqual(args, c.args) {
+ return nil, fmt.Errorf("args mismatch. expect: %v, got: %v", c.args, args)
+ }
+ return noEffectResult{}, nil
+}
+
+func (e expectExec) Connect(context.Context) (driver.Conn, error) { return e, nil }
+func (expectExec) Driver() driver.Driver { panic("not implemented") }
+func (expectExec) Prepare(query string) (driver.Stmt, error) { panic("not implemented") }
+func (expectExec) Close() (e error) { return }
+func (expectExec) Begin() (driver.Tx, error) { panic("not implemented") }
+
+type noEffectResult struct{}
+
+func (noEffectResult) LastInsertId() (i int64, e error) { return }
+func (noEffectResult) RowsAffected() (i int64, e error) { return }
From 5806446f90e1f20f83889d80e0deea33f3875c96 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sun, 29 Oct 2023 21:59:09 +0800
Subject: [PATCH 4/7] chore(deps): bump the github-actions group with 1 update
(#1274)
Bumps the github-actions group with 1 update: [actions/setup-node](https://github.com/actions/setup-node).
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-node
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: github-actions
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
.github/workflows/opencommit.yml | 2 +-
.github/workflows/pull-request.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/opencommit.yml b/.github/workflows/opencommit.yml
index db244705c..6496bd2ce 100644
--- a/.github/workflows/opencommit.yml
+++ b/.github/workflows/opencommit.yml
@@ -27,7 +27,7 @@ jobs:
permissions: write-all
steps:
- name: Setup Node.js Environment
- uses: actions/setup-node@v3
+ uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/checkout@v4
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 8094718c6..045f269d6 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -42,7 +42,7 @@ jobs:
git config user.name 'openimbot'
git config user.email 'openimsdk@qq.com'
git checkout -b cicd/patch-${{ github.event.number }}
- - uses: actions/setup-node@v3
+ - uses: actions/setup-node@v4
- name: Setup Go
uses: actions/setup-go@v4
- name: Run go modules tidy
From 726f14fd404327db6f7e219e321e2cd05063c0a5 Mon Sep 17 00:00:00 2001
From: a3d21 <93191329+a3d21@users.noreply.github.com>
Date: Sun, 29 Oct 2023 22:00:17 +0800
Subject: [PATCH 5/7] fix: NotNotifyUser receive offline push (#1287)
* fix: NotNotifyUser receive offline push
* use utils.SliceSub
---
internal/push/push_to_client.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/internal/push/push_to_client.go b/internal/push/push_to_client.go
index ba0d65b39..8f671c21d 100644
--- a/internal/push/push_to_client.go
+++ b/internal/push/push_to_client.go
@@ -222,7 +222,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
// log.ZError(ctx, "GetRecvMsgNotNotifyUserIDs failed", err, "groupID", groupID)
return err
}
- needOfflinePushUserIDs = utils.DifferenceString(notNotificationUserIDs, needOfflinePushUserIDs)
+ needOfflinePushUserIDs = utils.SliceSub(needOfflinePushUserIDs, notNotificationUserIDs)
}
// Use offline push messaging
if len(needOfflinePushUserIDs) > 0 {
From a4b28c9523365f63ababf67886dd8c8be6c8b175 Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <3293172751@qq.com>
Date: Mon, 30 Oct 2023 10:16:37 +0800
Subject: [PATCH 6/7] docs: add openim cluster helm chart (#1291)
* docs: add openim cluster helm chart
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* docs: add openim scripts deployment system
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* docs: add all openim helm chart deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* docs: add all openim helm chart deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim install scripts docs
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim kubernetes deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim kubernetes deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim kubernetes deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim kubernetes deployment
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* fix: openim images version
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* fix: make image
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim helm charts
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim helm charts
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
* feat: add openim config docs
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
---------
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
---
.env | 9 +-
.github/workflows/docker-buildx.yml | 79 +++-
.github/workflows/openimci.yml | 21 ++
.gitignore | 14 +-
.golangci.yml | 89 +----
Makefile | 8 +-
README-zh_CN.md | 4 +-
README.md | 4 +-
build/goreleaser.yaml | 125 -------
config/config.yaml | 11 +-
deployments/README.md | 120 +++---
deployments/charts/helmfile.yaml | 20 +
.../openim-api}/.helmignore | 0
deployments/charts/openim-api/Chart.yaml | 39 ++
.../openim-api}/LICENSE | 0
.../openim-api}/templates/NOTES.txt | 8 +-
.../openim-api}/templates/_helpers.tpl | 20 +-
.../charts/openim-api/templates/app-cm.yaml | 13 +
.../openim-api/templates/deployment.yaml | 72 ++++
.../openim-api}/templates/hpa.yaml | 20 +-
.../openim-api}/templates/ingress.yaml | 18 +-
.../charts/openim-api/templates/service.yaml | 15 +
.../openim-api/templates/serviceaccount.yaml | 12 +
deployments/charts/openim-api/values.yaml | 86 +++++
.../charts/openim-msggateway/.helmignore | 23 ++
.../openim-msggateway}/Chart.yaml | 41 +-
.../openim-msggateway/templates/NOTES.txt | 22 ++
.../openim-msggateway/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 75 ++++
.../openim-msggateway/templates/hpa.yaml | 28 ++
.../openim-msggateway/templates/ingress.yaml | 61 +++
.../openim-msggateway/templates/service.yaml | 19 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-msggateway/values.yaml | 82 ++++
.../charts/openim-msgtransfer/.helmignore | 23 ++
.../charts/openim-msgtransfer/Chart.yaml | 39 ++
.../openim-msgtransfer/templates/NOTES.txt | 22 ++
.../openim-msgtransfer/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 72 ++++
.../openim-msgtransfer/templates/hpa.yaml | 28 ++
.../openim-msgtransfer/templates/ingress.yaml | 61 +++
.../openim-msgtransfer/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../openim-msgtransfer}/values.yaml | 20 +-
deployments/charts/openim-push/.helmignore | 23 ++
deployments/charts/openim-push/Chart.yaml | 39 ++
.../charts/openim-push/templates/NOTES.txt | 22 ++
.../charts/openim-push/templates/_helpers.tpl | 62 +++
.../openim-push/templates/deployment.yaml | 72 ++++
.../charts/openim-push/templates/hpa.yaml | 28 ++
.../charts/openim-push/templates/ingress.yaml | 61 +++
.../charts/openim-push/templates/service.yaml | 15 +
.../openim-push/templates/serviceaccount.yaml | 12 +
deployments/charts/openim-push/values.yaml | 82 ++++
.../charts/openim-rpc-auth/.helmignore | 23 ++
deployments/charts/openim-rpc-auth/Chart.yaml | 39 ++
.../openim-rpc-auth/templates/NOTES.txt | 22 ++
.../openim-rpc-auth/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 51 ++-
.../charts/openim-rpc-auth/templates/hpa.yaml | 28 ++
.../openim-rpc-auth/templates/ingress.yaml | 61 +++
.../openim-rpc-auth/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-rpc-auth/values.yaml | 82 ++++
.../openim-rpc-conversation/.helmignore | 23 ++
.../charts/openim-rpc-conversation/Chart.yaml | 39 ++
.../templates/NOTES.txt | 22 ++
.../templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 72 ++++
.../templates/hpa.yaml | 28 ++
.../templates/ingress.yaml | 61 +++
.../templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../openim-rpc-conversation/values.yaml | 82 ++++
.../charts/openim-rpc-friend/.helmignore | 23 ++
.../charts/openim-rpc-friend/Chart.yaml | 39 ++
.../openim-rpc-friend/templates/NOTES.txt | 22 ++
.../openim-rpc-friend/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 72 ++++
.../openim-rpc-friend/templates/hpa.yaml | 28 ++
.../openim-rpc-friend/templates/ingress.yaml | 61 +++
.../openim-rpc-friend/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-rpc-friend/values.yaml | 82 ++++
.../charts/openim-rpc-group/.helmignore | 23 ++
.../charts/openim-rpc-group/Chart.yaml | 39 ++
.../openim-rpc-group/templates/NOTES.txt | 22 ++
.../openim-rpc-group/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 72 ++++
.../openim-rpc-group/templates/hpa.yaml | 28 ++
.../openim-rpc-group/templates/ingress.yaml | 61 +++
.../openim-rpc-group/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-rpc-group/values.yaml | 82 ++++
deployments/charts/openim-rpc-msg/.helmignore | 23 ++
deployments/charts/openim-rpc-msg/Chart.yaml | 39 ++
.../charts/openim-rpc-msg/templates/NOTES.txt | 22 ++
.../openim-rpc-msg/templates/_helpers.tpl | 62 +++
.../openim-rpc-msg/templates/deployment.yaml | 72 ++++
.../charts/openim-rpc-msg/templates/hpa.yaml | 28 ++
.../openim-rpc-msg/templates/ingress.yaml | 61 +++
.../openim-rpc-msg/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
deployments/charts/openim-rpc-msg/values.yaml | 82 ++++
.../charts/openim-rpc-third/.helmignore | 23 ++
.../charts/openim-rpc-third/Chart.yaml | 39 ++
.../openim-rpc-third/templates/NOTES.txt | 22 ++
.../openim-rpc-third/templates/_helpers.tpl | 62 +++
.../templates/deployment.yaml | 72 ++++
.../openim-rpc-third/templates/hpa.yaml | 28 ++
.../openim-rpc-third/templates/ingress.yaml | 61 +++
.../openim-rpc-third/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-rpc-third/values.yaml | 82 ++++
.../charts/openim-rpc-user/.helmignore | 23 ++
deployments/charts/openim-rpc-user/Chart.yaml | 39 ++
.../openim-rpc-user/templates/NOTES.txt | 22 ++
.../openim-rpc-user/templates/_helpers.tpl | 62 +++
.../openim-rpc-user/templates/deployment.yaml | 72 ++++
.../charts/openim-rpc-user/templates/hpa.yaml | 28 ++
.../openim-rpc-user/templates/ingress.yaml | 61 +++
.../openim-rpc-user/templates/service.yaml | 15 +
.../templates/serviceaccount.yaml | 12 +
.../charts/openim-rpc-user/values.yaml | 82 ++++
deployments/openim-server/README.md | 15 -
.../openim-server/templates/service.yaml | 29 --
.../templates/serviceaccount.yaml | 26 --
deployments/templates/charts-value.yaml | 96 +++++
deployments/templates/helm-image.yaml | 89 +++++
deployments/templates/init/README.md | 220 -----------
deployments/templates/init/openim-api.service | 16 -
.../templates/init/openim-cmdutils.service | 16 -
.../templates/init/openim-crontask.service | 16 -
.../templates/init/openim-msggateway.service | 15 -
.../templates/init/openim-msgtransfer.service | 15 -
.../templates/init/openim-push.service | 16 -
deployments/templates/init/openim-rpc.service | 15 -
deployments/templates/openim.service | 13 +
deployments/templates/openim.target | 7 +
deployments/templates/openim.yaml | 2 +-
docs/contrib/install-openim-linux-system.md | 353 ++++++++++++++++++
docs/conversions/version.md | 92 +++++
go.mod | 10 +
go.sum | 52 ++-
manifest/build-docker.sh | 37 --
manifest/dockerfiles/openim-api/Dockerfile | 27 --
.../dockerfiles/openim-crontask/Dockerfile | 27 --
.../dockerfiles/openim-msggateway/Dockerfile | 27 --
.../dockerfiles/openim-msgtransfer/Dockerfile | 27 --
manifest/dockerfiles/openim-push/Dockerfile | 27 --
.../dockerfiles/openim-rpc-auth/Dockerfile | 27 --
.../openim-rpc-conversation/Dockerfile | 27 --
.../dockerfiles/openim-rpc-friend/Dockerfile | 27 --
.../dockerfiles/openim-rpc-group/Dockerfile | 27 --
.../dockerfiles/openim-rpc-msg/Dockerfile | 27 --
.../dockerfiles/openim-rpc-third/Dockerfile | 27 --
.../dockerfiles/openim-rpc-user/Dockerfile | 27 --
pkg/common/cmd/msg_gateway.go | 14 +-
pkg/common/cmd/root.go | 5 +-
pkg/common/version/base.go | 47 +++
pkg/common/version/types.go | 30 ++
pkg/common/version/version.go | 58 +++
scripts/check-all.sh | 5 +-
scripts/install/environment.sh | 29 +-
scripts/install/install.sh | 63 ++--
scripts/install/openim-api.sh | 53 ++-
scripts/install/openim-crontask.sh | 24 +-
scripts/install/openim-man.sh | 2 +-
scripts/install/openim-msggateway.sh | 17 +-
scripts/install/openim-msgtransfer.sh | 22 +-
scripts/install/openim-push.sh | 19 +-
scripts/install/openim-rpc.sh | 88 ++++-
scripts/install/vimrc | 300 ---------------
scripts/lib/util.sh | 1 +
scripts/make-rules/golang.mk | 1 +
scripts/make-rules/image.mk | 5 +-
scripts/template/head.md.tmpl | 2 +-
scripts/update-generated-docs.sh | 8 +-
tools/infra/go.mod | 8 +
tools/infra/go.sum | 10 +
tools/infra/infra.go | 35 +-
tools/versionchecker/go.mod | 8 +
tools/versionchecker/go.sum | 10 +
tools/versionchecker/versionchecker.go | 73 ++--
184 files changed, 5657 insertions(+), 1647 deletions(-)
create mode 100644 deployments/charts/helmfile.yaml
rename deployments/{openim-server => charts/openim-api}/.helmignore (100%)
create mode 100644 deployments/charts/openim-api/Chart.yaml
rename deployments/{openim-server => charts/openim-api}/LICENSE (100%)
rename deployments/{openim-server => charts/openim-api}/templates/NOTES.txt (76%)
rename deployments/{openim-server => charts/openim-api}/templates/_helpers.tpl (73%)
create mode 100644 deployments/charts/openim-api/templates/app-cm.yaml
create mode 100644 deployments/charts/openim-api/templates/deployment.yaml
rename deployments/{openim-server => charts/openim-api}/templates/hpa.yaml (50%)
rename deployments/{openim-server => charts/openim-api}/templates/ingress.yaml (73%)
create mode 100644 deployments/charts/openim-api/templates/service.yaml
create mode 100644 deployments/charts/openim-api/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-api/values.yaml
create mode 100644 deployments/charts/openim-msggateway/.helmignore
rename deployments/{openim-server => charts/openim-msggateway}/Chart.yaml (51%)
create mode 100644 deployments/charts/openim-msggateway/templates/NOTES.txt
create mode 100644 deployments/charts/openim-msggateway/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-msggateway/templates/deployment.yaml
create mode 100644 deployments/charts/openim-msggateway/templates/hpa.yaml
create mode 100644 deployments/charts/openim-msggateway/templates/ingress.yaml
create mode 100644 deployments/charts/openim-msggateway/templates/service.yaml
create mode 100644 deployments/charts/openim-msggateway/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-msggateway/values.yaml
create mode 100644 deployments/charts/openim-msgtransfer/.helmignore
create mode 100644 deployments/charts/openim-msgtransfer/Chart.yaml
create mode 100644 deployments/charts/openim-msgtransfer/templates/NOTES.txt
create mode 100644 deployments/charts/openim-msgtransfer/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-msgtransfer/templates/deployment.yaml
create mode 100644 deployments/charts/openim-msgtransfer/templates/hpa.yaml
create mode 100644 deployments/charts/openim-msgtransfer/templates/ingress.yaml
create mode 100644 deployments/charts/openim-msgtransfer/templates/service.yaml
create mode 100644 deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml
rename deployments/{openim-server => charts/openim-msgtransfer}/values.yaml (73%)
create mode 100644 deployments/charts/openim-push/.helmignore
create mode 100644 deployments/charts/openim-push/Chart.yaml
create mode 100644 deployments/charts/openim-push/templates/NOTES.txt
create mode 100644 deployments/charts/openim-push/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-push/templates/deployment.yaml
create mode 100644 deployments/charts/openim-push/templates/hpa.yaml
create mode 100644 deployments/charts/openim-push/templates/ingress.yaml
create mode 100644 deployments/charts/openim-push/templates/service.yaml
create mode 100644 deployments/charts/openim-push/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-push/values.yaml
create mode 100644 deployments/charts/openim-rpc-auth/.helmignore
create mode 100644 deployments/charts/openim-rpc-auth/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-auth/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-auth/templates/_helpers.tpl
rename deployments/{openim-server => charts/openim-rpc-auth}/templates/deployment.yaml (55%)
create mode 100644 deployments/charts/openim-rpc-auth/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-auth/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-auth/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-auth/values.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/.helmignore
create mode 100644 deployments/charts/openim-rpc-conversation/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-conversation/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-conversation/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-conversation/values.yaml
create mode 100644 deployments/charts/openim-rpc-friend/.helmignore
create mode 100644 deployments/charts/openim-rpc-friend/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-friend/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-friend/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-friend/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-friend/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-friend/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-friend/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-friend/values.yaml
create mode 100644 deployments/charts/openim-rpc-group/.helmignore
create mode 100644 deployments/charts/openim-rpc-group/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-group/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-group/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-group/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-group/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-group/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-group/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-group/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-group/values.yaml
create mode 100644 deployments/charts/openim-rpc-msg/.helmignore
create mode 100644 deployments/charts/openim-rpc-msg/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-msg/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-msg/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-msg/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-msg/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-msg/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-msg/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-msg/values.yaml
create mode 100644 deployments/charts/openim-rpc-third/.helmignore
create mode 100644 deployments/charts/openim-rpc-third/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-third/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-third/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-third/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-third/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-third/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-third/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-third/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-third/values.yaml
create mode 100644 deployments/charts/openim-rpc-user/.helmignore
create mode 100644 deployments/charts/openim-rpc-user/Chart.yaml
create mode 100644 deployments/charts/openim-rpc-user/templates/NOTES.txt
create mode 100644 deployments/charts/openim-rpc-user/templates/_helpers.tpl
create mode 100644 deployments/charts/openim-rpc-user/templates/deployment.yaml
create mode 100644 deployments/charts/openim-rpc-user/templates/hpa.yaml
create mode 100644 deployments/charts/openim-rpc-user/templates/ingress.yaml
create mode 100644 deployments/charts/openim-rpc-user/templates/service.yaml
create mode 100644 deployments/charts/openim-rpc-user/templates/serviceaccount.yaml
create mode 100644 deployments/charts/openim-rpc-user/values.yaml
delete mode 100644 deployments/openim-server/README.md
delete mode 100644 deployments/openim-server/templates/service.yaml
delete mode 100644 deployments/openim-server/templates/serviceaccount.yaml
create mode 100644 deployments/templates/charts-value.yaml
create mode 100644 deployments/templates/helm-image.yaml
delete mode 100644 deployments/templates/init/README.md
delete mode 100644 deployments/templates/init/openim-api.service
delete mode 100644 deployments/templates/init/openim-cmdutils.service
delete mode 100644 deployments/templates/init/openim-crontask.service
delete mode 100644 deployments/templates/init/openim-msggateway.service
delete mode 100644 deployments/templates/init/openim-msgtransfer.service
delete mode 100644 deployments/templates/init/openim-push.service
delete mode 100644 deployments/templates/init/openim-rpc.service
create mode 100644 deployments/templates/openim.service
create mode 100644 deployments/templates/openim.target
create mode 100644 docs/contrib/install-openim-linux-system.md
delete mode 100755 manifest/build-docker.sh
delete mode 100644 manifest/dockerfiles/openim-api/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-crontask/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-msggateway/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-msgtransfer/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-push/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-auth/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-conversation/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-friend/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-group/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-msg/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-third/Dockerfile
delete mode 100644 manifest/dockerfiles/openim-rpc-user/Dockerfile
create mode 100644 pkg/common/version/base.go
create mode 100644 pkg/common/version/types.go
create mode 100644 pkg/common/version/version.go
delete mode 100644 scripts/install/vimrc
create mode 100644 tools/infra/go.sum
create mode 100644 tools/versionchecker/go.sum
diff --git a/.env b/.env
index 4f684ad77..bcfc0722a 100644
--- a/.env
+++ b/.env
@@ -30,12 +30,19 @@ MINIO_ENDPOINT=http://172.28.0.1:10005
# Base URL for the application programming interface (API).
# Default: API_URL=http://172.28.0.1:10002
-API_URL=http://127.0.0.1:10002
+API_URL=http://172.28.0.1:10002
# Directory path for storing data files or related information.
# Default: DATA_DIR=./
DATA_DIR=./
+# Choose the appropriate image address, the default is GITHUB image,
+# you can choose docker hub, for Chinese users can choose Ali Cloud
+# export IMAGE_REGISTRY="ghcr.io/openimsdk"
+# export IMAGE_REGISTRY="openim"
+# export IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk"
+IMAGE_REGISTRY=ghcr.io/openimsdk
+
# ======================================
# ========= Network Configuration ======
# ======================================
diff --git a/.github/workflows/docker-buildx.yml b/.github/workflows/docker-buildx.yml
index 366317b1c..6113cfae5 100644
--- a/.github/workflows/docker-buildx.yml
+++ b/.github/workflows/docker-buildx.yml
@@ -54,6 +54,19 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Log in to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+
+ - name: Log in to AliYun Docker Hub
+ uses: docker/login-action@v3
+ with:
+ registry: registry.cn-hangzhou.aliyuncs.com
+ username: ${{ secrets.ALIREGISTRY_USERNAME }}
+ password: ${{ secrets.ALIREGISTRY_TOKEN }}
+
################################################
# build/
# └── docker
@@ -89,7 +102,10 @@ jobs:
id: meta1
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-api
+ images: |
+ ghcr.io/openimsdk/openim-api
+ openim/openim-api
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-api
- name: Build and push Docker image for openim-api
uses: docker/build-push-action@v5
@@ -107,7 +123,10 @@ jobs:
id: meta2
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-cmdutils
+ images: |
+ ghcr.io/openimsdk/openim-cmdutils
+ openim/openim-cmdutils
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-cmdutils
- name: Build and push Docker image for openim-cmdutils
uses: docker/build-push-action@v5
@@ -125,7 +144,10 @@ jobs:
id: meta3
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-crontask
+ images: |
+ ghcr.io/openimsdk/openim-crontask
+ openim/openim-crontask
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-crontask
- name: Build and push Docker image for openim-crontask
uses: docker/build-push-action@v5
@@ -143,7 +165,10 @@ jobs:
id: meta4
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-msggateway
+ images: |
+ ghcr.io/openimsdk/openim-msggateway
+ openim/openim-msggateway
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msggateway
- name: Build and push Docker image for openim-msggateway
uses: docker/build-push-action@v5
@@ -161,7 +186,10 @@ jobs:
id: meta5
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-msgtransfer
+ images: |
+ ghcr.io/openimsdk/openim-msgtransfer
+ openim/openim-msgtransfer
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msgtransfer
- name: Build and push Docker image for openim-msgtransfer
uses: docker/build-push-action@v5
@@ -179,7 +207,10 @@ jobs:
id: meta6
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-push
+ images: |
+ ghcr.io/openimsdk/openim-push
+ openim/openim-push
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-push
- name: Build and push Docker image for openim-push
uses: docker/build-push-action@v5
@@ -197,7 +228,10 @@ jobs:
id: meta7
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-auth
+ images: |
+ ghcr.io/openimsdk/openim-rpc-auth
+ openim/openim-rpc-auth
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-auth
- name: Build and push Docker image for openim-rpc-auth
uses: docker/build-push-action@v5
@@ -215,7 +249,10 @@ jobs:
id: meta8
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-conversation
+ images: |
+ ghcr.io/openimsdk/openim-rpc-conversation
+ openim/openim-rpc-conversation
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-conversation
- name: Build and push Docker image for openim-rpc-conversation
uses: docker/build-push-action@v5
@@ -233,7 +270,10 @@ jobs:
id: meta9
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-friend
+ images: |
+ ghcr.io/openimsdk/openim-rpc-friend
+ openim/openim-rpc-friend
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-friend
- name: Build and push Docker image for openim-rpc-friend
uses: docker/build-push-action@v5
@@ -251,7 +291,10 @@ jobs:
id: meta10
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-group
+ images: |
+ ghcr.io/openimsdk/openim-rpc-group
+ openim/openim-rpc-group
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-group
- name: Build and push Docker image for openim-rpc-group
uses: docker/build-push-action@v5
@@ -269,7 +312,10 @@ jobs:
id: meta11
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-msg
+ images: |
+ ghcr.io/openimsdk/openim-rpc-msg
+ openim/openim-rpc-msg
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-msg
- name: Build and push Docker image for openim-rpc-msg
uses: docker/build-push-action@v5
@@ -287,7 +333,10 @@ jobs:
id: meta12
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-third
+ images: |
+ ghcr.io/openimsdk/openim-rpc-third
+ openim/openim-rpc-third
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-third
- name: Build and push Docker image for openim-rpc-third
uses: docker/build-push-action@v5
@@ -305,7 +354,10 @@ jobs:
id: meta13
uses: docker/metadata-action@v5.0.0
with:
- images: ghcr.io/openimsdk/openim-rpc-user
+ images: |
+ ghcr.io/openimsdk/openim-rpc-user
+ openim/openim-rpc-user
+ registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-user
- name: Build and push Docker image for openim-rpc-user
uses: docker/build-push-action@v5
@@ -318,4 +370,3 @@ jobs:
labels: ${{ steps.meta13.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
-
diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml
index 347f6d762..05a8ce5c5 100644
--- a/.github/workflows/openimci.yml
+++ b/.github/workflows/openimci.yml
@@ -170,3 +170,24 @@ jobs:
- name: Print OpenIM Logs
run: sudo cat ./_output/logs/* 2>/dev/null
continue-on-error: true
+
+ openim-build-image:
+ name: Build OpenIM Docker Image
+ runs-on: ubuntu-latest
+ environment:
+ name: openim
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Set up Go ${{ matrix.go_version }}
+ uses: actions/setup-go@v4
+ with:
+ go-version: ${{ matrix.go_version }}
+ id: go
+ - name: Install Task
+ uses: arduino/setup-task@v1
+ with:
+ version: 2.x
+ - name: Test Docker Build
+ run: |
+ sudo make image
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 92408fa56..fa1818e2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@ tmp/
bin/
output/
_output/
+deployments/charts/generated-configs/
### OpenIM Config ###
config/config.yaml
@@ -37,18 +38,7 @@ config/config.yaml
./.env
### OpenIM deploy ###
-deploy/openim_demo
-deploy/openim-api
-deploy/openim-rpc-msg_gateway
-deploy/openim-msgtransfer
-deploy/openim-push
-deploy/openim_timer_task
-deploy/openim-rpc-user
-deploy/openim-rpc-friend
-deploy/openim-rpc-group
-deploy/openim-rpc-msg
-deploy/openim-rpc-auth
-deploy/Open-IM-SDK-Core
+deployments/openim-server/charts
# files used by the developer
.idea.md
diff --git a/.golangci.yml b/.golangci.yml
index dd68ce5a6..b129ffd68 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -715,83 +715,18 @@ linters:
# enable-all: true
disable-all: true
enable:
- - typecheck
- - asciicheck
- - bodyclose
- - cyclop
- # - depguard
- - dogsled
- - dupl
- - durationcheck
- - errcheck
- - errorlint
- - exhaustive
- - exportloopref
- # - forbidigo
- - funlen
- # - gci
- # - gochecknoinits
- - gocognit
- - goconst
- - gocyclo
- - godot
- - godox
- - gofmt
- - gofumpt
- - goheader
- - goimports
- - gomoddirectives
- - gomodguard
- - goprintffuncname
- - gosec
- - gosimple
- - govet
- - importas
- - ineffassign
- - lll
- - makezero
- - misspell
- - nakedret
- - nestif
- - nilerr
- - nlreturn
- - noctx
- - nolintlint
- - paralleltest
- - prealloc
- - predeclared
- - promlinter
- - revive
- - rowserrcheck
- - sqlclosecheck
- - staticcheck
- - stylecheck
- - thelper
- - tparallel
- - unconvert
- - unparam
- - unused
- - wastedassign
- - whitespace
- - bidichk
- - wastedassign
- - execinquery
- - nosprintfhostport
- - grouper
- - decorder
- - errchkjson
- - maintidx
- #- containedctx
- #- tagliatelle
- #- nonamedreturns
- #- nilnil
- #- tenv
- #- varnamelen
- #- contextcheck
- #- errname
- #- ForceTypeAssert
- #- nilassign
- fast: false
+ - typecheck # 基本的类型检查
+ - gofmt # 格式检查
+ - govet # Go 语言的标准检查工具
+ - gosimple # 简化代码的建议
+ - misspell # 拼写错误
+ - staticcheck # 静态检查
+ - unused # 未使用的代码检查
+ - goimports # 检查导入是否正确排序和格式化
+ - godot # 注释句点检查
+ - bodyclose # 确保 HTTP response body 被关闭
+ - errcheck # 检查是否遗漏了错误返回值
+ fast: true
issues:
# List of regexps of issue texts to exclude, empty list by default.
diff --git a/Makefile b/Makefile
index 1d01409a5..1d3544ed6 100644
--- a/Makefile
+++ b/Makefile
@@ -73,9 +73,9 @@ gen:
demo:
@$(MAKE) go.demo
-## versionchecker: Check version of openim. ✨
-.PHONY: versionchecker
-versionchecker:
+## version: Check version of openim. ✨
+.PHONY: version
+version:
@$(MAKE) go.versionchecker
## build: Build binaries by default ✨
@@ -95,7 +95,7 @@ stop:
## restart: Restart openim ✨
.PHONY: restart
-restart: clean stop build init start
+restart: clean stop build init start check
## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨
.PHONY: multiarch
diff --git a/README-zh_CN.md b/README-zh_CN.md
index 8addfe20a..f24ee4739 100644
--- a/README-zh_CN.md
+++ b/README-zh_CN.md
@@ -1,5 +1,5 @@
-
+
@@ -23,7 +23,7 @@
English •
简体中文 •
- Docs
+ Docs
diff --git a/README.md b/README.md
index f58625fb0..dd0a674d2 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
+
@@ -24,7 +24,7 @@
English •
简体中文 •
- Docs
+ Docs
diff --git a/build/goreleaser.yaml b/build/goreleaser.yaml
index d4e28fc2a..ed7f7cd1b 100644
--- a/build/goreleaser.yaml
+++ b/build/goreleaser.yaml
@@ -255,131 +255,6 @@ builds:
- "6"
- "7"
- - binary: infra
- id: infra
- main: ./tools/infra/infra.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: ncpu
- id: ncpu
- main: ./tools/ncpu/ncpu.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: openim-web
- id: openim-web
- main: ./tools/openim-web/openim-web.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: component
- id: component
- main: ./tools/component/component.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: versionchecker
- id: versionchecker
- main: ./tools/versionchecker/versionchecker.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: changelog
- id: changelog
- main: ./tools/changelog/changelog.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
-
- - binary: yamlfmt
- id: yamlfmt
- main: ./tools/yamlfmt/yamlfmt.go
- goos:
- - darwin
- - windows
- - linux
- goarch:
- - s390x
- - mips64
- - mips64le
- - amd64
- - ppc64le
- - arm64
- goarm:
- - "6"
- - "7"
# TODO:Need a script, such as the init - release to help binary to find the right directory
# ,which can be compiled binary
diff --git a/config/config.yaml b/config/config.yaml
index 0f980b4e4..81da293cb 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -19,6 +19,9 @@
# --| target: config/config.yaml
# -----------------------------------------------------------------
+envs:
+ discovery: zookeeper
+
###################### Zookeeper ######################
# Zookeeper configuration
# It's not recommended to modify the schema
@@ -26,9 +29,6 @@
# Zookeeper address
# Zookeeper username
# Zookeeper password
-envs:
- discovery: zookeeper
-
zookeeper:
schema: openim
address: [ 172.28.0.1:12181 ]
@@ -168,7 +168,6 @@ rpcPort:
openImUserPort: [ 10110 ]
openImFriendPort: [ 10120 ]
openImMessagePort: [ 10130 ]
- openImMessageGatewayPort: [ 10140 ]
openImGroupPort: [ 10150 ]
openImAuthPort: [ 10160 ]
openImPushPort: [ 10170 ]
@@ -199,7 +198,7 @@ rpcRegisterName:
# Whether to output in json format
# Whether to include stack trace in logs
log:
- storageLocation: ../../logs/
+ storageLocation: ../logs/
rotationTime: 24
remainRotationCount: 2
remainLogLevel: 6
@@ -216,8 +215,8 @@ log:
# Websocket connection handshake timeout
longConnSvr:
openImWsPort: [ 10001 ]
- openImMessageGatewayPort: [ 10140 ]
websocketMaxConnNum: 100000
+ openImMessageGatewayPort: [ 10140 ]
websocketMaxMsgLen: 4096
websocketTimeout: 10
diff --git a/deployments/README.md b/deployments/README.md
index e070d8e1f..a36ab4cdb 100644
--- a/deployments/README.md
+++ b/deployments/README.md
@@ -1,52 +1,48 @@
-# OpenIM 应用容器化部署指南
+# OpenIM Application Containerization Deployment Guide
-OpenIM 支持很多种集群化部署方式,包括但不限于 helm, sealos, kubeam, kubesphere, kubeflow, kuboard, kubespray, k3s, k3d, k3c, k3sup, k3v, k3x
+OpenIM supports a variety of cluster deployment methods, including but not limited to `helm`, `sealos`, `kustomize`
-**目前还在开发这个模块,预计 v3.2.0 之前会有一个集群方案。**
+Various contributors, as well as previous official releases, have provided some referenceable solutions:
-目前各个贡献者,以及之前的官方有出过一些可以参考的方案:
++ [k8s-jenkins Repository](https://github.com/OpenIMSDK/k8s-jenkins)
++ [open-im-server-k8s-deploy Repository](https://github.com/openimsdk/open-im-server-k8s-deploy)
++ [openim-charts Repository](https://github.com/OpenIMSDK/openim-charts)
++ [deploy-openim Repository](https://github.com/showurl/deploy-openim)
-- https://github.com/OpenIMSDK/k8s-jenkins
-- https://github.com/openimsdk/open-im-server-k8s-deploy
-- https://github.com/OpenIMSDK/openim-charts
-- https://github.com/showurl/deploy-openim
-
-
-### 依赖检查
+### Dependency Check
```bash
Kubernetes: >= 1.16.0-0
Helm: >= 3.0
```
+### Minimum Configuration
-### 最低配置
-
-建议生产环境的最低配置如下:
+The recommended minimum configuration for a production environment is as follows:
-```bash
+```yaml
CPU: 4
Memory: 8G
Disk: 100G
```
-## 生成配置文件
+## Configuration File Generation
-我们将自动文件全部自动化处理了,所以生成配置文件对于 openim 来说是可选的,但是如果你想要自定义配置,可以参考下面的步骤:
+We have automated all the files, making the generation of configuration files optional for OpenIM. However, if you desire custom configurations, you can follow the steps below:
```bash
$ make init
-# 或者是使用脚本:
+# Alternatively, use script:
# ./scripts/init-config.sh
```
-此时会帮你在 `deployments/openim/config` 目录下生成配置文件,你可以根据自己的需求进行修改。
+At this point, configuration files will be generated under `deployments/openim/config`, which you can modify as per your requirements.
-## 集群搭建
+## Cluster Setup
-如果你已经有了一个 `kubernetes` 集群,或者是你希望自己从头开始搭建一个 `kubernetes` 那么你可以直接跳过这一步。
+If you already have a `kubernetes` cluster, or if you wish to build a `kubernetes` cluster from scratch, you can skip this step.
-为了快速开始,我使用 [sealos](https://github.com/labring/sealos) 来快速搭建集群,sealos 底层也是对 kubeadm 的封装:
+For a quick start, I used [sealos](https://github.com/labring/sealos) to rapidly set up the cluster, with sealos also being a wrapper for kubeadm at its core:
```bash
$ SEALOS_VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/latest | grep -oE '"tag_name": "[^"]+"' | head -n1 | cut -d'"' -f4` && \
@@ -54,21 +50,20 @@ $ SEALOS_VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/l
sh -s ${SEALOS_VERSION} labring/sealos
```
-**支持的版本:**
+**Supported Versions:**
+ docker: `labring/kubernetes-docker`:(v1.24.0~v1.27.0)
+ containerd: `labring/kubernetes`:(v1.24.0~v1.27.0)
+#### Cluster Installation:
-#### 安装集群:
-
-集群的信息如下:
+Cluster details are as follows:
-| 机器名 | IP地址 | 系统信息 |
-|---------|-----------------|------------------------------------------------------------------------------------------------------------|
-| master01| 10.0.0.9 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
-| node01 | 10.0.0.4 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
-| node02 | 10.0.0.10 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux |
+| Hostname | IP Address | System Info |
+| -------- | ---------- | ------------------------------------------------------------ |
+| master01 | 10.0.0.9 | `Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux` |
+| node01 | 10.0.0.4 | Similar to master01 |
+| node02 | 10.0.0.10 | Similar to master01 |
```bash
$ export CLUSTER_USERNAME=ubuntu
@@ -80,40 +75,79 @@ $ sudo sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:
-p "$CLUSTER_PASSWORD"
```
-> **Node**
-> 卸载的方式:使用 `kubeadm` 卸载并不会清除 `etcd` 和 `cni` 相关,所以需要手动清除,或者使用 `sealos` 卸载。
+> **Node** Uninstallation method: using `kubeadm` for uninstallation does not remove `etcd` and `cni` related configurations. Manual clearance or using `sealos` for uninstallation is needed.
+>
> ```bash
-> sealos reset
+> $ sealos reset
> ```
-### 安装 helm
+If you are local, you can also use Kind and Minikube to test, for example, using Kind:
-helm通过打包的方式,支持发布的版本管理和控制,很大程度上简化了Kubernetes应用的部署和管理。
+```bash
+$ sGO111MODULE="on" go get sigs.k8s.io/kind@v0.11.1
+$ skind create cluster
+```
+
+### Installing helm
+Helm simplifies the deployment and management of Kubernetes applications to a large extent by offering version control and release management through packaging.
-**使用脚本:**
+**Using Script:**
```bash
$ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
```
-**添加仓库:**
+**Adding Repository:**
```bash
$ helm repo add brigade https://openimsdk.github.io/openim-charts
```
-### OpenIM 的镜像策略
+### OpenIM Image Strategy
-自动化提供的 aliyun, ghcr, docker hub: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md
+Automated offerings include aliyun, ghcr, docker hub: [Image Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md)
-**本地化测试构建方法:**
+**Local Test Build Method:**
```bash
$ make image
```
+> This command assists in quickly building the required images locally. For a detailed build strategy, refer to the [Build Documentation](https://github.com/openimsdk/open-im-server/blob/main/build/README.md).
+
+## Installation
+
+Explore our Helm-Charts repository and read through: [Helm-Charts Repository](https://github.com/openimsdk/helm-charts)
-### 容器化安装
-具体安装步骤如下:
+Using the helm charts repository, you can ignore the following configuration, but if you want to just use the server and scale on top of it, you can go ahead:
+
+**Use Helmfile:**
+
+```bash
+GO111MODULE=on go get github.com/roboll/helmfile@latest
+```
+
+```bash
+export MYSQL_ADDRESS=im-mysql
+export MYSQL_PORT=3306
+export MONGO_ADDRESS=im-mongo
+export MONGO_PORT=27017
+export REDIS_ADDRESS=im-redis-master
+export REDIS_PORT=6379
+export KAFKA_ADDRESS=im-kafka
+export KAFKA_PORT=9092
+export OBJECT_APIURL="https://openim.server.com/api"
+export MINIO_ENDPOINT="http://im-minio:9000"
+export MINIO_SIGN_ENDPOINT="https://openim.server.com/im-minio-api"
+
+mkdir ./charts/generated-configs
+../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/openim.yaml > ./charts/generated-configs/config.yaml
+cp ../config/notification.yaml ./charts/generated-configs/notification.yaml
+../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml
+```
+
+```bash
+helmfile apply
+```
\ No newline at end of file
diff --git a/deployments/charts/helmfile.yaml b/deployments/charts/helmfile.yaml
new file mode 100644
index 000000000..a6a009257
--- /dev/null
+++ b/deployments/charts/helmfile.yaml
@@ -0,0 +1,20 @@
+{{- define "defaultValues" -}}
+- ./generated-configs/helm-image.yaml
+- ./generated-configs/config.yaml
+- ./generated-configs/notification.yaml
+{{- end -}}
+
+{{- define "defaultRelease" -}}
+namespace: openim
+chart: ./{{ .name }}
+values:
+ - ./{{ .name }}/values.yaml
+ {{- template "defaultValues" . }}
+{{- end -}}
+
+releases:
+{{- $apps := list "openim-api" "openim-msggateway" "openim-msgtransfer" "openim-push" "openim-rpc-auth" "openim-rpc-conversation" "openim-rpc-friend" "openim-rpc-group" "openim-rpc-msg" "openim-rpc-third" "openim-rpc-user" }}
+{{- range $app := $apps }}
+ - name: {{ $app }}
+ {{- template "defaultRelease" dict "name" $app }}
+{{- end }}
diff --git a/deployments/openim-server/.helmignore b/deployments/charts/openim-api/.helmignore
similarity index 100%
rename from deployments/openim-server/.helmignore
rename to deployments/charts/openim-api/.helmignore
diff --git a/deployments/charts/openim-api/Chart.yaml b/deployments/charts/openim-api/Chart.yaml
new file mode 100644
index 000000000..74779b64a
--- /dev/null
+++ b/deployments/charts/openim-api/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-api
+description: A OpenIM Api Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/openim-server/LICENSE b/deployments/charts/openim-api/LICENSE
similarity index 100%
rename from deployments/openim-server/LICENSE
rename to deployments/charts/openim-api/LICENSE
diff --git a/deployments/openim-server/templates/NOTES.txt b/deployments/charts/openim-api/templates/NOTES.txt
similarity index 76%
rename from deployments/openim-server/templates/NOTES.txt
rename to deployments/charts/openim-api/templates/NOTES.txt
index edb391088..e9ce81bdb 100644
--- a/deployments/openim-server/templates/NOTES.txt
+++ b/deployments/charts/openim-api/templates/NOTES.txt
@@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
- export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-server.fullname" . }})
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-api.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
- You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-server.fullname" . }}'
- export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-api.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-api.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
- export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-api.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
diff --git a/deployments/openim-server/templates/_helpers.tpl b/deployments/charts/openim-api/templates/_helpers.tpl
similarity index 73%
rename from deployments/openim-server/templates/_helpers.tpl
rename to deployments/charts/openim-api/templates/_helpers.tpl
index 79f4ebd6a..f137492f1 100644
--- a/deployments/openim-server/templates/_helpers.tpl
+++ b/deployments/charts/openim-api/templates/_helpers.tpl
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
-{{- define "openim-server.name" -}}
+{{- define "openim-api.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
@@ -10,7 +10,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
-{{- define "openim-server.fullname" -}}
+{{- define "openim-api.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
@@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
-{{- define "openim-server.chart" -}}
+{{- define "openim-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
-{{- define "openim-server.labels" -}}
-helm.sh/chart: {{ include "openim-server.chart" . }}
-{{ include "openim-server.selectorLabels" . }}
+{{- define "openim-api.labels" -}}
+helm.sh/chart: {{ include "openim-api.chart" . }}
+{{ include "openim-api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
@@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
-{{- define "openim-server.selectorLabels" -}}
-app.kubernetes.io/name: {{ include "openim-server.name" . }}
+{{- define "openim-api.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
-{{- define "openim-server.serviceAccountName" -}}
+{{- define "openim-api.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
-{{- default (include "openim-server.fullname" .) .Values.serviceAccount.name }}
+{{- default (include "openim-api.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
diff --git a/deployments/charts/openim-api/templates/app-cm.yaml b/deployments/charts/openim-api/templates/app-cm.yaml
new file mode 100644
index 000000000..7a6f23314
--- /dev/null
+++ b/deployments/charts/openim-api/templates/app-cm.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: openim-cm
+data:
+ config.yaml: |+
+ {{- with .Values.config }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+ notification.yaml: |+
+ {{- with .Values.notification }}
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
diff --git a/deployments/charts/openim-api/templates/deployment.yaml b/deployments/charts/openim-api/templates/deployment.yaml
new file mode 100644
index 000000000..182d90cdc
--- /dev/null
+++ b/deployments/charts/openim-api/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-api.fullname" . }}
+ labels:
+ {{- include "openim-api.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-api.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-api.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-api.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/openim-server/templates/hpa.yaml b/deployments/charts/openim-api/templates/hpa.yaml
similarity index 50%
rename from deployments/openim-server/templates/hpa.yaml
rename to deployments/charts/openim-api/templates/hpa.yaml
index c7726c969..0e5848181 100644
--- a/deployments/openim-server/templates/hpa.yaml
+++ b/deployments/charts/openim-api/templates/hpa.yaml
@@ -1,29 +1,15 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
- name: {{ include "openim-server.fullname" . }}
+ name: {{ include "openim-api.fullname" . }}
labels:
- {{- include "openim-server.labels" . | nindent 4 }}
+ {{- include "openim-api.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
- name: {{ include "openim-server.fullname" . }}
+ name: {{ include "openim-api.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
diff --git a/deployments/openim-server/templates/ingress.yaml b/deployments/charts/openim-api/templates/ingress.yaml
similarity index 73%
rename from deployments/openim-server/templates/ingress.yaml
rename to deployments/charts/openim-api/templates/ingress.yaml
index c269ecc26..62c66c135 100644
--- a/deployments/openim-server/templates/ingress.yaml
+++ b/deployments/charts/openim-api/templates/ingress.yaml
@@ -1,19 +1,5 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
{{- if .Values.ingress.enabled -}}
-{{- $fullName := include "openim-server.fullname" . -}}
+{{- $fullName := include "openim-api.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
@@ -31,7 +17,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
- {{- include "openim-server.labels" . | nindent 4 }}
+ {{- include "openim-api.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
diff --git a/deployments/charts/openim-api/templates/service.yaml b/deployments/charts/openim-api/templates/service.yaml
new file mode 100644
index 000000000..eb37fa56c
--- /dev/null
+++ b/deployments/charts/openim-api/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-api.fullname" . }}
+ labels:
+ {{- include "openim-api.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-api.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-api/templates/serviceaccount.yaml b/deployments/charts/openim-api/templates/serviceaccount.yaml
new file mode 100644
index 000000000..e3e7b2849
--- /dev/null
+++ b/deployments/charts/openim-api/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-api.serviceAccountName" . }}
+ labels:
+ {{- include "openim-api.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-api/values.yaml b/deployments/charts/openim-api/values.yaml
new file mode 100644
index 000000000..e41fb6e76
--- /dev/null
+++ b/deployments/charts/openim-api/values.yaml
@@ -0,0 +1,86 @@
+# Default values for openim-api.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-api
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: "nginx"
+ annotations:
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
+
+notification:
+
+config:
diff --git a/deployments/charts/openim-msggateway/.helmignore b/deployments/charts/openim-msggateway/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-msggateway/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/openim-server/Chart.yaml b/deployments/charts/openim-msggateway/Chart.yaml
similarity index 51%
rename from deployments/openim-server/Chart.yaml
rename to deployments/charts/openim-msggateway/Chart.yaml
index 22a95940a..c8c380bf9 100644
--- a/deployments/openim-server/Chart.yaml
+++ b/deployments/charts/openim-msggateway/Chart.yaml
@@ -1,19 +1,5 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
apiVersion: v2
-name: openim-server
+name: openim-msggateway
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
@@ -35,7 +21,7 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
-appVersion: "default"
+appVersion: "1.16.0"
icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
@@ -50,25 +36,4 @@ keywords:
sources:
- "https://github.com/openimsdk/open-im-server"
- - "https://github.com/openimsdk/openim-sdk-core"
- - "https://github.com/openimsdk/openim-docker"
-
-dependencies:
- - name: mysql
- version: 8.0.25
- repository: https://charts.bitnami.com/bitnami
- - name: redis
- version: 14.6.1
- repository: https://charts.bitnami.com/bitnami
- - name: mongodb
- version: 10.1.0
- repository: https://charts.bitnami.com/bitnami
- - name: kafka
- version: 14.1.0
- repository: https://charts.bitnami.com/bitnami
- - name: minio
- version: 8.1.2
- repository: https://charts.bitnami.com/bitnami
- - name: zookeeper
- version: 5.17.0
- repository: https://charts.bitnami.com/bitnami
\ No newline at end of file
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-msggateway/templates/NOTES.txt b/deployments/charts/openim-msggateway/templates/NOTES.txt
new file mode 100644
index 000000000..c1f032586
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-msggateway.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-msggateway.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-msggateway.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-msggateway.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-msggateway/templates/_helpers.tpl b/deployments/charts/openim-msggateway/templates/_helpers.tpl
new file mode 100644
index 000000000..c902a1b30
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-msggateway.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-msggateway.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-msggateway.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-msggateway.labels" -}}
+helm.sh/chart: {{ include "openim-msggateway.chart" . }}
+{{ include "openim-msggateway.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-msggateway.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-msggateway.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-msggateway.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-msggateway.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msggateway/templates/deployment.yaml b/deployments/charts/openim-msggateway/templates/deployment.yaml
new file mode 100644
index 000000000..bc2f45a33
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/deployment.yaml
@@ -0,0 +1,75 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-msggateway.fullname" . }}
+ labels:
+ {{- include "openim-msggateway.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-msggateway.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-msggateway.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-msggateway.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ - name: rpc
+ containerPort: 88
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-msggateway/templates/hpa.yaml b/deployments/charts/openim-msggateway/templates/hpa.yaml
new file mode 100644
index 000000000..e1fbe50a6
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-msggateway.fullname" . }}
+ labels:
+ {{- include "openim-msggateway.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-msggateway.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msggateway/templates/ingress.yaml b/deployments/charts/openim-msggateway/templates/ingress.yaml
new file mode 100644
index 000000000..5c1c24078
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-msggateway.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-msggateway.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msggateway/templates/service.yaml b/deployments/charts/openim-msggateway/templates/service.yaml
new file mode 100644
index 000000000..2ed58a869
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/service.yaml
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-msggateway.fullname" . }}
+ labels:
+ {{- include "openim-msggateway.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ - port: 88
+ targetPort: rpc
+ protocol: TCP
+ name: rpc
+ selector:
+ {{- include "openim-msggateway.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-msggateway/templates/serviceaccount.yaml b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml
new file mode 100644
index 000000000..6b47c12c5
--- /dev/null
+++ b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-msggateway.serviceAccountName" . }}
+ labels:
+ {{- include "openim-msggateway.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msggateway/values.yaml b/deployments/charts/openim-msggateway/values.yaml
new file mode 100644
index 000000000..d82c674fc
--- /dev/null
+++ b/deployments/charts/openim-msggateway/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-msggateway.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-msggateway
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: "nginx"
+ annotations:
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-msgtransfer/.helmignore b/deployments/charts/openim-msgtransfer/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-msgtransfer/Chart.yaml b/deployments/charts/openim-msgtransfer/Chart.yaml
new file mode 100644
index 000000000..bba7a047f
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-msgtransfer
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-msgtransfer/templates/NOTES.txt b/deployments/charts/openim-msgtransfer/templates/NOTES.txt
new file mode 100644
index 000000000..a9876065d
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-msgtransfer.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-msgtransfer.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-msgtransfer.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-msgtransfer.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-msgtransfer/templates/_helpers.tpl b/deployments/charts/openim-msgtransfer/templates/_helpers.tpl
new file mode 100644
index 000000000..39f7a9acf
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-msgtransfer.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-msgtransfer.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-msgtransfer.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-msgtransfer.labels" -}}
+helm.sh/chart: {{ include "openim-msgtransfer.chart" . }}
+{{ include "openim-msgtransfer.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-msgtransfer.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-msgtransfer.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-msgtransfer.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-msgtransfer.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msgtransfer/templates/deployment.yaml b/deployments/charts/openim-msgtransfer/templates/deployment.yaml
new file mode 100644
index 000000000..b63b74dc4
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-msgtransfer.fullname" . }}
+ labels:
+ {{- include "openim-msgtransfer.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-msgtransfer.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-msgtransfer.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-msgtransfer.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-msgtransfer/templates/hpa.yaml b/deployments/charts/openim-msgtransfer/templates/hpa.yaml
new file mode 100644
index 000000000..75c7d4fef
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-msgtransfer.fullname" . }}
+ labels:
+ {{- include "openim-msgtransfer.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-msgtransfer.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msgtransfer/templates/ingress.yaml b/deployments/charts/openim-msgtransfer/templates/ingress.yaml
new file mode 100644
index 000000000..c9968a438
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-msgtransfer.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-msgtransfer.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-msgtransfer/templates/service.yaml b/deployments/charts/openim-msgtransfer/templates/service.yaml
new file mode 100644
index 000000000..839e520e5
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-msgtransfer.fullname" . }}
+ labels:
+ {{- include "openim-msgtransfer.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-msgtransfer.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml
new file mode 100644
index 000000000..2e3ca4ee7
--- /dev/null
+++ b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-msgtransfer.serviceAccountName" . }}
+ labels:
+ {{- include "openim-msgtransfer.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/openim-server/values.yaml b/deployments/charts/openim-msgtransfer/values.yaml
similarity index 73%
rename from deployments/openim-server/values.yaml
rename to deployments/charts/openim-msgtransfer/values.yaml
index 99bddb99b..d4a792d17 100644
--- a/deployments/openim-server/values.yaml
+++ b/deployments/charts/openim-msgtransfer/values.yaml
@@ -1,25 +1,11 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Default values for openim-server.
+# Default values for openim-msgtransfer.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
- repository: nginx
+ repository: ghcr.io/openimsdk/openim-msgtransfer
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
@@ -30,7 +16,7 @@ fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
- create: true
+ create: false
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
diff --git a/deployments/charts/openim-push/.helmignore b/deployments/charts/openim-push/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-push/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-push/Chart.yaml b/deployments/charts/openim-push/Chart.yaml
new file mode 100644
index 000000000..93e134879
--- /dev/null
+++ b/deployments/charts/openim-push/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-push
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
diff --git a/deployments/charts/openim-push/templates/NOTES.txt b/deployments/charts/openim-push/templates/NOTES.txt
new file mode 100644
index 000000000..625c39050
--- /dev/null
+++ b/deployments/charts/openim-push/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-push.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-push.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-push.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-push.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-push/templates/_helpers.tpl b/deployments/charts/openim-push/templates/_helpers.tpl
new file mode 100644
index 000000000..050428471
--- /dev/null
+++ b/deployments/charts/openim-push/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-push.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-push.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-push.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-push.labels" -}}
+helm.sh/chart: {{ include "openim-push.chart" . }}
+{{ include "openim-push.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-push.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-push.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-push.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-push.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-push/templates/deployment.yaml b/deployments/charts/openim-push/templates/deployment.yaml
new file mode 100644
index 000000000..4a646ba0e
--- /dev/null
+++ b/deployments/charts/openim-push/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-push.fullname" . }}
+ labels:
+ {{- include "openim-push.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-push.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-push.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-push.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-push/templates/hpa.yaml b/deployments/charts/openim-push/templates/hpa.yaml
new file mode 100644
index 000000000..89c89c041
--- /dev/null
+++ b/deployments/charts/openim-push/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-push.fullname" . }}
+ labels:
+ {{- include "openim-push.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-push.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-push/templates/ingress.yaml b/deployments/charts/openim-push/templates/ingress.yaml
new file mode 100644
index 000000000..b00fda3d3
--- /dev/null
+++ b/deployments/charts/openim-push/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-push.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-push.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-push/templates/service.yaml b/deployments/charts/openim-push/templates/service.yaml
new file mode 100644
index 000000000..4d8bb0457
--- /dev/null
+++ b/deployments/charts/openim-push/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-push.fullname" . }}
+ labels:
+ {{- include "openim-push.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-push.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-push/templates/serviceaccount.yaml b/deployments/charts/openim-push/templates/serviceaccount.yaml
new file mode 100644
index 000000000..e22115724
--- /dev/null
+++ b/deployments/charts/openim-push/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-push.serviceAccountName" . }}
+ labels:
+ {{- include "openim-push.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-push/values.yaml b/deployments/charts/openim-push/values.yaml
new file mode 100644
index 000000000..dd6f0faf6
--- /dev/null
+++ b/deployments/charts/openim-push/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-push.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-push
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-auth/.helmignore b/deployments/charts/openim-rpc-auth/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-auth/Chart.yaml b/deployments/charts/openim-rpc-auth/Chart.yaml
new file mode 100644
index 000000000..97848dbf2
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-auth
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-rpc-auth/templates/NOTES.txt b/deployments/charts/openim-rpc-auth/templates/NOTES.txt
new file mode 100644
index 000000000..220602077
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-auth.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-auth.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-auth.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-auth.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-auth/templates/_helpers.tpl b/deployments/charts/openim-rpc-auth/templates/_helpers.tpl
new file mode 100644
index 000000000..cb6575872
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-auth.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-auth.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-auth.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-auth.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-auth.chart" . }}
+{{ include "openim-rpc-auth.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-auth.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-auth.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-auth.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-auth.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/openim-server/templates/deployment.yaml b/deployments/charts/openim-rpc-auth/templates/deployment.yaml
similarity index 55%
rename from deployments/openim-server/templates/deployment.yaml
rename to deployments/charts/openim-rpc-auth/templates/deployment.yaml
index 9c630e89a..a5df44ead 100644
--- a/deployments/openim-server/templates/deployment.yaml
+++ b/deployments/charts/openim-rpc-auth/templates/deployment.yaml
@@ -1,30 +1,16 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
apiVersion: apps/v1
kind: Deployment
metadata:
- name: {{ include "openim-server.fullname" . }}
+ name: {{ include "openim-rpc-auth.fullname" . }}
labels:
- {{- include "openim-server.labels" . | nindent 4 }}
+ {{- include "openim-rpc-auth.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
- {{- include "openim-server.selectorLabels" . | nindent 6 }}
+ {{- include "openim-rpc-auth.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
@@ -32,13 +18,13 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
- {{- include "openim-server.selectorLabels" . | nindent 8 }}
+ {{- include "openim-rpc-auth.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
- serviceAccountName: {{ include "openim-server.serviceAccountName" . }}
+ serviceAccountName: {{ include "openim-rpc-auth.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
@@ -51,16 +37,27 @@ spec:
- name: http
containerPort: 80
protocol: TCP
- livenessProbe:
- httpGet:
- path: /
- port: http
- readinessProbe:
- httpGet:
- path: /
- port: http
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
diff --git a/deployments/charts/openim-rpc-auth/templates/hpa.yaml b/deployments/charts/openim-rpc-auth/templates/hpa.yaml
new file mode 100644
index 000000000..20108afbf
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-auth.fullname" . }}
+ labels:
+ {{- include "openim-rpc-auth.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-auth.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-auth/templates/ingress.yaml b/deployments/charts/openim-rpc-auth/templates/ingress.yaml
new file mode 100644
index 000000000..f14458c52
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-auth.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-auth.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-auth/templates/service.yaml b/deployments/charts/openim-rpc-auth/templates/service.yaml
new file mode 100644
index 000000000..ef7b00b86
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-auth.fullname" . }}
+ labels:
+ {{- include "openim-rpc-auth.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-auth.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml
new file mode 100644
index 000000000..f13dcca81
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-auth.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-auth.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-auth/values.yaml b/deployments/charts/openim-rpc-auth/values.yaml
new file mode 100644
index 000000000..a6db6716c
--- /dev/null
+++ b/deployments/charts/openim-rpc-auth/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-auth.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-auth
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-conversation/.helmignore b/deployments/charts/openim-rpc-conversation/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-conversation/Chart.yaml b/deployments/charts/openim-rpc-conversation/Chart.yaml
new file mode 100644
index 000000000..090d63127
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-conversation
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
diff --git a/deployments/charts/openim-rpc-conversation/templates/NOTES.txt b/deployments/charts/openim-rpc-conversation/templates/NOTES.txt
new file mode 100644
index 000000000..287f2fd64
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-conversation.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-conversation.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-conversation.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-conversation.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl b/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl
new file mode 100644
index 000000000..184271057
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-conversation.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-conversation.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-conversation.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-conversation.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-conversation.chart" . }}
+{{ include "openim-rpc-conversation.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-conversation.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-conversation.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-conversation.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-conversation.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/deployment.yaml b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml
new file mode 100644
index 000000000..5cc8dc2aa
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-conversation.fullname" . }}
+ labels:
+ {{- include "openim-rpc-conversation.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-conversation.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-conversation.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-conversation.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/hpa.yaml b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml
new file mode 100644
index 000000000..a2378bfa0
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-conversation.fullname" . }}
+ labels:
+ {{- include "openim-rpc-conversation.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-conversation.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/ingress.yaml b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml
new file mode 100644
index 000000000..224591f67
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-conversation.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-conversation.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/service.yaml b/deployments/charts/openim-rpc-conversation/templates/service.yaml
new file mode 100644
index 000000000..be8355154
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-conversation.fullname" . }}
+ labels:
+ {{- include "openim-rpc-conversation.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-conversation.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml
new file mode 100644
index 000000000..4e2d0e29f
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-conversation.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-conversation.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-conversation/values.yaml b/deployments/charts/openim-rpc-conversation/values.yaml
new file mode 100644
index 000000000..1b3e1e3de
--- /dev/null
+++ b/deployments/charts/openim-rpc-conversation/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-conversation.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-conversation
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-friend/.helmignore b/deployments/charts/openim-rpc-friend/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-friend/Chart.yaml b/deployments/charts/openim-rpc-friend/Chart.yaml
new file mode 100644
index 000000000..d7e4a9fef
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-friend
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
diff --git a/deployments/charts/openim-rpc-friend/templates/NOTES.txt b/deployments/charts/openim-rpc-friend/templates/NOTES.txt
new file mode 100644
index 000000000..004ee5c5e
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-friend.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-friend.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-friend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-friend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-friend/templates/_helpers.tpl b/deployments/charts/openim-rpc-friend/templates/_helpers.tpl
new file mode 100644
index 000000000..83719fb31
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-friend.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-friend.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-friend.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-friend.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-friend.chart" . }}
+{{ include "openim-rpc-friend.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-friend.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-friend.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-friend.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-friend.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-friend/templates/deployment.yaml b/deployments/charts/openim-rpc-friend/templates/deployment.yaml
new file mode 100644
index 000000000..a99d541dd
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-friend.fullname" . }}
+ labels:
+ {{- include "openim-rpc-friend.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-friend.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-friend.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-friend.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-friend/templates/hpa.yaml b/deployments/charts/openim-rpc-friend/templates/hpa.yaml
new file mode 100644
index 000000000..7c4f14b7c
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-friend.fullname" . }}
+ labels:
+ {{- include "openim-rpc-friend.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-friend.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-friend/templates/ingress.yaml b/deployments/charts/openim-rpc-friend/templates/ingress.yaml
new file mode 100644
index 000000000..b5d411743
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-friend.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-friend.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-friend/templates/service.yaml b/deployments/charts/openim-rpc-friend/templates/service.yaml
new file mode 100644
index 000000000..792592d87
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-friend.fullname" . }}
+ labels:
+ {{- include "openim-rpc-friend.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-friend.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml
new file mode 100644
index 000000000..c81343f6b
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-friend.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-friend.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-friend/values.yaml b/deployments/charts/openim-rpc-friend/values.yaml
new file mode 100644
index 000000000..041665a81
--- /dev/null
+++ b/deployments/charts/openim-rpc-friend/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-friend.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-friend
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-group/.helmignore b/deployments/charts/openim-rpc-group/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-group/Chart.yaml b/deployments/charts/openim-rpc-group/Chart.yaml
new file mode 100644
index 000000000..8e037caea
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-group
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-rpc-group/templates/NOTES.txt b/deployments/charts/openim-rpc-group/templates/NOTES.txt
new file mode 100644
index 000000000..0cc117a49
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-group.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-group.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-group.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-group.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-group/templates/_helpers.tpl b/deployments/charts/openim-rpc-group/templates/_helpers.tpl
new file mode 100644
index 000000000..7835b84e1
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-group.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-group.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-group.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-group.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-group.chart" . }}
+{{ include "openim-rpc-group.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-group.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-group.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-group.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-group.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-group/templates/deployment.yaml b/deployments/charts/openim-rpc-group/templates/deployment.yaml
new file mode 100644
index 000000000..872c49ccb
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-group.fullname" . }}
+ labels:
+ {{- include "openim-rpc-group.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-group.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-group.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-group.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-group/templates/hpa.yaml b/deployments/charts/openim-rpc-group/templates/hpa.yaml
new file mode 100644
index 000000000..0ba0e8283
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-group.fullname" . }}
+ labels:
+ {{- include "openim-rpc-group.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-group.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-group/templates/ingress.yaml b/deployments/charts/openim-rpc-group/templates/ingress.yaml
new file mode 100644
index 000000000..6a744f914
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-group.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-group.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-group/templates/service.yaml b/deployments/charts/openim-rpc-group/templates/service.yaml
new file mode 100644
index 000000000..aa16f71b9
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-group.fullname" . }}
+ labels:
+ {{- include "openim-rpc-group.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-group.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml
new file mode 100644
index 000000000..b42dfb13b
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-group.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-group.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-group/values.yaml b/deployments/charts/openim-rpc-group/values.yaml
new file mode 100644
index 000000000..ec36e256f
--- /dev/null
+++ b/deployments/charts/openim-rpc-group/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-group.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-group
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-msg/.helmignore b/deployments/charts/openim-rpc-msg/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-msg/Chart.yaml b/deployments/charts/openim-rpc-msg/Chart.yaml
new file mode 100644
index 000000000..659767484
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-msg
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-rpc-msg/templates/NOTES.txt b/deployments/charts/openim-rpc-msg/templates/NOTES.txt
new file mode 100644
index 000000000..65033b107
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-msg.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-msg.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-msg.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-msg.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-msg/templates/_helpers.tpl b/deployments/charts/openim-rpc-msg/templates/_helpers.tpl
new file mode 100644
index 000000000..da6956822
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-msg.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-msg.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-msg.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-msg.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-msg.chart" . }}
+{{ include "openim-rpc-msg.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-msg.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-msg.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-msg.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-msg.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-msg/templates/deployment.yaml b/deployments/charts/openim-rpc-msg/templates/deployment.yaml
new file mode 100644
index 000000000..a4da7e2b4
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-msg.fullname" . }}
+ labels:
+ {{- include "openim-rpc-msg.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-msg.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-msg.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-msg.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-msg/templates/hpa.yaml b/deployments/charts/openim-rpc-msg/templates/hpa.yaml
new file mode 100644
index 000000000..c01e07294
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-msg.fullname" . }}
+ labels:
+ {{- include "openim-rpc-msg.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-msg.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-msg/templates/ingress.yaml b/deployments/charts/openim-rpc-msg/templates/ingress.yaml
new file mode 100644
index 000000000..2f5ad9d15
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-msg.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-msg.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-msg/templates/service.yaml b/deployments/charts/openim-rpc-msg/templates/service.yaml
new file mode 100644
index 000000000..9afd55a8c
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-msg.fullname" . }}
+ labels:
+ {{- include "openim-rpc-msg.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-msg.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml
new file mode 100644
index 000000000..da69e5ce8
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-msg.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-msg.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-msg/values.yaml b/deployments/charts/openim-rpc-msg/values.yaml
new file mode 100644
index 000000000..22cfd61f1
--- /dev/null
+++ b/deployments/charts/openim-rpc-msg/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-msg.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-msg
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-third/.helmignore b/deployments/charts/openim-rpc-third/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-third/Chart.yaml b/deployments/charts/openim-rpc-third/Chart.yaml
new file mode 100644
index 000000000..d7763d70a
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-third
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-rpc-third/templates/NOTES.txt b/deployments/charts/openim-rpc-third/templates/NOTES.txt
new file mode 100644
index 000000000..a2228c84d
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-third.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-third.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-third.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-third.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-third/templates/_helpers.tpl b/deployments/charts/openim-rpc-third/templates/_helpers.tpl
new file mode 100644
index 000000000..46039ce2c
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-third.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-third.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-third.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-third.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-third.chart" . }}
+{{ include "openim-rpc-third.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-third.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-third.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-third.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-third.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-third/templates/deployment.yaml b/deployments/charts/openim-rpc-third/templates/deployment.yaml
new file mode 100644
index 000000000..07bac7fcf
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-third.fullname" . }}
+ labels:
+ {{- include "openim-rpc-third.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-third.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-third.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-third.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-third/templates/hpa.yaml b/deployments/charts/openim-rpc-third/templates/hpa.yaml
new file mode 100644
index 000000000..2197e21a5
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-third.fullname" . }}
+ labels:
+ {{- include "openim-rpc-third.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-third.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-third/templates/ingress.yaml b/deployments/charts/openim-rpc-third/templates/ingress.yaml
new file mode 100644
index 000000000..3ba50cf33
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-third.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-third.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-third/templates/service.yaml b/deployments/charts/openim-rpc-third/templates/service.yaml
new file mode 100644
index 000000000..866b5cda2
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-third.fullname" . }}
+ labels:
+ {{- include "openim-rpc-third.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-third.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml
new file mode 100644
index 000000000..8a45872ce
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-third.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-third.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-third/values.yaml b/deployments/charts/openim-rpc-third/values.yaml
new file mode 100644
index 000000000..8a92566a9
--- /dev/null
+++ b/deployments/charts/openim-rpc-third/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-third.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-third
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/charts/openim-rpc-user/.helmignore b/deployments/charts/openim-rpc-user/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/.helmignore
@@ -0,0 +1,23 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/charts/openim-rpc-user/Chart.yaml b/deployments/charts/openim-rpc-user/Chart.yaml
new file mode 100644
index 000000000..7a2118e46
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/Chart.yaml
@@ -0,0 +1,39 @@
+apiVersion: v2
+name: openim-rpc-user
+description: A Helm chart for Kubernetes
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "1.16.0"
+
+icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg
+
+maintainers:
+ - name: "OpenIM"
+ url: "https://github.com/openimsdk"
+
+keywords:
+ - openim
+ - im
+ - chat
+
+sources:
+ - "https://github.com/openimsdk/open-im-server"
+ - "https://github.com/openimsdk/helm-charts"
\ No newline at end of file
diff --git a/deployments/charts/openim-rpc-user/templates/NOTES.txt b/deployments/charts/openim-rpc-user/templates/NOTES.txt
new file mode 100644
index 000000000..9928bd162
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/NOTES.txt
@@ -0,0 +1,22 @@
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-user.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-user.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-user.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
+ echo http://$SERVICE_IP:{{ .Values.service.port }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-user.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
+{{- end }}
diff --git a/deployments/charts/openim-rpc-user/templates/_helpers.tpl b/deployments/charts/openim-rpc-user/templates/_helpers.tpl
new file mode 100644
index 000000000..473f66556
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "openim-rpc-user.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "openim-rpc-user.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "openim-rpc-user.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "openim-rpc-user.labels" -}}
+helm.sh/chart: {{ include "openim-rpc-user.chart" . }}
+{{ include "openim-rpc-user.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "openim-rpc-user.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "openim-rpc-user.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "openim-rpc-user.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "openim-rpc-user.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-user/templates/deployment.yaml b/deployments/charts/openim-rpc-user/templates/deployment.yaml
new file mode 100644
index 000000000..4517f9b72
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/deployment.yaml
@@ -0,0 +1,72 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "openim-rpc-user.fullname" . }}
+ labels:
+ {{- include "openim-rpc-user.labels" . | nindent 4 }}
+spec:
+ {{- if not .Values.autoscaling.enabled }}
+ replicas: {{ .Values.replicaCount }}
+ {{- end }}
+ selector:
+ matchLabels:
+ {{- include "openim-rpc-user.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ {{- with .Values.podAnnotations }}
+ annotations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "openim-rpc-user.selectorLabels" . | nindent 8 }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "openim-rpc-user.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ ports:
+ - name: http
+ containerPort: 80
+ protocol: TCP
+ #livenessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ #readinessProbe:
+ # httpGet:
+ # path: /
+ # port: http
+ resources:
+ {{- toYaml .Values.resources | nindent 12 }}
+ volumeMounts:
+ - mountPath: /config/config.yaml
+ name: config
+ subPath: config.yaml
+ - mountPath: /config/notification.yaml
+ name: config
+ subPath: notification.yaml
+ volumes:
+ - name: config
+ configMap:
+ name: openim-cm
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/deployments/charts/openim-rpc-user/templates/hpa.yaml b/deployments/charts/openim-rpc-user/templates/hpa.yaml
new file mode 100644
index 000000000..7c00c9d64
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/hpa.yaml
@@ -0,0 +1,28 @@
+{{- if .Values.autoscaling.enabled }}
+apiVersion: autoscaling/v2beta1
+kind: HorizontalPodAutoscaler
+metadata:
+ name: {{ include "openim-rpc-user.fullname" . }}
+ labels:
+ {{- include "openim-rpc-user.labels" . | nindent 4 }}
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: {{ include "openim-rpc-user.fullname" . }}
+ minReplicas: {{ .Values.autoscaling.minReplicas }}
+ maxReplicas: {{ .Values.autoscaling.maxReplicas }}
+ metrics:
+ {{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: cpu
+ targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
+ {{- end }}
+ {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ - type: Resource
+ resource:
+ name: memory
+ targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-user/templates/ingress.yaml b/deployments/charts/openim-rpc-user/templates/ingress.yaml
new file mode 100644
index 000000000..7ed5a0328
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/ingress.yaml
@@ -0,0 +1,61 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "openim-rpc-user.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
+ {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
+ {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
+ {{- end }}
+{{- end }}
+{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1
+{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "openim-rpc-user.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
+ ingressClassName: {{ .Values.ingress.className }}
+ {{- end }}
+ {{- if .Values.ingress.tls }}
+ tls:
+ {{- range .Values.ingress.tls }}
+ - hosts:
+ {{- range .hosts }}
+ - {{ . | quote }}
+ {{- end }}
+ secretName: {{ .secretName }}
+ {{- end }}
+ {{- end }}
+ rules:
+ {{- range .Values.ingress.hosts }}
+ - host: {{ .host | quote }}
+ http:
+ paths:
+ {{- range .paths }}
+ - path: {{ .path }}
+ {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
+ pathType: {{ .pathType }}
+ {{- end }}
+ backend:
+ {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
+ service:
+ name: {{ $fullName }}
+ port:
+ number: {{ $svcPort }}
+ {{- else }}
+ serviceName: {{ $fullName }}
+ servicePort: {{ $svcPort }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-user/templates/service.yaml b/deployments/charts/openim-rpc-user/templates/service.yaml
new file mode 100644
index 000000000..728c5de92
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "openim-rpc-user.fullname" . }}
+ labels:
+ {{- include "openim-rpc-user.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ selector:
+ {{- include "openim-rpc-user.selectorLabels" . | nindent 4 }}
diff --git a/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml
new file mode 100644
index 000000000..d3395f00d
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "openim-rpc-user.serviceAccountName" . }}
+ labels:
+ {{- include "openim-rpc-user.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+{{- end }}
diff --git a/deployments/charts/openim-rpc-user/values.yaml b/deployments/charts/openim-rpc-user/values.yaml
new file mode 100644
index 000000000..d137f0ad7
--- /dev/null
+++ b/deployments/charts/openim-rpc-user/values.yaml
@@ -0,0 +1,82 @@
+# Default values for openim-rpc-user.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+ repository: ghcr.io/openimsdk/openim-rpc-user
+ pullPolicy: IfNotPresent
+ # Overrides the image tag whose default is the chart appVersion.
+ tag: ""
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ # Specifies whether a service account should be created
+ create: false
+ # Annotations to add to the service account
+ annotations: {}
+ # The name of the service account to use.
+ # If not set and create is true, a name is generated using the fullname template
+ name: ""
+
+podAnnotations: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # readOnlyRootFilesystem: true
+ # runAsNonRoot: true
+ # runAsUser: 1000
+
+service:
+ type: ClusterIP
+ port: 80
+
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # kubernetes.io/ingress.class: nginx
+ # kubernetes.io/tls-acme: "true"
+ hosts:
+ - host: chart-example.local
+ paths:
+ - path: /
+ pathType: ImplementationSpecific
+ tls: []
+ # - secretName: chart-example-tls
+ # hosts:
+ # - chart-example.local
+
+resources: {}
+ # We usually recommend not to specify default resources and to leave this as a conscious
+ # choice for the user. This also increases chances charts run on environments with little
+ # resources, such as Minikube. If you do want to specify resources, uncomment the following
+ # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
+ # limits:
+ # cpu: 100m
+ # memory: 128Mi
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+
+autoscaling:
+ enabled: false
+ minReplicas: 1
+ maxReplicas: 100
+ targetCPUUtilizationPercentage: 80
+ # targetMemoryUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
diff --git a/deployments/openim-server/README.md b/deployments/openim-server/README.md
deleted file mode 100644
index dd6eb759a..000000000
--- a/deployments/openim-server/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# OpenIM Server Chat
-
-## 目录结构
-
-```bash
-openim-server/
- Chart.yaml # 包含了chart信息的YAML文件
- LICENSE # 包含OpenIM Chart许可证的纯文本文件
- README.md # OpenIM 可读的README文件
- values.yaml # chart 默认的配置值
- charts/ # 包含chart依赖的其他chart
- crds/ # 自定义资源的定义
- templates/ # 模板目录, 当和values 结合时,可生成有效的Kubernetes manifest文件
- templates/NOTES.txt # 包含简要使用说明的纯文本文件
-```
\ No newline at end of file
diff --git a/deployments/openim-server/templates/service.yaml b/deployments/openim-server/templates/service.yaml
deleted file mode 100644
index a12825bfb..000000000
--- a/deployments/openim-server/templates/service.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-apiVersion: v1
-kind: Service
-metadata:
- name: {{ include "openim-server.fullname" . }}
- labels:
- {{- include "openim-server.labels" . | nindent 4 }}
-spec:
- type: {{ .Values.service.type }}
- ports:
- - port: {{ .Values.service.port }}
- targetPort: http
- protocol: TCP
- name: http
- selector:
- {{- include "openim-server.selectorLabels" . | nindent 4 }}
diff --git a/deployments/openim-server/templates/serviceaccount.yaml b/deployments/openim-server/templates/serviceaccount.yaml
deleted file mode 100644
index 6e31d9c83..000000000
--- a/deployments/openim-server/templates/serviceaccount.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-{{- if .Values.serviceAccount.create -}}
-apiVersion: v1
-kind: ServiceAccount
-metadata:
- name: {{ include "openim-server.serviceAccountName" . }}
- labels:
- {{- include "openim-server.labels" . | nindent 4 }}
- {{- with .Values.serviceAccount.annotations }}
- annotations:
- {{- toYaml . | nindent 4 }}
- {{- end }}
-{{- end }}
diff --git a/deployments/templates/charts-value.yaml b/deployments/templates/charts-value.yaml
new file mode 100644
index 000000000..274d9b8d1
--- /dev/null
+++ b/deployments/templates/charts-value.yaml
@@ -0,0 +1,96 @@
+#This configuration file is used to override the use of the value.yaml variable.
+#Currently, only the configuration with ingressName as nginx is provided.
+#If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements
+
+global:
+ commonRepository: ghcr.io/openimsdk
+ commonTag: "latest"
+ pullPolicy: Always
+
+openim-api:
+ image:
+ repository: ghcr.io/openimsdk/openim-api
+ pullPolicy: Always
+ tag: "latest"
+ ingress:
+ enabled: true
+ className: "nginx"
+ annotations:
+ nginx.ingress.kubernetes.io/use-regex: "true"
+ nginx.ingress.kubernetes.io/rewrite-target: /$2
+ hosts:
+ - host: openim.server.com # your hostname
+ paths:
+ - path: /api(/|$)(.*)
+ pathType: ImplementationSpecific
+ tls:
+ - secretName: webapitls #your hostname tls
+ hosts:
+ - openim.server.com
+
+openim-msggateway:
+ image:
+ repository: ghcr.io/openimsdk/openim-msggateway
+ tag: "latest"
+ pullPolicy: Always
+ ingress:
+ enabled: true
+ className: "nginx"
+ annotations:
+ nginx.ingress.kubernetes.io/use-regex: "true"
+ nginx.ingress.kubernetes.io/rewrite-target: /$2
+ hosts:
+ - host: openim.server.com # your hostname
+ paths:
+ - path: /msg_gateway(/|$)(.*)
+ pathType: ImplementationSpecific
+ tls:
+ - secretName: webapitls #your hostname tls
+ hosts:
+ - openim.server.com
+
+openim-msgtransfer:
+ image:
+ repository: ghcr.io/openimsdk/openim-msgtransfer
+ tag: "latest"
+ pullPolicy: Always
+openim-push:
+ image:
+ repository: ghcr.io/openimsdk/openim-push
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-auth:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-auth
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-conversation:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-conversation
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-friend:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-friend
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-group:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-group
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-msg:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-msg
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-third:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-third
+ tag: "latest"
+ pullPolicy: Always
+openim-rpc-user:
+ image:
+ repository: ghcr.io/openimsdk/openim-rpc-user
+ tag: "latest"
+ pullPolicy: Always
diff --git a/deployments/templates/helm-image.yaml b/deployments/templates/helm-image.yaml
new file mode 100644
index 000000000..317bc34ac
--- /dev/null
+++ b/deployments/templates/helm-image.yaml
@@ -0,0 +1,89 @@
+#This configuration file is used to override the use of the value.yaml variable.
+#Currently, only the configuration with ingressName as nginx is provided.
+#If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements
+image:
+ repository: ${IMAGE_REGISTRY}/openim-api
+ pullPolicy: Always
+ tag: "${SERVER_IMAGE_TAG}"
+ingress:
+ enabled: true
+ className: "nginx"
+ annotations:
+ nginx.ingress.kubernetes.io/use-regex: "true"
+ nginx.ingress.kubernetes.io/rewrite-target: /$2
+ hosts:
+ - host: openim.server.com # your hostname
+ paths:
+ - path: /api(/|$)(.*)
+ pathType: ImplementationSpecific
+ tls:
+ - secretName: webapitls #your hostname tls
+ hosts:
+ - openim.server.com
+
+openim-msggateway:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-msggateway
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+ ingress:
+ enabled: true
+ className: "nginx"
+ annotations:
+ nginx.ingress.kubernetes.io/use-regex: "true"
+ nginx.ingress.kubernetes.io/rewrite-target: /$2
+ hosts:
+ - host: openim.server.com # your hostname
+ paths:
+ - path: /msg_gateway(/|$)(.*)
+ pathType: ImplementationSpecific
+ tls:
+ - secretName: webapitls #your hostname tls
+ hosts:
+ - openim.server.com
+
+openim-msgtransfer:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-msgtransfer
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-push:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-push
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-auth:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-auth
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-conversation:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-conversation
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-friend:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-friend
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-group:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-group
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-msg:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-msg
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-third:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-third
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
+openim-rpc-user:
+ image:
+ repository: ${IMAGE_REGISTRY}/openim-rpc-user
+ tag: "${SERVER_IMAGE_TAG}"
+ pullPolicy: Always
\ No newline at end of file
diff --git a/deployments/templates/init/README.md b/deployments/templates/init/README.md
deleted file mode 100644
index b9957dadc..000000000
--- a/deployments/templates/init/README.md
+++ /dev/null
@@ -1,220 +0,0 @@
-# Systemd Configuration, Installation, and Startup
-
-- [Systemd Configuration, Installation, and Startup](#systemd-configuration-installation-and-startup)
- - [1. Introduction](#1-introduction)
- - [2. Prerequisites (Requires root permissions)](#2-prerequisites-requires-root-permissions)
- - [3. Create `openim-api` systemd unit template file](#3-create-openim-api-systemd-unit-template-file)
- - [4. Copy systemd unit template file to systemd config directory (Requires root permissions)](#4-copy-systemd-unit-template-file-to-systemd-config-directory-requires-root-permissions)
- - [5. Start systemd service](#5-start-systemd-service)
-
-## 1. Introduction
-
-Systemd is the default service management form for the latest Linux distributions, replacing the original init.
-
-Format introduction:
-
-```bash
-[Unit] : Unit of the service
-
-Description: Brief description of the service
-
-[Service]: Configuration of the service's runtime behavior
-
-ExecStart: Complete path of the program
-
-Restart: Restart configurations like no, always, on-success, on-failure, on-abnormal, on-abort, on-watchdog
-
-[Install]: Installation configuration
-
-WantedBy: Multi-user, etc.
-```
-
-For more details, refer to: [Systemd Service Manual](https://www.freedesktop.org/software/systemd/man/systemd.service.html)
-
-Starting command:
-
-```bash
-systemctl daemon-reload && systemctl enable openim-api && systemctl restart openim-api
-```
-
-Service status:
-
-```bash
-systemctl status openim-api
-```
-
-Stop command:
-
-```bash
-systemctl stop openim-api
-```
-
-More command:
-```bash
-# 列出正在运行的Unit,可以直接使用systemctl
-systemctl list-units
-
-# 列出所有Unit,包括没有找到配置文件的或者启动失败的
-systemctl list-units --all
-
-# 列出所有没有运行的 Unit
-systemctl list-units --all --state=inactive
-
-# 列出所有加载失败的 Unit
-systemctl list-units --failed
-
-# 列出所有正在运行的、类型为service的Unit
-systemctl list-units --type=service
-
-# 显示某个 Unit 是否正在运行
-systemctl is-active application.service
-
-# 显示某个 Unit 是否处于启动失败状态
-systemctl is-failed application.service
-
-# 显示某个 Unit 服务是否建立了启动链接
-systemctl is-enabled application.service
-
-# 立即启动一个服务
-sudo systemctl start apache.service
-
-# 立即停止一个服务
-sudo systemctl stop apache.service
-
-# 重启一个服务
-sudo systemctl restart apache.service
-
-# 重新加载一个服务的配置文件
-sudo systemctl reload apache.service
-
-# 重载所有修改过的配置文件
-sudo systemctl daemon-reload
-```
-
-**Why choose systemd?**
-
-**Advanced requirements:**
-
-- Convenient service runtime log recording for problem analysis
-- Service management logs
-- Option to restart upon abnormal exit
-
-The daemon does not meet these advanced requirements.
-
-`nohup` only logs the service's runtime outputs and errors.
-
-Only systemd can fulfill all of the above requirements.
-
-> The default logs are enhanced with timestamps, usernames, service names, PIDs, etc., making them user-friendly. You can view logs of abnormal service exits. Advanced customization is possible through the configuration files in `/lib/systemd/system/`.
-
-In short, systemd is the current mainstream way to manage backend services on Linux, so I've abandoned `nohup` in my new versions of bash scripts, opting instead for systemd.
-
-## 2. Prerequisites (Requires root permissions)
-
-1. Configure `environment.sh` based on the comments.
-2. Create a data directory:
-
-```bash
-mkdir -p ${OPENIM_DATA_DIR}/{openim-api,openim-crontask}
-```
-
-3. Create a bin directory and copy `openim-api` and `openim-crontask` executable files:
-
-```bash
-source ./environment.sh
-mkdir -p ${OPENIM_INSTALL_DIR}/bin
-cp openim-api openim-crontask ${OPENIM_INSTALL_DIR}/bin
-```
-
-4. Copy the configuration files of `openim-api` and `openim-crontask` to the `${OPENIM_CONFIG_DIR}` directory:
-
-```bash
-mkdir -p ${OPENIM_CONFIG_DIR}
-cp openim-api.yaml openim-crontask.yaml ${OPENIM_CONFIG_DIR}
-```
-
-## 3. Create `openim-api` systemd unit template file
-
-For each OpenIM service, we will create a systemd unit template. Follow the steps below for each service:
-
-Run the following shell script to generate the `openim-api.service.template`:
-
-```bash
-source ./environment.sh
-cat > openim-api.service.template < $service.service.template <
+* 1. [1. Introduction](#Introduction)
+* 2. [2. Prerequisites (Requires root permissions)](#PrerequisitesRequiresrootpermissions)
+* 3. [3. Create `openim-api` systemd unit template file](#Createopenim-apisystemdunittemplatefile)
+* 4. [4. Copy systemd unit template file to systemd config directory (Requires root permissions)](#CopysystemdunittemplatefiletosystemdconfigdirectoryRequiresrootpermissions)
+* 5. [5. Start systemd service](#Startsystemdservice)
+
+
+## 0. 0. Introduction
+
+Systemd is the default service management form for the latest Linux distributions, replacing the original init.
+
+The OpenIM system is a comprehensive suite of services tailored to address a wide variety of messaging needs. This guide will walk you through the steps of setting up the OpenIM system services and provide insights into its usage.
+
+**Prerequisites:**
+
++ A Linux server with necessary privileges.
++ Ensure you have `systemctl` installed and running.
+
+
+## 1. 1. Deployment
+
+1. **Retrieve the Installation Script**:
+
+ Begin by obtaining the OpenIM installation script which will be utilized to deploy the entire OpenIM system.
+
+2. **Install OpenIM**:
+
+ To install all the components of OpenIM, run:
+
+ ```bash
+ ./scripts/install/install.sh -i
+ ```
+
+ or
+
+ ```bash
+ ./scripts/install/install.sh --install
+ ```
+
+ This will initiate the installation process for all OpenIM components.
+
+3. **Check the Status**:
+
+ Post installation, it is good practice to verify if all the services are running as expected:
+
+ ```bash
+ systemctl status openim.target
+ ```
+
+ This will list the status of all related services of OpenIM.
+
+**Maintenance & Management:**
+
+1. **Checking Individual Service Status**:
+
+ You can monitor the status of individual services with the following command:
+
+ ```bash
+ systemctl status
+ ```
+
+ For instance:
+
+ ```bash
+ systemctl status openim-api.service
+ ``
+
+2. **Starting and Stopping Services**:
+
+ If you wish to start or stop any specific service, you can do so with `systemctl start` or `systemctl stop` followed by the service name:
+
+ ```bash
+ systemctl start openim-api.service
+ systemctl stop openim-api.service
+ ```
+
+3. **Uninstalling OpenIM**:
+
+ In case you wish to remove the OpenIM components from your server, utilize:
+
+ ```bash
+ ./scripts/install/install.sh -u
+ ```
+
+ or
+
+ ```bash
+ ./scripts/install/install.sh --uninstall
+ ```
+
+ Ensure you take a backup of any important data before executing the uninstall command.
+
+4. **Logs & Troubleshooting**:
+
+ Logs play a pivotal role in understanding the system's operation and troubleshooting any issues. OpenIM logs can typically be found in the directory specified during installation, usually `${OPENIM_LOG_DIR}`.
+
+ Always refer to the logs when troubleshooting. Look for any error messages or warnings that might give insights into the issue at hand.
+
+
+**Note:**
+
++ `openim-api.service`: Manages the main API gateways for OpenIM communication.
++ `openim-crontask.service`: Manages scheduled tasks and jobs.
++ `openim-msggateway.service`: Takes care of message gateway operations.
++ `openim-msgtransfer.service`: Handles message transfer functionalities.
++ `openim-push.service`: Responsible for push notification services.
++ `openim-rpc-auth.service`: Manages RPC (Remote Procedure Call) for authentication.
++ `openim-rpc-conversation.service`: Manages RPC for conversations.
++ `openim-rpc-friend.service`: Handles RPC for friend-related operations.
++ `openim-rpc-group.service`: Manages group-related RPC operations.
++ `openim-rpc-msg.service`: Takes care of message RPCs.
++ `openim-rpc-third.service`: Deals with third-party integrations using RPC.
++ `openim-rpc-user.service`: Manages user-related RPC operations.
++ `openim.target`: A target that bundles all the above services for collective operations.
+
+
+**Viewing Logs with `journalctl`:**
+
+`systemctl` services usually log their output to the systemd journal, which you can access using the `journalctl` command.
+
+1. **View Logs for a Specific Service**:
+
+ To view the logs for a particular service, you can use:
+
+ ```bash
+ journalctl -u
+ ```
+
+ For example, to see the logs for the `openim-api.service`, you would use:
+
+ ```bash
+ journalctl -u openim-api.service
+ ```
+
+2. **Filtering Logs**:
+
+ + By Time
+
+ : If you wish to see logs since a specific time:
+
+ ```bash
+ journalctl -u openim-api.service --since "2023-10-28 12:00:00"
+ ```
+
+ + Most Recent Logs
+
+ : To view the most recent logs, you can combine
+`tail` functionality with `journalctl`:
+
+ ```bash
+ journalctl -u openim-api.service -n 100
+ ```
+
+3. **Continuous Monitoring of Logs**:
+
+ To see new log messages in real-time, you can use the `-f` flag, which mimics the behavior of `tail -f`:
+
+ ```bash
+ journalctl -u openim-api.service -f
+ ```
+
+### Continued Maintenance:
+
+1. **Regularly Check Service Status**:
+
+ It's good practice to routinely verify that all services are active and running. This can be done with:
+
+ ```bash
+ systemctl status openim-api.service openim-push.service openim-rpc-group.service openim-crontask.service openim-rpc-auth.service openim-rpc-msg.service openim-msggateway.service openim-rpc-conversation.service openim-rpc-third.service openim-msgtransfer.service openim-rpc-friend.service openim-rpc-user.service
+ ```
+
+2. **Update Services**:
+
+ Periodically, there might be updates or patches to the OpenIM system or its components. Make sure you keep the system updated. After updating any service, always reload the daemon and restart the service:
+
+ ```bash
+ systemctl daemon-reload
+ systemctl restart openim-api.service
+ ```
+
+3. **Backup Important Data**:
+
+ Regularly backup any configuration files, user data, and other essential data. This ensures that you can restore the system to a working state in case of failures.
+
+### Important `systemctl` and Logging Commands to Learn:
+
+1. **Start/Stop/Restart Services**:
+
+ ```bash
+ systemctl start
+ systemctl stop
+ systemctl restart
+ ```
+
+2. **Enable/Disable Services**:
+
+ If you want a service to start automatically at boot:
+
+ ```bash
+ systemctl enable
+ ```
+
+ To prevent it from starting at boot:
+
+ ```bash
+ systemctl disable
+ ```
+
+3. **Check Failed Services**:
+
+ To quickly check if any service has failed:
+
+ ```bash
+ systemctl --failed
+ ```
+
+4. **Log Rotation**:
+
+ `journalctl` logs can grow large. To clear all archived journal entries, use:
+
+ ```bash
+ journalctl --vacuum-time=1d
+ ```
+
+
+**Advanced requirements:**
+
+- Convenient service runtime log recording for problem analysis
+- Service management logs
+- Option to restart upon abnormal exit
+
+The daemon does not meet these advanced requirements.
+
+`nohup` only logs the service's runtime outputs and errors.
+
+Only systemd can fulfill all of the above requirements.
+
+> The default logs are enhanced with timestamps, usernames, service names, PIDs, etc., making them user-friendly. You can view logs of abnormal service exits. Advanced customization is possible through the configuration files in `/lib/systemd/system/`.
+
+In short, systemd is the current mainstream way to manage backend services on Linux, so I've abandoned `nohup` in my new versions of bash scripts, opting instead for systemd.
+
+## 2. Prerequisites (Requires root permissions)
+
+1. Configure `environment.sh` based on the comments.
+2. Create a data directory:
+
+```bash
+mkdir -p ${OPENIM_DATA_DIR}/{openim-api,openim-crontask}
+```
+
+3. Create a bin directory and copy `openim-api` and `openim-crontask` executable files:
+
+```bash
+source ./environment.sh
+mkdir -p ${OPENIM_INSTALL_DIR}/bin
+cp openim-api openim-crontask ${OPENIM_INSTALL_DIR}/bin
+```
+
+4. Copy the configuration files of `openim-api` and `openim-crontask` to the `${OPENIM_CONFIG_DIR}` directory:
+
+```bash
+mkdir -p ${OPENIM_CONFIG_DIR}
+cp openim-api.yaml openim-crontask.yaml ${OPENIM_CONFIG_DIR}
+```
+
+## 3. Create `openim-api` systemd unit template file
+
+For each OpenIM service, we will create a systemd unit template. Follow the steps below for each service:
+
+Run the following shell script to generate the `openim-api.service.template`:
+
+```bash
+source ./environment.sh
+cat > openim-api.service.template < $service.service.template <Copy systemd unit template file to systemd config directory (Requires root permissions)
+
+Ensure you have root permissions to perform this operation:
+
+```bash
+for service in "${services[@]}"
+do
+ sudo cp $service.service.template /etc/systemd/system/$service.service
+done
+...
+```
+
+## 5. Start systemd service
+
+To start the OpenIM services:
+
+```bash
+for service in "${services[@]}"
+do
+ sudo systemctl daemon-reload
+ sudo systemctl enable $service
+ sudo systemctl restart $service
+done
+```
diff --git a/docs/conversions/version.md b/docs/conversions/version.md
index 0980eaa27..95f736be4 100644
--- a/docs/conversions/version.md
+++ b/docs/conversions/version.md
@@ -7,6 +7,7 @@
- [Tag Management: The Cornerstone of Version Control](#tag-management-the-cornerstone-of-version-control)
- [Release Management: A Guided Tour](#release-management-a-guided-tour)
- [Milestones, Branching, and Addressing Major Bugs](#milestones-branching-and-addressing-major-bugs)
+ - [Version Skew Policy](#version-skew-policy)
- [Applying Principles: A Git Workflow Example](#applying-principles-a-git-workflow-example)
- [Docker Images Version Management](#docker-images-version-management)
@@ -77,6 +78,97 @@ When dealing with major bugs, we selectively merge the fix into the affected ver
We reinforce our approach to branch management and versioning with stringent testing protocols. Automated tests and code review sessions form vital components of maintaining a robust and reliable codebase.
+## Version Skew Policy
+
+This document describes the maximum version skew supported between various openim components. Specific cluster deployment tools may place additional restrictions on version skew.
+
+
+### Supported version skew
+
+In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version.
+
+### OpenIM Versioning, Branching, and Tag Strategy
+
+Similar to Kubernetes, OpenIM has a strict versioning, branching, and tag strategy to ensure compatibility among its various services and components. This document outlines the policies, especially focusing on the version skew supported between OpenIM's components. Given that the current version is v3.3, the policy references will be centered around this version.
+
+#### Supported Version Skew
+
+##### openim-api
+
+In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version.
+
+Example:
+
++ Newest `openim-api` is at v3.3
++ Other `openim-api` instances are supported at v3.3 and v3.2
+
+##### openim-rpc-* Components
+
+All `openim-rpc-*` components (e.g., `openim-rpc-auth`, `openim-rpc-conversation`, etc.) should adhere to the following rules:
+
+1. They must not be newer than `openim-api`.
+2. They may be up to one minor version older than `openim-api`.
+
+Example:
+
++ `openim-api` is at v3.3
++ All `openim-rpc-*` components are supported at v3.3 and v3.2
+
+Note: If version skew exists between `openim-api` instances in an HA cluster, this narrows the allowed `openim-rpc-*` components versions.
+
+##### Other OpenIM Services
+
+Other OpenIM services such as `openim-cmdutils`, `openim-crontask`, `openim-msggateway`, etc. should adhere to the following rules:
+
+1. These services must not be newer than `openim-api`.
+2. They are expected to match the `openim-api` minor version but may be up to one minor version older (to allow live upgrades).
+
+Example:
+
++ `openim-api` is at v3.3
++ `openim-msggateway`, `openim-cmdutils`, and other services are supported at v3.3 and v3.2
+
+#### Supported Component Upgrade Order
+
+The version skew policy has implications on the order in which components should be upgraded. Below is the recommended order to transition an existing cluster from version v3.2 to v3.3:
+
+##### openim-api
+
+Pre-requisites:
+
+1. In a single-instance cluster, the existing `openim-api` instance is v3.2.
+2. In an HA cluster, all `openim-api` instances are at v3.2 or v3.3.
+3. All `openim-rpc-*` and other OpenIM services communicating with this server are at version v3.2.
+
+Upgrade Procedure:
+
+1. Upgrade `openim-api` to v3.3.
+
+##### openim-rpc-* Components
+
+Pre-requisites:
+
+1. The `openim-api` instances these components communicate with are at v3.3.
+
+Upgrade Procedure:
+
+2. Upgrade all `openim-rpc-*` components to v3.3.
+
+##### Other OpenIM Services
+
+Pre-requisites:
+
+1. The `openim-api` instances these services communicate with are at v3.3.
+
+Upgrade Procedure:
+
+2. Upgrade other OpenIM services such as `openim-msggateway`, `openim-cmdutils`, etc., to v3.3.
+
+#### Conclusion
+
+Just like Kubernetes, it's essential for OpenIM to have a strict versioning and upgrade policy to ensure seamless operation and compatibility among its various services. Adhering to the policies outlined above will help in achieving this goal.
+
+
## Applying Principles: A Git Workflow Example
The workflow to address a bug fix might follow these steps:
diff --git a/go.mod b/go.mod
index 4d4ed879b..82e38e8e3 100644
--- a/go.mod
+++ b/go.mod
@@ -44,6 +44,7 @@ require (
github.com/go-sql-driver/mysql v1.7.1
github.com/redis/go-redis/v9 v9.2.1
github.com/tencentyun/cos-go-sdk-v5 v0.7.45
+ gopkg.in/src-d/go-git.v4 v4.13.1
)
require (
@@ -65,6 +66,7 @@ require (
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
+ github.com/emirpasic/gods v1.12.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
@@ -79,6 +81,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
@@ -87,6 +90,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
+ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
@@ -94,6 +98,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
+ github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
@@ -108,8 +113,11 @@ require (
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/xid v1.5.0 // indirect
+ github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
+ github.com/src-d/gcfg v1.4.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+ github.com/xanzy/ssh-agent v0.2.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
@@ -129,6 +137,8 @@ require (
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
+ gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
+ gopkg.in/warnings.v0 v0.1.2 // indirect
)
require (
diff --git a/go.sum b/go.sum
index 0dd6cc940..c64fc8d68 100644
--- a/go.sum
+++ b/go.sum
@@ -20,11 +20,17 @@ github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
github.com/OpenIMSDK/protocol v0.0.30 h1:MiHO6PyQMR9ojBHNnSFxCHLmsoE2xZqaiYj975JiZnM=
github.com/OpenIMSDK/protocol v0.0.30/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
-github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
-github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
+github.com/OpenIMSDK/tools v0.0.15 h1:FF3m0TQUG56pJC15a11jmBG6Y1EjXarEW4JV3CBF/Jc=
+github.com/OpenIMSDK/tools v0.0.15/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
+github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
+github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible h1:Sg/2xHwDrioHpxTN6WMiwbXTpUEinBpHsN7mG21Rc2k=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
@@ -49,6 +55,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -65,10 +72,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
+github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
@@ -79,6 +89,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
+github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
+github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
@@ -165,6 +177,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
@@ -177,6 +191,7 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
+github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
@@ -186,6 +201,8 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
+github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
@@ -195,7 +212,11 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
@@ -217,6 +238,8 @@ github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurw
github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4=
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
@@ -246,10 +269,12 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
+github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ=
github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -273,13 +298,18 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
+github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -301,6 +331,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
+github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
@@ -326,7 +358,9 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -351,6 +385,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
@@ -379,7 +414,9 @@ golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -401,6 +438,7 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -417,6 +455,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
@@ -464,12 +503,21 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
+gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
+gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
+gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
+gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
+gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/manifest/build-docker.sh b/manifest/build-docker.sh
deleted file mode 100755
index 648e6370d..000000000
--- a/manifest/build-docker.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-IMAGEHUB="registry.cn-shenzhen.aliyuncs.com/huanglin_hub"
-PROJECT=$1
-ALLPRO="all"
-servers=(openim-api openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc-auth openim-rpc-conversation openim-rpc-friend openim-rpc-group openim-rpc-msg openim-rpc-third openim-rpc-user)
-
-
-if [ "$1" != "" ]
-then
- if [[ "${servers[@]}" =~ "${1}" ]]
- then
- echo "building ${PROJECT}"
- DOCKER_PUSHIMG=${IMAGEHUB}/${PROJECT}:dev
- docker rmi ${DOCKER_PUSHIMG}
- docker build -f manifest/dockerfiles/${PROJECT}/Dockerfile -t ${DOCKER_PUSHIMG} .
- docker push ${DOCKER_PUSHIMG}
- elif [[ ! "${servers[@]}" =~ "${1}" ]]
- then
- if [ ${PROJECT} == ${ALLPRO} ]
- then
- echo "building allproject"
- for element in ${servers[@]}
- do
- SUB_IMG=${element}
- SUB_PUSHIMG=${IMAGEHUB}/${element}:dev
- docker rmi ${SUB_PUSHIMG}
- docker build -f manifest/dockerfiles/${SUB_IMG}/Dockerfile -t ${SUB_PUSHIMG} .
- docker push ${SUB_PUSHIMG}
- done
- else
- echo "输入的项目名称不正确"
- fi
- fi
-else
- echo "请传入一个参数"
-fi
\ No newline at end of file
diff --git a/manifest/dockerfiles/openim-api/Dockerfile b/manifest/dockerfiles/openim-api/Dockerfile
deleted file mode 100644
index c5198d2ad..000000000
--- a/manifest/dockerfiles/openim-api/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-api/openim-api cmd/openim-api/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-api/openim-api /app/bin/
-ENTRYPOINT ["/app/bin/openim-api"]
diff --git a/manifest/dockerfiles/openim-crontask/Dockerfile b/manifest/dockerfiles/openim-crontask/Dockerfile
deleted file mode 100644
index bba54b2e2..000000000
--- a/manifest/dockerfiles/openim-crontask/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-crontask/openim-crontask cmd/openim-crontask/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-crontask/openim-crontask /app/bin/
-ENTRYPOINT ["/app/bin/openim-crontask"]
diff --git a/manifest/dockerfiles/openim-msggateway/Dockerfile b/manifest/dockerfiles/openim-msggateway/Dockerfile
deleted file mode 100644
index 582178013..000000000
--- a/manifest/dockerfiles/openim-msggateway/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-msggateway/openim-msggateway cmd/openim-msggateway/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-msggateway/openim-msggateway /app/bin/
-ENTRYPOINT ["/app/bin/openim-msggateway"]
diff --git a/manifest/dockerfiles/openim-msgtransfer/Dockerfile b/manifest/dockerfiles/openim-msgtransfer/Dockerfile
deleted file mode 100644
index 1e08eb38a..000000000
--- a/manifest/dockerfiles/openim-msgtransfer/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-msgtransfer/openim-msgtransfer cmd/openim-msgtransfer/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-msgtransfer/openim-msgtransfer /app/bin/
-ENTRYPOINT ["/app/bin/openim-msgtransfer"]
diff --git a/manifest/dockerfiles/openim-push/Dockerfile b/manifest/dockerfiles/openim-push/Dockerfile
deleted file mode 100644
index c1ae3ed84..000000000
--- a/manifest/dockerfiles/openim-push/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-push/openim-push cmd/openim-push/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-push/openim-push /app/bin/
-ENTRYPOINT ["/app/bin/openim-push"]
diff --git a/manifest/dockerfiles/openim-rpc-auth/Dockerfile b/manifest/dockerfiles/openim-rpc-auth/Dockerfile
deleted file mode 100644
index 5124da7a1..000000000
--- a/manifest/dockerfiles/openim-rpc-auth/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth cmd/openim-rpc/openim-rpc-auth/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-auth"]
diff --git a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile b/manifest/dockerfiles/openim-rpc-conversation/Dockerfile
deleted file mode 100644
index 539d441b9..000000000
--- a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation cmd/openim-rpc/openim-rpc-conversation/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-conversation"]
diff --git a/manifest/dockerfiles/openim-rpc-friend/Dockerfile b/manifest/dockerfiles/openim-rpc-friend/Dockerfile
deleted file mode 100644
index 9927c1d30..000000000
--- a/manifest/dockerfiles/openim-rpc-friend/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend cmd/openim-rpc/openim-rpc-friend/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-friend"]
diff --git a/manifest/dockerfiles/openim-rpc-group/Dockerfile b/manifest/dockerfiles/openim-rpc-group/Dockerfile
deleted file mode 100644
index 754151156..000000000
--- a/manifest/dockerfiles/openim-rpc-group/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-group/openim-rpc-group cmd/openim-rpc/openim-rpc-group/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-group/openim-rpc-group /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-group"]
diff --git a/manifest/dockerfiles/openim-rpc-msg/Dockerfile b/manifest/dockerfiles/openim-rpc-msg/Dockerfile
deleted file mode 100644
index 0f942ba8e..000000000
--- a/manifest/dockerfiles/openim-rpc-msg/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg cmd/openim-rpc/openim-rpc-msg/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-msg"]
diff --git a/manifest/dockerfiles/openim-rpc-third/Dockerfile b/manifest/dockerfiles/openim-rpc-third/Dockerfile
deleted file mode 100644
index a1391c0c3..000000000
--- a/manifest/dockerfiles/openim-rpc-third/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-third/openim-rpc-third cmd/openim-rpc/openim-rpc-third/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-third/openim-rpc-third /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-third"]
diff --git a/manifest/dockerfiles/openim-rpc-user/Dockerfile b/manifest/dockerfiles/openim-rpc-user/Dockerfile
deleted file mode 100644
index b45b4aa2f..000000000
--- a/manifest/dockerfiles/openim-rpc-user/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# build container
-FROM golang:1.20-alpine3.18 AS builder
-ENV GOPROXY https://goproxy.cn,direct
-ENV GOSUMDB=sum.golang.google.cn
-ENV GO111MODULE=on
-
-WORKDIR /app
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add git pkgconfig build-base
-ADD go.mod .
-ADD go.sum .
-RUN go mod download
-ADD . .
-RUN go build -o cmd/openim-rpc/openim-rpc-user/openim-rpc-user cmd/openim-rpc/openim-rpc-user/main.go
-
-# archive container
-FROM alpine:3.18
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
-RUN apk --no-cache add ca-certificates libdrm
-RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone \
- && apk del tzdata
-
-WORKDIR /app/bin
-COPY --from=builder /app/cmd/openim-rpc/openim-rpc-user/openim-rpc-user /app/bin/
-ENTRYPOINT ["/app/bin/openim-rpc-user"]
diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go
index c96bbd7af..358b79f9b 100644
--- a/pkg/common/cmd/msg_gateway.go
+++ b/pkg/common/cmd/msg_gateway.go
@@ -15,10 +15,11 @@
package cmd
import (
+ "log"
+
"github.com/openimsdk/open-im-server/v3/internal/msggateway"
- config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config"
+ v3config "github.com/openimsdk/open-im-server/v3/pkg/common/config"
- //"github.com/openimsdk/open-im-server/internal/msggateway".
"github.com/spf13/cobra"
"github.com/OpenIMSDK/protocol/constant"
@@ -39,7 +40,10 @@ func (m *MsgGatewayCmd) AddWsPortFlag() {
}
func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int {
- port, _ := cmd.Flags().GetInt(constant.FlagWsPort)
+ port, err := cmd.Flags().GetInt(constant.FlagWsPort)
+ if err != nil {
+ log.Println("Error getting ws port flag:", err)
+ }
if port == 0 {
port = m.PortFromConfig(constant.FlagWsPort)
}
@@ -58,9 +62,9 @@ func (m *MsgGatewayCmd) Exec() error {
}
func (m *MsgGatewayCmd) GetPortFromConfig(portType string) int {
if portType == constant.FlagWsPort {
- return config2.Config.LongConnSvr.OpenImWsPort[0]
+ return v3config.Config.LongConnSvr.OpenImWsPort[0]
} else if portType == constant.FlagPort {
- return config2.Config.LongConnSvr.OpenImMessageGatewayPort[0]
+ return v3config.Config.LongConnSvr.OpenImMessageGatewayPort[0]
} else if portType == constant.FlagPrometheusPort {
return 0
} else {
diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go
index 7bff0f798..d2d2b5009 100644
--- a/pkg/common/cmd/root.go
+++ b/pkg/common/cmd/root.go
@@ -131,7 +131,10 @@ func (r *RootCmd) AddPortFlag() {
}
func (r *RootCmd) getPortFlag(cmd *cobra.Command) int {
- port, _ := cmd.Flags().GetInt(constant.FlagPort)
+ port, err := cmd.Flags().GetInt(constant.FlagPort)
+ if err != nil {
+ fmt.Println("Error getting ws port flag:", err)
+ }
if port == 0 {
port = r.PortFromConfig(constant.FlagPort)
}
diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go
new file mode 100644
index 000000000..4161107c1
--- /dev/null
+++ b/pkg/common/version/base.go
@@ -0,0 +1,47 @@
+package version
+
+// Base version information.
+//
+// This is the fallback data used when version information from git is not
+// provided via go ldflags. It provides an approximation of the Kubernetes
+// version for ad-hoc builds (e.g. `go build`) that cannot get the version
+// information from git.
+//
+// If you are looking at these fields in the git tree, they look
+// strange. They are modified on the fly by the build process. The
+// in-tree values are dummy values used for "git archive", which also
+// works for GitHub tar downloads.
+//
+// When releasing a new Kubernetes version, this file is updated by
+// build/mark_new_version.sh to reflect the new version, and then a
+// git annotated tag (using format vX.Y where X == Major version and Y
+// == Minor version) is created to point to the commit that updates
+var (
+ // TODO: Deprecate gitMajor and gitMinor, use only gitVersion
+ // instead. First step in deprecation, keep the fields but make
+ // them irrelevant. (Next we'll take it out, which may muck with
+ // scripts consuming the kubectl version output - but most of
+ // these should be looking at gitVersion already anyways.)
+ gitMajor string = "" // major version, always numeric
+ gitMinor string = "" // minor version, numeric possibly followed by "+"
+
+ // semantic version, derived by build scripts (see
+ // https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md#kubernetes-release-versioning
+ // https://kubernetes.io/releases/version-skew-policy/
+ // for a detailed discussion of this field)
+ //
+ // TODO: This field is still called "gitVersion" for legacy
+ // reasons. For prerelease versions, the build metadata on the
+ // semantic version is a git hash, but the version itself is no
+ // longer the direct output of "git describe", but a slight
+ // translation to be semver compliant.
+
+ // NOTE: The $Format strings are replaced during 'git archive' thanks to the
+ // 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"
+
+ 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
new file mode 100644
index 000000000..3512640cc
--- /dev/null
+++ b/pkg/common/version/types.go
@@ -0,0 +1,30 @@
+package version
+
+// Info contains versioning information.
+// 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"`
+ 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"`
+}
+
+type Output struct {
+ OpenIMServerVersion Info `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"`
+ OpenIMClientVersion *OpenIMClientVersion `json:"OpenIMClientVersion,omitempty" yaml:"OpenIMClientVersion,omitempty"`
+}
+
+type OpenIMClientVersion struct {
+ ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version
+}
+
+// String returns info as a human-friendly version string.
+func (info Info) String() string {
+ return info.GitVersion
+}
diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go
new file mode 100644
index 000000000..b841c3f65
--- /dev/null
+++ b/pkg/common/version/version.go
@@ -0,0 +1,58 @@
+package version
+
+import (
+ "fmt"
+ "runtime"
+
+ "gopkg.in/src-d/go-git.v4"
+)
+
+// Get returns the overall codebase version. It's for detecting
+// what code a binary was built from.
+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,
+ GitTreeState: gitTreeState,
+ GitCommit: gitCommit,
+ BuildDate: buildDate,
+ GoVersion: runtime.Version(),
+ Compiler: runtime.Compiler,
+ Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
+ }
+}
+
+// GetClientVersion returns the git version of the OpenIM client repository
+func GetClientVersion() (*OpenIMClientVersion, error) {
+ clientVersion, err := getClientVersion()
+ if err != nil {
+ return nil, err
+ }
+ return &OpenIMClientVersion{
+ ClientVersion: clientVersion,
+ }, nil
+}
+
+func getClientVersion() (string, error) {
+ repo, err := git.PlainClone("/tmp/openim-sdk-core", false, &git.CloneOptions{
+ URL: "https://github.com/OpenIMSDK/openim-sdk-core",
+ })
+ if err != nil {
+ return "", fmt.Errorf("error cloning repository: %w", err)
+ }
+
+ ref, err := repo.Head()
+ if err != nil {
+ return "", fmt.Errorf("error getting head reference: %w", err)
+ }
+
+ return ref.Hash().String(), nil
+}
+
+// GetSingleVersion returns single version of sealer
+func GetSingleVersion() string {
+ return gitVersion
+}
diff --git a/scripts/check-all.sh b/scripts/check-all.sh
index 0d849dd50..23e2119d4 100755
--- a/scripts/check-all.sh
+++ b/scripts/check-all.sh
@@ -33,8 +33,9 @@ openim::log::info "\n# Begin to check all openim service"
# OpenIM status
# Elegant printing function
print_services_and_ports() {
- local -n service_names=$1
- local -n service_ports=$2
+ # 获取数组
+ declare -g service_names=("${!1}")
+ declare -g service_ports=("${!2}")
echo "+-------------------------+----------+"
echo "| Service Name | Port |"
diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh
index c5407f5e3..f3f53e49e 100755
--- a/scripts/install/environment.sh
+++ b/scripts/install/environment.sh
@@ -69,7 +69,7 @@ def "ENV_FILE" ""${OPENIM_ROOT}"/scripts/install/environment.sh"
def "CHAT_BRANCH" "main"
def "SERVER_BRANCH" "main"
-# Choose the appropriate image address, the default is GITHUB image,
+# Choose the appropriate image address, the default is GITHUB image,
# you can choose docker hub, for Chinese users can choose Ali Cloud
# export IMAGE_REGISTRY="ghcr.io/openimsdk"
# export IMAGE_REGISTRY="openim"
@@ -78,6 +78,9 @@ def "IMAGE_REGISTRY" "ghcr.io/openimsdk"
# def "IMAGE_REGISTRY" "openim"
# def "IMAGE_REGISTRY" "registry.cn-hangzhou.aliyuncs.com/openimsdk"
+# Choose the appropriate image tag, the default is the latest version
+def "SERVER_IMAGE_TAG" "latest"
+
###################### OpenIM Docker Network ######################
# 设置 Docker 网络的网段
readonly DOCKER_BRIDGE_SUBNET=${DOCKER_BRIDGE_SUBNET:-'172.28.0.0/16'}
@@ -115,10 +118,10 @@ LAST_OCTET=$((LAST_OCTET + 1))
GRAFANA_NETWORK_ADDRESS=$(generate_ip)
###################### openim 配置 ######################
-# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/init/README.md
+# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/README.md
def "OPENIM_DATA_DIR" "/data/openim"
def "OPENIM_INSTALL_DIR" "/opt/openim"
-def "OPENIM_CONFIG_DIR" "/etc/openim"
+def "OPENIM_CONFIG_DIR" "/etc/openim/config"
def "OPENIM_LOG_DIR" "/var/log/openim"
def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem"
@@ -138,14 +141,14 @@ def "OPENIM_CHAT_ADDRESS" "${DOCKER_BRIDGE_GATEWAY}" # OpenIM服务地址
def "OPENIM_CHAT_API_PORT" "10008" # OpenIM API端口
def "CHAT_API_LISTEN_IP" "" # OpenIM API的监听IP
-def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口
-def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP
+def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口
+def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP
-def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口
-def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP
+def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口
+def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP
-def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名
-def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名
+def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名
+def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名
# TODO 注意: 一般的配置都可以使用 def 函数来定义,如果是包含特殊字符,比如说:
# TODO readonly MSG_DESTRUCT_TIME=${MSG_DESTRUCT_TIME:-'0 2 * * *'}
@@ -306,10 +309,10 @@ def "GETUI_INTENT" "" # GeTui推送意图
def "GETUI_CHANNEL_ID" "" # GeTui渠道ID
def "GETUI_CHANNEL_NAME" "" # GeTui渠道名称
def "FCM_SERVICE_ACCOUNT" "x.json" # FCM服务账户
-def "JPNS_APP_KEY" "" # JPNS应用密钥
-def "JPNS_MASTER_SECRET" "" # JPNS主密钥
-def "JPNS_PUSH_URL" "" # JPNS推送URL
-def "JPNS_PUSH_INTENT" "" # JPNS推送意图
+def "JPNS_APP_KEY" "" # JPNS应用密钥
+def "JPNS_MASTER_SECRET" "" # JPNS主密钥
+def "JPNS_PUSH_URL" "" # JPNS推送URL
+def "JPNS_PUSH_INTENT" "" # JPNS推送意图
def "MANAGER_USERID_1" "openIM123456" # 管理员ID 1
def "MANAGER_USERID_2" "openIM654321" # 管理员ID 2
def "MANAGER_USERID_3" "openIMAdmin" # 管理员ID 3
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 9f1698a5b..915eef3f6 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -51,15 +51,9 @@
OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P)
[[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-msggateway.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-msgtransfer.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-push.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-rpc.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-crontask.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-api.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-man.sh
-source "${OPENIM_ROOT}"/scripts/install/openim-tools.sh
-source "${OPENIM_ROOT}"/scripts/install/test.sh
+${OPENIM_ROOT}/scripts/install/openim-man.sh
+${OPENIM_ROOT}/scripts/install/openim-tools.sh
+${OPENIM_ROOT}/scripts/install/test.sh
# Detailed help function
function openim::install::show_help() {
@@ -79,16 +73,26 @@ function openim::install::show_help() {
function openim::install::install_openim()
{
+ openim::common::sudo "mkdir -p ${OPENIM_DATA_DIR} ${OPENIM_INSTALL_DIR} ${OPENIM_CONFIG_DIR} ${OPENIM_LOG_DIR}"
openim::log::info "check openim dependency"
+ openim::common::sudo "cp -r ${OPENIM_ROOT}/config/* ${OPENIM_CONFIG_DIR}/"
+
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.yaml > ${OPENIM_CONFIG_DIR}/config.yaml"
+
openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]}
- openim::msggateway::install || return 1
- openim::msgtransfer::install || return 1
- openim::push::install || return 1
- openim::rpc::install || return 1
- openim::crontask::install || return 1
- openim::api::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::install || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::install || return 1
+ openim::common::sudo "cp -r ${OPENIM_ROOT}/deployments/templates/openim.target /etc/systemd/system/openim.target"
+ openim::common::sudo "systemctl daemon-reload"
+ openim::common::sudo "systemctl restart openim.target"
+ openim::common::sudo "systemctl enable openim.target"
openim::log::success "openim install success"
}
@@ -96,13 +100,18 @@ function openim::uninstall::uninstall_openim()
{
openim::log::info "uninstall openim"
- openim::msggateway::uninstall || return 1
- openim::msgtransfer::uninstall || return 1
- openim::push::uninstall || return 1
- openim::rpc::uninstall || return 1
- openim::crontask::uninstall || return 1
- openim::api::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::uninstall || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::uninstall || return 1
+ set +o errexit
+ openim::common::sudo "systemctl stop openim.target"
+ openim::common::sudo "systemctl disable openim.target"
+ openim::common::sudo "rm -f /etc/systemd/system/openim.target"
+ set -o errexit
openim::log::success "openim uninstall success"
}
@@ -110,12 +119,12 @@ function openim::install::status()
{
openim::log::info "check openim status"
- openim::msggateway::status || return 1
- openim::msgtransfer::status || return 1
- openim::push::status || return 1
- openim::rpc::status || return 1
- openim::crontask::status || return 1
- openim::api::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::status || return 1
+ ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::status || return 1
openim::log::success "openim status success"
}
diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh
index 5239b95e7..a2d40b777 100755
--- a/scripts/install/openim-api.sh
+++ b/scripts/install/openim-api.sh
@@ -92,21 +92,70 @@ function openim::api::start_service() {
###################################### Linux Systemd ######################################
SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
+# Print the necessary information after installation
+function openim::api::info() {
+cat << EOF
+openim-api listen on: ${OPENIM_API_HOST}:${API_OPENIM_PORT}
+EOF
+}
+
+# install openim-api
function openim::api::install() {
openim::log::info "Installing ${SERVER_NAME} ..."
+
+ pushd "${OPENIM_ROOT}"
+
+ # 1. Build openim-api
+ make build BINS=${SERVER_NAME}
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
+
+ # 2. Generate and install the openim-api configuration file (config)
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
+
+ # 3. Create and install the ${SERVER_NAME} systemd unit file
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
+ openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
+
+ # 4. Start the openim-api service
+ openim::common::sudo "systemctl daemon-reload"
+ openim::common::sudo "systemctl restart ${SERVER_NAME}"
+ openim::common::sudo "systemctl enable ${SERVER_NAME}"
+ openim::api::status || return 1
+ openim::api::info
+
+ openim::log::info "install ${SERVER_NAME} successfully"
+ popd
}
+# Unload
function openim::api::uninstall() {
openim::log::info "Uninstalling ${SERVER_NAME} ..."
+ set +o errexit
+ openim::common::sudo "systemctl stop ${SERVER_NAME}"
+ openim::common::sudo "systemctl disable ${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
+ set -o errexit
+ openim::log::info "uninstall ${SERVER_NAME} successfully"
}
+# Status Check
function openim::api::status() {
openim::log::info "Checking ${SERVER_NAME} status ..."
+ # Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
+ systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
+ return 1
+ }
+
openim::util::check_ports ${OPENIM_API_PORT_LISTARIES[@]}
}
if [[ "$*" =~ openim::api:: ]];then
- eval $*
-fi
\ No newline at end of file
+ eval $*
+fi
diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh
index 455dafa8b..49e018ad1 100755
--- a/scripts/install/openim-crontask.sh
+++ b/scripts/install/openim-crontask.sh
@@ -51,7 +51,7 @@ function openim::crontask::start()
openim::util::stop_services_with_name ${OPENIM_CRONTASK_BINARY}
openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}"
- nohup ${OPENIM_CRONTASK_BINARY} >> ${LOG_FILE} 2>&1 &
+ nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2>&1 &
openim::util::check_process_names ${SERVER_NAME}
}
@@ -72,18 +72,16 @@ function openim::crontask::install()
# 1. Build openim-crontask
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
# 2. Generate and install the openim-crontask configuration file (openim-crontask.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-crontask service
@@ -104,7 +102,7 @@ function openim::crontask::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -115,15 +113,11 @@ function openim::crontask::uninstall()
function openim::crontask::status()
{
# Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
- systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ if systemctl is-active --quiet "${SERVER_NAME}"; then
+ openim::log::info "${SERVER_NAME} is running successfully."
+ else
openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
return 1
- }
-
- # The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
- openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
- return 1
fi
}
diff --git a/scripts/install/openim-man.sh b/scripts/install/openim-man.sh
index 4cf8e385d..6dda4bfe1 100755
--- a/scripts/install/openim-man.sh
+++ b/scripts/install/openim-man.sh
@@ -48,7 +48,7 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
function openim::man::info() {
cat <<- EOF
Usage:
- man openim-server # Display the man page for openim-server
+ man openim-server to see openim-server help # Display the man page for openim-server
EOF
}
diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh
index 612b7ae16..79aa6fa15 100755
--- a/scripts/install/openim-msggateway.sh
+++ b/scripts/install/openim-msggateway.sh
@@ -74,7 +74,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
# Print the necessary information after installation
function openim::msggateway::info() {
cat << EOF
-openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST}
+openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST}:${OPENIM_MESSAGE_GATEWAY_PORT}
EOF
}
@@ -85,18 +85,15 @@ function openim::msggateway::install()
# 1. Build openim-msggateway
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
-
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
# 2. Generate and install the openim-msggateway configuration file (openim-msggateway.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # nono
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-msggateway service
@@ -117,7 +114,7 @@ function openim::msggateway::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -134,7 +131,7 @@ function openim::msggateway::status()
}
# The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_MESSAGE_GATEWAY_PORT} 2>&1|grep refused &>/dev/null;then
openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
return 1
fi
diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh
index 51ac78850..b28ca7efa 100755
--- a/scripts/install/openim-msgtransfer.sh
+++ b/scripts/install/openim-msgtransfer.sh
@@ -95,18 +95,18 @@ function openim::msgtransfer::install()
# 1. Build openim-msgtransfer
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
+
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
# 2. Generate and install the openim-msgtransfer configuration file (openim-msgtransfer.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # nono
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-msgtransfer service
@@ -127,7 +127,7 @@ function openim::msgtransfer::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -138,15 +138,11 @@ function openim::msgtransfer::uninstall()
function openim::msgtransfer::status()
{
# Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully.
- systemctl status ${SERVER_NAME}|grep -q 'active' || {
+ if systemctl is-active --quiet "${SERVER_NAME}"; then
+ openim::log::info "${SERVER_NAME} is running successfully."
+ else
openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly"
return 1
- }
-
- # The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then
- openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
- return 1
fi
}
diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh
index 9b1d4d53f..5197c9948 100755
--- a/scripts/install/openim-push.sh
+++ b/scripts/install/openim-push.sh
@@ -83,7 +83,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
# Print the necessary information after installation
function openim::push::info() {
cat << EOF
-openim-push listen on: ${OPENIM_PUSH_HOST}
+openim-push listen on: ${OPENIM_PUSH_HOST}:${OPENIM_PUSH_PORT}
EOF
}
@@ -94,18 +94,15 @@ function openim::push::install()
# 1. Build openim-push
make build BINS=${SERVER_NAME}
- openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin"
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
+ openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}"
- openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
-
- # 2. Generate and install the openim-push configuration file (openim-push.yaml)
- echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
- openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
+ # 2. Generate and install the openim-push configuration file (config)
+ openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml"
# 3. Create and install the ${SERVER_NAME} systemd unit file
echo ${LINUX_PASSWORD} | sudo -S bash -c \
- "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}"
+ "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}"
openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}"
# 4. Start the openim-push service
@@ -125,7 +122,7 @@ function openim::push::uninstall()
set +o errexit
openim::common::sudo "systemctl stop ${SERVER_NAME}"
openim::common::sudo "systemctl disable ${SERVER_NAME}"
- openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}"
openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml"
openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service"
set -o errexit
@@ -142,7 +139,7 @@ function openim::push::status()
}
# The listening port is hardcode in the configuration file
- if echo | telnet 127.0.0.1 7071 2>&1|grep refused &>/dev/null;then # Assuming a different port for push
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_PUSH_PORT} 2>&1|grep refused &>/dev/null;then # Assuming a different port for push
openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup"
return 1
fi
diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh
index a0a7868f1..d6000b093 100755
--- a/scripts/install/openim-rpc.sh
+++ b/scripts/install/openim-rpc.sh
@@ -160,26 +160,86 @@ function openim::rpc::start_service() {
}
###################################### Linux Systemd ######################################
-SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service"
-
-function openim::rpc::install() {
- openim::log::info "Installing ${SERVER_NAME} ..."
+declare -A SYSTEM_FILE_PATHS
+for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ SYSTEM_FILE_PATHS["$service"]="/etc/systemd/system/${service}.service"
+done
+
+# Print the necessary information after installation
+function openim::rpc::info() {
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ echo "${service} listen on: ${OPENIM_RPC_PORT_LISTARIES[@]}"
+ done
}
-function openim::rpc::uninstall() {
- openim::log::info "Uninstalling ${SERVER_NAME} ..."
+# install openim-rpc
+function openim::rpc::install()
+{
+ pushd "${OPENIM_ROOT}"
-}
+ # 1. Build openim-rpc
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ make build BINS=${service}
+ openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${service} ${OPENIM_INSTALL_DIR}/${service}"
+ openim::log::status "${service} binary: ${OPENIM_INSTALL_DIR}/${service}/${service}"
+ done
-function openim::rpc::status() {
- openim::log::info "Checking ${SERVER_NAME} status ..."
+ # 2. Generate and install the openim-rpc configuration file (config)
+ openim::log::status "openim-rpc config file: ${OPENIM_CONFIG_DIR}/config.yaml"
- openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]}
- # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]}
+ # 3. Create and install the systemd unit files
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ echo ${LINUX_PASSWORD} | sudo -S bash -c \
+ "SERVER_NAME=${service} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATHS[$service]}"
+ openim::log::status "${service} systemd file: ${SYSTEM_FILE_PATHS[$service]}"
+ done
- openim::util::check_process_names ${SERVER_NAME}
+ # 4. Start the openim-rpc services
+ openim::common::sudo "systemctl daemon-reload"
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ openim::common::sudo "systemctl restart ${service}"
+ openim::common::sudo "systemctl enable ${service}"
+ done
+ openim::rpc::status || return 1
+ openim::rpc::info
+
+ openim::log::info "install openim-rpc successfully"
+ popd
+}
+
+# Unload
+function openim::rpc::uninstall()
+{
+ set +o errexit
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ openim::common::sudo "systemctl stop ${service}"
+ openim::common::sudo "systemctl disable ${service}"
+ openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${service}"
+ openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${service}.yaml"
+ openim::common::sudo "rm -f ${SYSTEM_FILE_PATHS[$service]}"
+ done
+ set -o errexit
+ openim::log::info "uninstall openim-rpc successfully"
+}
+
+# Status Check
+function openim::rpc::status()
+{
+ for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do
+ # Check the running status of the ${service}. If active (running) is displayed, the ${service} is started successfully.
+ systemctl status ${service}|grep -q 'active' || {
+ openim::log::error "${service} failed to start, maybe not installed properly"
+ return 1
+ }
+
+ # The listening port is hardcoded in the configuration file
+ if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_RPC_PORT_LISTARIES[@]} 2>&1|grep refused &>/dev/null;then
+ openim::log::error "cannot access health check port, ${service} maybe not startup"
+ return 1
+ fi
+ done
}
if [[ "$*" =~ openim::rpc:: ]];then
- eval $*
-fi
\ No newline at end of file
+ eval $*
+fi
diff --git a/scripts/install/vimrc b/scripts/install/vimrc
deleted file mode 100644
index b128951c6..000000000
--- a/scripts/install/vimrc
+++ /dev/null
@@ -1,300 +0,0 @@
-" learn: https://github.com/cubxxw/awesome-cs-course/tree/master/linux
-" Read: https://github.com/cubxxw/awesome-cs-course/blob/master/linux/markdown/my_vim.md
-
-"vim的配置关于鼠标滚动滑动"""
-if has("autocmd")
- au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
- set mouse=a
-endif
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"C,C++ 按F5编译运行
-map :call CompileRunGcc()
-func! CompileRunGcc()
- exec "w"
- if &filetype == 'c'
- exec "!g++ % -o %<"
- exec "! ./%<"
- elseif &filetype == 'cpp'
- exec "!g++ % -o %<"
- exec "! ./%<"
- elseif &filetype == 'java'
- exec "!javac %"
- exec "!java %<"
- elseif &filetype == 'sh'
- :!./%
- endif
-endfunc
-"配置命令"
-"C,C++的调试
-"''''''''''''''''""""""""""""""""""""""""""""""""""'''''''''''''''''''''
-map :call Rungdb()
-func! Rungdb()
- exec "w"
- exec "!g++ % -g -o %<"
- exec "!gdb ./%<"
-endfunc
-
-""实用设置
-" 设置当文件被改动时自动载入
-set autoread
-" quickfix模式
-autocmd FileType c,cpp map :w:make
-"代码补全
-set completeopt=preview,menu
-
-" common configure
-"set noswapfile
-set mouse=a " 激活鼠标使用
-set wrap " 自动换行
-set sw=4 " 设置软宽度
-set gdefault " 行内替换
-set nu
-set showmatch " 高亮显示括号匹配
-set expandtab " 使用空格来替换 Tab
-set tabstop=4 " 设置 Tab 长度为 4 空格
-set shiftwidth=4 " 设置自动缩进长度为 4 空格
-set autoindent " 继承前一行的缩进方式,适用于多行注释"
-set autowrite " 自动保存
-set nocompatible " 关闭 vi 兼容模式
-set history=1000 " 设置历史记录步数
-set confirm " 在处理未保存或只读文件时,弹出确认
-
-" 搜索逐字符高亮
-set hlsearch
-set incsearch
-
-" 从不备份
-set nobackup
-set noswapfile
-
-let g:indentLine_enabled=0
-
-" golang configure ====> start
-let g:go_highlight_methods = 1
-let g:go_highlight_operators = 1
-let g:go_highlight_build_constraints = 1
-let g:go_fmt_autosave = 1
-let g:go_version_warning = 1
-let g:go_autodetect_gopath = 1
-let g:go_highlight_types = 1
-let g:go_highlight_fields = 1
-let g:go_highlight_functions = 1
-let g:go_highlight_function_calls = 1
-let g:go_highlight_extra_types = 1
-let g:go_highlight_generate_tags = 1
-let g:go_def_mode = 'gopls'
-let g:go_gopls_enabled = 1
-let g:go_guru_enabled = 1
-let g:go_fmt_experimental = 1
-let g:go_def_mapping_enabled = 1
-let g:go_build_tags = '-v'
-let g:go_fmt_command = "goimports"
-let g:go_list_type = "quickfix"
-let g:go_def_mapping_enable = 1
-
-map <2-LeftMouse> :GoDef
-map :GoDefPop
-map :GoCallers
-map :GoCallees
-map
-map
-unmap
-map :GoDef
-map :GoDefPop
-map :GoDoc
-map :GoInfo
-map :GoDefType
-map :GoAddTag
-map :GoImplements
-map :GoRename
-map :GoFillStruct
-map :GoCallers
-map :GoSameIdsToggle
-
-augroup go
- autocmd!
-
- " Show by default 4 spaces for a tab
- autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4
-
- " :GoDef but opens in a vertical split
- autocmd FileType go nmap v (go-def-vertical)
- " :GoDef but opens in a horizontal split
- autocmd FileType go nmap s (go-def-split)
-
- " :GoAlternate commands :A, :AV, :AS and :AT
- autocmd Filetype go command! -bang A call go#alternate#Switch(0, 'edit')
- autocmd Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit')
- autocmd Filetype go command! -bang AS call go#alternate#Switch(0, 'split')
- autocmd Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe')
-augroup END
-
-" build_go_files is a custom function that builds or compiles the test file.
-" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file
-function! s:build_go_files()
- let l:file = expand('%')
- if l:file =~# '^\f\+_test\.go$'
- call go#test#Test(0, 1)
- elseif l:file =~# '^\f\+\.go$'
- call go#cmd#Build(0)
- endif
-endfunction
-" golang configure ====> end
-
-:inoremap ( ()i
-:inoremap ) =ClosePair(')')
-:inoremap { {}O
-:inoremap } =ClosePair('}')
-:inoremap [ []i
-:inoremap ] =ClosePair(']')
-:inoremap " ""i
-:inoremap ' ''i
-function! ClosePair(char)
- if getline('.')[col('.') - 1] == a:char
- return "\"
- else
- return a:char
- endif
-endfunction
-filetype plugin indent on
-"打开文件类型检测, 加了这句才可以用智能补全
-
-set completeopt=longest,menu
-
-"""""""""""""""""""""""""""""""""""""""""""""""
- noremap :set nu
- noremap :!python3 a
- noremap :set ai
- noremap :syntax on
- set cursorline " 突出显示当前行
- set magic " 设置魔术
- "" noremap :! g++ -o a
-nnoremap
-nnoremap
-nnoremap
-nnoremap
-nmap wj :resize -3
-nmap wk :resize +3
-nmap wh :vertical resize -3
-nmap wl :vertical resize +3
-set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体
-set guicursor=n-v-c:ver5 " 设置光标为竖线
-set number ""# 显示行号
-set autowrite "" # 自动保存
-set ruler ""# 显示打开状态栏标尺
-set cursorline "" # 突出显示当前行
-
-set showmatch "" # 匹配光标所经过的括号等.
-set showcmd ""# 命令行显示输入的命令
-set showmode ""命令行显示vim当前模式
-set showtabline=0 " 隐藏Tab栏
-set laststatus=2 """"'vim 窗口底部显示永久状态栏,显示文件名,行号,列号等.
-let mapleader = "," " 定义键
-set nocompatible " 设置不兼容原始vi模式
-filetype on " 设置开启文件类型侦测
-filetype plugin on " 设置加载对应文件类型的插件
-set noeb " 关闭错误的提示
-syntax enable " 开启语法高亮功能
-syntax on " 自动语法高亮
-set cmdheight=2 " 设置命令行的高度
-set showcmd " select模式下显示选中的行数
-set ruler " 总是显示光标位置
-set laststatus=2 " 总是显示状态栏
-set number " 开启行号显示
-set cursorline " 高亮显示当前行
-set whichwrap+=<,>,h,l " 设置光标键跨行
-set ttimeoutlen=0 " 设置键响应时间
-set virtualedit=block,onemore " 允许光标出现在最后一个字符的后面
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 代码缩进和排版
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set autoindent " 设置自动缩进
-set cindent " 设置使用C/C++语言的自动缩进方式
-set cinoptions=g0,:0,N-s,(0 " 设置C/C++语言的具体缩进方式
-set smartindent " 智能的选择对其方式
-filetype indent on " 自适应不同语言的智能缩进
-set expandtab " 将制表符扩展为空格
-set tabstop=4 " 设置编辑时制表符占用空格数
-set shiftwidth=4 " 设置格式化时制表符占用空格数
-set softtabstop=4 " 设置4个空格为制表符
-set smarttab " 在行和段开始处使用制表符
-set nowrap " 禁止折行
-set backspace=2 " 使用回车键正常处理indent,eol,start等
-set sidescroll=10 " 设置向右滚动字符数
-set nofoldenable " 禁用折叠代码
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 代码补全
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set wildmenu " vim自身命名行模式智能补全
-set completeopt-=preview " 补全时不显示窗口,只显示补全列表
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 搜索设置
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set hlsearch " 高亮显示搜索结果
-set incsearch " 开启实时搜索功能
-set ignorecase " 搜索时大小写不敏感
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" 缓存设置
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set nobackup " 设置不备份
-set noswapfile " 禁止生成临时文件
-set autoread " 文件在vim之外修改过,自动重新读入
-set autowrite " 设置自动保存
-set confirm " 在处理未保存或只读文件的时候,弹出确认
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"调整窗
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-nmap wj :resize -3
-nmap wk :resize +3
-nmap wh :vertical resize -3
-nmap wl :vertical resize +3
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"编码"
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-set langmenu=zh_CN.UTF-8
-set helplang=cn
-set termencoding=utf-8
-set encoding=utf8
-set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"代码补全“
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-inoremap ' ''i
-inoremap " ""i
-inoremap ( ()i
-inoremap [ []i
-inoremap { {}O
- : set nu
- : set ai
- : syntax on
- : filetype on
- set tabstop=4
- set ignorecase
-noremap h
-noremap j
-noremap r
-noremap l
-" Specify a directory for plugins
-" - For Neovim: stdpath('data') . '/plugged'
-" - Avoid using standard Vim directory names like 'plugin'
-let g:coc_disable_startup_warning = 1
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"tmux"
-"复用终端、分屏"
-"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-map h (easymotion-linebackward)
-map j (easymotion-j)
-map k (easymotion-k)
-map l (easymotion-lineforward)
-" 重复上一次操作, 类似repeat插件, 很强大
-map . (easymotion-repeat)
-nmap s (easymotion-s)
diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh
index d7c274c56..6fd9a5cfd 100755
--- a/scripts/lib/util.sh
+++ b/scripts/lib/util.sh
@@ -268,6 +268,7 @@ openim::util::check_docker_and_compose_versions() {
# Check if the docker compose sub-command is available
if ! docker compose version &> /dev/null; then
echo "Docker does not support the docker compose sub-command"
+ echo "You need to upgrade Docker to the right version"
return 1
fi
diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk
index cc2c98544..29f527028 100644
--- a/scripts/make-rules/golang.mk
+++ b/scripts/make-rules/golang.mk
@@ -137,6 +137,7 @@ ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' &&
endif
## go.build.%: Build binaries for a specific platform
+# CGO_ENABLED=0 https://wiki.musl-libc.org/functional-differences-from-glibc.html
.PHONY: go.build.%
go.build.%:
$(eval COMMAND := $(word 2,$(subst ., ,$*)))
diff --git a/scripts/make-rules/image.mk b/scripts/make-rules/image.mk
index 09e92126b..fa7f8ee9c 100644
--- a/scripts/make-rules/image.mk
+++ b/scripts/make-rules/image.mk
@@ -23,7 +23,8 @@
DOCKER := docker
# read: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md
-REGISTRY_PREFIX ?= ghcr.io/openimsdk
+REGISTRY_PREFIX ?= registry.cn-hangzhou.aliyuncs.com/openimsdk
+# REGISTRY_PREFIX ?= ghcr.io/openimsdk
BASE_IMAGE ?= ghcr.io/openim-sigs/openim-bash-image
@@ -43,6 +44,7 @@ endif
# Determine image files by looking into build/images/*/Dockerfile
IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/images/*)
# Determine images names by stripping out the dir names, and filter out the undesired directories
+# IMAGES ?= $(filter-out Dockerfile,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
IMAGES ?= $(filter-out Dockerfile openim-tools openim-cmdutils,$(foreach image,${IMAGES_DIR},$(notdir ${image})))
ifeq (${IMAGES},)
@@ -105,6 +107,7 @@ image.build.%: go.build.%
| sed "s#BINARY_NAME#$(IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile
@cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)
$(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE))
+ @echo $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX)
@if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \
$(MAKE) image.daemon.verify ;\
$(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \
diff --git a/scripts/template/head.md.tmpl b/scripts/template/head.md.tmpl
index 4aba97556..41dac30ef 100644
--- a/scripts/template/head.md.tmpl
+++ b/scripts/template/head.md.tmpl
@@ -16,7 +16,7 @@ Learn more about versions of OpenIM:
-
+
diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh
index bd2ebb268..008cf63ed 100755
--- a/scripts/update-generated-docs.sh
+++ b/scripts/update-generated-docs.sh
@@ -28,10 +28,10 @@ source "${OPENIM_ROOT}/hack/lib/init.sh"
openim::golang::setup_env
BINS=(
- cmd/gendocs
- cmd/genopenimdocs
- cmd/genman
- cmd/genyaml
+ gendocs
+ genopenimdocs
+ genman
+ genyaml
)
make -C "${OPENIM_ROOT}" WHAT="${BINS[*]}"
diff --git a/tools/infra/go.mod b/tools/infra/go.mod
index a6cf16c77..8c66e2654 100644
--- a/tools/infra/go.mod
+++ b/tools/infra/go.mod
@@ -1,3 +1,11 @@
module github.com/openimsdk/open-im-server/v3/tools/infra
go 1.19
+
+require github.com/fatih/color v1.15.0
+
+require (
+ github.com/mattn/go-colorable v0.1.13 // indirect
+ github.com/mattn/go-isatty v0.0.17 // indirect
+ golang.org/x/sys v0.6.0 // indirect
+)
diff --git a/tools/infra/go.sum b/tools/infra/go.sum
new file mode 100644
index 000000000..2624c9db0
--- /dev/null
+++ b/tools/infra/go.sum
@@ -0,0 +1,10 @@
+github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/tools/infra/infra.go b/tools/infra/infra.go
index cc20a17c7..f8d8c7522 100644
--- a/tools/infra/infra.go
+++ b/tools/infra/infra.go
@@ -1,29 +1,25 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
package main
import (
"fmt"
- "log"
+
+ "github.com/fatih/color"
)
+// 定义一个函数以打印重要的链接信息
+func printLinks() {
+ blue := color.New(color.FgBlue).SprintFunc()
+ fmt.Printf("OpenIM Github: %s\n", blue("https://github.com/OpenIMSDK/Open-IM-Server"))
+ fmt.Printf("Slack Invitation: %s\n", blue("https://openimsdk.slack.com"))
+}
+
func main() {
- log.Println("Current module is still under development.")
- message := `
-Current module is still under development.
+ yellow := color.New(color.FgYellow)
+ blue := color.New(color.FgBlue, color.Bold)
+
+ yellow.Println("Current module is still under development.")
+ message := `
____ _____ __ __
/ __ \ |_ _|| \/ |
| | | | _ __ ___ _ __ | | | \ / |
@@ -36,5 +32,6 @@ ____ _____ __ __
Keep checking for updates!
`
- fmt.Println(message)
+ blue.Println(message)
+ printLinks() // 调用函数以打印链接信息
}
diff --git a/tools/versionchecker/go.mod b/tools/versionchecker/go.mod
index 619bcdb5b..7c274fcf9 100644
--- a/tools/versionchecker/go.mod
+++ b/tools/versionchecker/go.mod
@@ -1,3 +1,11 @@
module github.com/openimsdk/open-im-server/v3/tools/versionchecker
go 1.19
+
+require github.com/fatih/color v1.15.0
+
+require (
+ github.com/mattn/go-colorable v0.1.13 // indirect
+ github.com/mattn/go-isatty v0.0.17 // indirect
+ golang.org/x/sys v0.6.0 // indirect
+)
diff --git a/tools/versionchecker/go.sum b/tools/versionchecker/go.sum
new file mode 100644
index 000000000..2624c9db0
--- /dev/null
+++ b/tools/versionchecker/go.sum
@@ -0,0 +1,10 @@
+github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
+github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
+github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
+github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
+github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go
index e7bc3e379..12254b58e 100644
--- a/tools/versionchecker/versionchecker.go
+++ b/tools/versionchecker/versionchecker.go
@@ -20,9 +20,12 @@ import (
"os/exec"
"runtime"
"time"
+
+ "github.com/fatih/color"
+ //"github.com/openimsdk/open-im-server/v3/pkg/common/version"
)
-func executeCommand(cmdName string, args ...string) (string, error) {
+func ExecuteCommand(cmdName string, args ...string) (string, error) {
cmd := exec.Command(cmdName, args...)
var out bytes.Buffer
var stderr bytes.Buffer
@@ -31,19 +34,15 @@ func executeCommand(cmdName string, args ...string) (string, error) {
err := cmd.Run()
if err != nil {
- return "", fmt.Errorf("Error executing %s: %v", cmdName, err)
+ return "", fmt.Errorf("error executing %s: %v, stderr: %s", cmdName, err, stderr.String())
}
return out.String(), nil
}
func printTime() string {
currentTime := time.Now()
-
- // 使用 Format 函数以优雅的方式格式化日期和时间
- // 2006-01-02 15:04:05 是 Go 中的标准时间格式
formattedTime := currentTime.Format("2006-01-02 15:04:05")
-
- return fmt.Sprintf("Current Date & Time:", formattedTime)
+ return fmt.Sprintf("Current Date & Time: %s", formattedTime)
}
func getGoVersion() string {
@@ -54,7 +53,7 @@ func getGoVersion() string {
}
func getDockerVersion() string {
- version, err := executeCommand("docker", "--version")
+ version, err := ExecuteCommand("docker", "--version")
if err != nil {
return "Docker is not installed. Please install it to get the version."
}
@@ -62,7 +61,7 @@ func getDockerVersion() string {
}
func getDockerComposeVersion() string {
- version, err := executeCommand("docker-compose", "--version")
+ version, err := ExecuteCommand("docker-compose", "--version")
if err != nil {
return "Docker Compose is not installed. Please install it to get the version."
}
@@ -70,7 +69,7 @@ func getDockerComposeVersion() string {
}
func getKubernetesVersion() string {
- version, err := executeCommand("kubectl", "version", "--client", "--short")
+ version, err := ExecuteCommand("kubectl", "version", "--client", "--short")
if err != nil {
return "Kubernetes is not installed. Please install it to get the version."
}
@@ -78,38 +77,52 @@ func getKubernetesVersion() string {
}
func getGitVersion() string {
- version, err := executeCommand("git", "branch", "--show-current")
+ version, err := ExecuteCommand("git", "branch", "--show-current")
if err != nil {
return "Git is not installed. Please install it to get the version."
}
return version
}
-// NOTE: You'll need to provide appropriate commands for OpenIM versions.
-func getOpenIMServerVersion() string {
- // Placeholder
- return "OpenIM Server: v3.2"
-}
+// // NOTE: You'll need to provide appropriate commands for OpenIM versions.
+// func getOpenIMServerVersion() string {
+// // Placeholder
+// openimVersion := version.GetSingleVersion()
+// return "OpenIM Server: " + openimVersion + "\n"
+// }
-func getOpenIMClientVersion() string {
- // Placeholder
- return "OpenIM Client: v3.2"
-}
+// func getOpenIMClientVersion() (string, error) {
+// openIMClientVersion, err := version.GetClientVersion()
+// if err != nil {
+// return "", err
+// }
+// return "OpenIM Client: " + openIMClientVersion.ClientVersion + "\n", nil
+// }
func main() {
- fmt.Println(printTime())
- fmt.Println("# Diagnostic Tool Result\n")
- fmt.Println("## Go Version")
+ // red := color.New(color.FgRed).SprintFunc()
+ green := color.New(color.FgGreen).SprintFunc()
+ blue := color.New(color.FgBlue).SprintFunc()
+ yellow := color.New(color.FgYellow).SprintFunc()
+
+ fmt.Println(green(printTime()))
+ fmt.Println(yellow("# Diagnostic Tool Result\n"))
+ fmt.Println(blue("## Go Version"))
fmt.Println(getGoVersion())
- fmt.Println("## Branch Type")
+ fmt.Println(blue("## Branch Type"))
fmt.Println(getGitVersion())
- fmt.Println("## Docker Version")
+ fmt.Println(blue("## Docker Version"))
fmt.Println(getDockerVersion())
- fmt.Println("## Docker Compose Version")
+ fmt.Println(blue("## Docker Compose Version"))
fmt.Println(getDockerComposeVersion())
- fmt.Println("## Kubernetes Version")
+ fmt.Println(blue("## Kubernetes Version"))
fmt.Println(getKubernetesVersion())
- fmt.Println("## OpenIM Versions")
- fmt.Println(getOpenIMServerVersion())
- fmt.Println(getOpenIMClientVersion())
+ // fmt.Println(blue("## OpenIM Versions"))
+ // fmt.Println(getOpenIMServerVersion())
+ // clientVersion, err := getOpenIMClientVersion()
+ // if err != nil {
+ // fmt.Println(red("Error getting OpenIM Client Version: "), err)
+ // } else {
+ // fmt.Println(clientVersion)
+ // }
}
From cc1f7739e13a1418260259ee23cec7ab453fbd8d Mon Sep 17 00:00:00 2001
From: Xinwei Xiong <3293172751@qq.com>
Date: Mon, 30 Oct 2023 21:26:11 +0800
Subject: [PATCH 7/7] docs: update readme docs (#1304)
* docs: update readme docs
* Update Makefile
* Update README.md
---
Makefile | 2 +-
README.md | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 1d3544ed6..67f595fb4 100644
--- a/Makefile
+++ b/Makefile
@@ -93,7 +93,7 @@ start:
stop:
@$(MAKE) go.stop
-## restart: Restart openim ✨
+## restart: Restart openim (make init configuration file is initialized) ✨
.PHONY: restart
restart: clean stop build init start check
diff --git a/README.md b/README.md
index dd0a674d2..0a569af6e 100644
--- a/README.md
+++ b/README.md
@@ -61,7 +61,7 @@ It's crafted in Golang and supports cross-platform deployment, ensuring a cohere
+ **REST API**: OpenIMServer provides REST API for business systems, aiming to empower your operations with additional functionalities like group creation and message push via backend interfaces.
+ **Callbacks**: To expand its utility across varied business forms, OpenIMServer offers callback capabilities. That is, it sends a request to the business server before or after an event occurs, such as sending a message, enriching the interaction and data exchange flow in the communication processes.
-👉 **[Learn More](https://doc.rentsoft.cn/guides/introduction/product)**
+👉 **[Learn More](https://docs.openim.io/guides/introduction/product)**
-+ **[Source Code Deployment Guide](https://doc.rentsoft.cn/guides/gettingStarted/imSourceCodeDeployment)**
-+ **[Docker Deployment Guide](https://doc.rentsoft.cn/guides/gettingStarted/dockerCompose)**
++ **[Source Code Deployment Guide](https://docs.openim.io/guides/gettingStarted/imSourceCodeDeployment)**
++ **[Production deployment of Linux systems](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/install-openim-linux-system.md)**
++ **[Docker Deployment Guide](https://docs.openim.io/guides/gettingStarted/dockerCompose)**
+ **[Kubernetes Deployment Guide](https://github.com/openimsdk/open-im-server/tree/main/deployments)**