From 1b8a3b0b75a59b762c7a3ea25b4a0edcc992a25f Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:24:39 +0800 Subject: [PATCH 01/41] fix: resolve deadlock in cache eviction and improve GetBatch implementation and full id version (#3591) * fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation --- pkg/localcache/cache.go | 27 ++++++----- pkg/localcache/cache_test.go | 67 ++++++++++++++++++++++++++++ pkg/localcache/init.go | 4 -- pkg/localcache/lru/lru_expiration.go | 49 +++++++++++++++++++- pkg/localcache/lru/lru_slot.go | 6 +-- 5 files changed, 133 insertions(+), 20 deletions(-) diff --git a/pkg/localcache/cache.go b/pkg/localcache/cache.go index 07d36cf46..b2376d6f1 100644 --- a/pkg/localcache/cache.go +++ b/pkg/localcache/cache.go @@ -47,15 +47,15 @@ func New[V any](opts ...Option) Cache[V] { if opt.localSlotNum > 0 && opt.localSlotSize > 0 { createSimpleLRU := func() lru.LRU[string, V] { if opt.expirationEvict { - return lru.NewExpirationLRU(opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict) + return lru.NewExpirationLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict) } else { - return lru.NewLazyLRU(opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict) + return lru.NewLazyLRU[string, V](opt.localSlotSize, opt.localSuccessTTL, opt.localFailedTTL, opt.target, c.onEvict) } } if opt.localSlotNum == 1 { c.local = createSimpleLRU() } else { - c.local = lru.NewSlotLRU(opt.localSlotNum, LRUStringHash, createSimpleLRU) + c.local = lru.NewSlotLRU[string, V](opt.localSlotNum, LRUStringHash, createSimpleLRU) } if opt.linkSlotNum > 0 { c.link = link.New(opt.linkSlotNum) @@ -71,14 +71,19 @@ type cache[V any] struct { } func (c *cache[V]) onEvict(key string, value V) { - _ = value - if c.link != nil { - lks := c.link.Del(key) - for k := range lks { - if key != k { // prevent deadlock - c.local.Del(k) - } + // Do not delete other keys while the underlying LRU still holds its lock; + // defer linked deletions to avoid re-entering the same slot and deadlocking. + if lks := c.link.Del(key); len(lks) > 0 { + go c.delLinked(key, lks) + } + } +} + +func (c *cache[V]) delLinked(src string, keys map[string]struct{}) { + for k := range keys { + if src != k { + c.local.Del(k) } } } @@ -105,7 +110,7 @@ func (c *cache[V]) Get(ctx context.Context, key string, fetch func(ctx context.C func (c *cache[V]) GetLink(ctx context.Context, key string, fetch func(ctx context.Context) (V, error), link ...string) (V, error) { if c.local != nil { return c.local.Get(key, func() (V, error) { - if len(link) > 0 { + if len(link) > 0 && c.link != nil { c.link.Link(key, link...) } return fetch(ctx) diff --git a/pkg/localcache/cache_test.go b/pkg/localcache/cache_test.go index c206e6799..13eb20797 100644 --- a/pkg/localcache/cache_test.go +++ b/pkg/localcache/cache_test.go @@ -22,6 +22,8 @@ import ( "sync/atomic" "testing" "time" + + "github.com/openimsdk/open-im-server/v3/pkg/localcache/lru" ) func TestName(t *testing.T) { @@ -91,3 +93,68 @@ func TestName(t *testing.T) { t.Log("del", del.Load()) // 137.35s } + +// Test deadlock scenario when eviction callback deletes a linked key that hashes to the same slot. +func TestCacheEvictDeadlock(t *testing.T) { + ctx := context.Background() + c := New[string](WithLocalSlotNum(1), WithLocalSlotSize(1), WithLazy()) + + if _, err := c.GetLink(ctx, "k1", func(ctx context.Context) (string, error) { + return "v1", nil + }, "k2"); err != nil { + t.Fatalf("seed cache failed: %v", err) + } + + done := make(chan struct{}) + go func() { + defer close(done) + _, _ = c.GetLink(ctx, "k2", func(ctx context.Context) (string, error) { + return "v2", nil + }, "k1") + }() + + select { + case <-done: + // expected to finish quickly; current implementation deadlocks here. + case <-time.After(time.Second): + t.Fatal("GetLink deadlocked during eviction of linked key") + } +} + +func TestExpirationLRUGetBatch(t *testing.T) { + l := lru.NewExpirationLRU[string, string](2, time.Minute, time.Second*5, EmptyTarget{}, nil) + + keys := []string{"a", "b"} + values, err := l.GetBatch(keys, func(keys []string) (map[string]string, error) { + res := make(map[string]string) + for _, k := range keys { + res[k] = k + "_v" + } + return res, nil + }) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + if len(values) != len(keys) { + t.Fatalf("expected %d values, got %d", len(keys), len(values)) + } + for _, k := range keys { + if v, ok := values[k]; !ok || v != k+"_v" { + t.Fatalf("unexpected value for %s: %q, ok=%v", k, v, ok) + } + } + + // second batch should hit cache + values, err = l.GetBatch(keys, func(keys []string) (map[string]string, error) { + t.Fatalf("should not fetch on cache hit") + return nil, nil + }) + if err != nil { + t.Fatalf("unexpected error on cache hit: %v", err) + } + for _, k := range keys { + if v, ok := values[k]; !ok || v != k+"_v" { + t.Fatalf("unexpected cached value for %s: %q, ok=%v", k, v, ok) + } + } +} diff --git a/pkg/localcache/init.go b/pkg/localcache/init.go index ad339da7c..d0bccaa7e 100644 --- a/pkg/localcache/init.go +++ b/pkg/localcache/init.go @@ -33,10 +33,6 @@ func InitLocalCache(localCache *config.LocalCache) { Local config.CacheConfig Keys []string }{ - { - Local: localCache.Auth, - Keys: []string{cachekey.UidPidToken}, - }, { Local: localCache.User, Keys: []string{cachekey.UserInfoKey, cachekey.UserGlobalRecvMsgOptKey}, diff --git a/pkg/localcache/lru/lru_expiration.go b/pkg/localcache/lru/lru_expiration.go index df6bacbf4..4197cacec 100644 --- a/pkg/localcache/lru/lru_expiration.go +++ b/pkg/localcache/lru/lru_expiration.go @@ -52,8 +52,53 @@ type ExpirationLRU[K comparable, V any] struct { } func (x *ExpirationLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) { - //TODO implement me - panic("implement me") + var ( + err error + results = make(map[K]V) + misses = make([]K, 0, len(keys)) + ) + + for _, key := range keys { + x.lock.Lock() + v, ok := x.core.Get(key) + x.lock.Unlock() + if ok { + x.target.IncrGetHit() + v.lock.RLock() + results[key] = v.value + if v.err != nil && err == nil { + err = v.err + } + v.lock.RUnlock() + continue + } + misses = append(misses, key) + } + + if len(misses) == 0 { + return results, err + } + + fetchValues, fetchErr := fetch(misses) + if fetchErr != nil && err == nil { + err = fetchErr + } + + for key, val := range fetchValues { + results[key] = val + if fetchErr != nil { + x.target.IncrGetFailed() + continue + } + x.target.IncrGetSuccess() + item := &expirationLruItem[V]{value: val} + x.lock.Lock() + x.core.Add(key, item) + x.lock.Unlock() + } + + // any keys not returned from fetch remain absent (no cache write) + return results, err } func (x *ExpirationLRU[K, V]) Get(key K, fetch func() (V, error)) (V, error) { diff --git a/pkg/localcache/lru/lru_slot.go b/pkg/localcache/lru/lru_slot.go index 14ee3b50f..077219b75 100644 --- a/pkg/localcache/lru/lru_slot.go +++ b/pkg/localcache/lru/lru_slot.go @@ -35,7 +35,7 @@ type slotLRU[K comparable, V any] struct { func (x *slotLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error)) (map[K]V, error) { var ( slotKeys = make(map[uint64][]K) - kVs = make(map[K]V) + vs = make(map[K]V) ) for _, k := range keys { @@ -49,10 +49,10 @@ func (x *slotLRU[K, V]) GetBatch(keys []K, fetch func(keys []K) (map[K]V, error) return nil, err } for key, value := range batches { - kVs[key] = value + vs[key] = value } } - return kVs, nil + return vs, nil } func (x *slotLRU[K, V]) getIndex(k K) uint64 { From c97d63754b281655f1c54510a3cf6039c4fb067b Mon Sep 17 00:00:00 2001 From: Gagan Singh <79045046+ozudev@users.noreply.github.com> Date: Mon, 15 Dec 2025 01:16:29 -0800 Subject: [PATCH 02/41] Simplify iOS background push gating (#3611) (#3612) --- internal/msggateway/hub_server.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index 8374af06d..6467b7e0f 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -152,19 +152,16 @@ func (s *Server) pushToUser(ctx context.Context, userID string, msgData *sdkws.M userPlatform := &msggateway.SingleMsgToUserPlatform{ RecvPlatFormID: int32(client.PlatformID), } - if !client.IsBackground || - (client.IsBackground && client.PlatformID != constant.IOSPlatformID) { - err := client.PushMessage(ctx, msgData) - if err != nil { - log.ZWarn(ctx, "online push msg failed", err, "userID", userID, "platformID", client.PlatformID) - userPlatform.ResultCode = int64(servererrs.ErrPushMsgErr.Code()) - } else { - if _, ok := s.pushTerminal[client.PlatformID]; ok { - result.OnlinePush = true - } - } - } else { + if client.IsBackground && client.PlatformID == constant.IOSPlatformID { userPlatform.ResultCode = int64(servererrs.ErrIOSBackgroundPushErr.Code()) + result.Resp = append(result.Resp, userPlatform) + continue + } + if err := client.PushMessage(ctx, msgData); err != nil { + log.ZWarn(ctx, "online push msg failed", err, "userID", userID, "platformID", client.PlatformID) + userPlatform.ResultCode = int64(servererrs.ErrPushMsgErr.Code()) + } else if _, ok := s.pushTerminal[client.PlatformID]; ok { + result.OnlinePush = true } result.Resp = append(result.Resp, userPlatform) } From 6f33c0a51518e14e6be37e3ff420f73b49e58d18 Mon Sep 17 00:00:00 2001 From: ribin2333 Date: Tue, 23 Dec 2025 14:37:32 +0800 Subject: [PATCH 03/41] fix: reset user conversation seq when rejoining group to resolve message recall issue (#3640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: reset user conversation seq when rejoining group to resolve message recall issue * fix: refactor setMemberJoinSeq based on review feedback * group: 入群个人上限重置为不受限值;退出个人上限固化;通知控制入群 minSeq --- internal/rpc/group/group.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 3700c054a..e254033cc 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -17,6 +17,7 @@ package group import ( "context" "fmt" + "math" "math/big" "math/rand" "strconv" @@ -472,6 +473,9 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite g.notification.GroupApplicationAgreeMemberEnterNotification(ctx, req.GroupID, req.SendMessage, opUserID, userIDs...) } } + if err := g.setMemberJoinSeq(ctx, req.GroupID, req.InvitedUserIDs); err != nil { + return nil, err + } return &pbgroup.InviteUserToGroupResp{}, nil } @@ -905,6 +909,9 @@ func (g *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup return nil, err } } + if err := g.setMemberJoinSeq(ctx, req.GroupID, []string{req.FromUserID}); err != nil { + return nil, err + } } case constant.GroupResponseRefuse: g.notification.GroupApplicationRejectedNotification(ctx, req) @@ -967,6 +974,9 @@ func (g *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq) if err = g.notification.MemberEnterNotification(ctx, req.GroupID, req.InviterUserID); err != nil { return nil, err } + if err := g.setMemberJoinSeq(ctx, req.GroupID, []string{req.InviterUserID}); err != nil { + return nil, err + } g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, req) return &pbgroup.JoinGroupResp{}, nil @@ -1028,6 +1038,11 @@ func (g *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, maxSeq) } +func (g *groupServer) setMemberJoinSeq(ctx context.Context, groupID string, userIDs []string) error { + conversationID := msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, groupID) + return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, math.MaxInt64) +} + func (g *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInfoReq) (*pbgroup.SetGroupInfoResp, error) { var opMember *model.GroupMember if !authverify.IsAdmin(ctx) { From 78b255396fc280089dbeffddd8051407984d7d1e Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Thu, 25 Dec 2025 16:27:16 +0800 Subject: [PATCH 04/41] feat: replace LongConn with ClientConn interface and simplify message handling (#3643) * fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation * refactor: replace LongConn with ClientConn interface and simplify message handling * refactor: replace LongConn with ClientConn interface and simplify message handling --- internal/msggateway/client.go | 161 ++------------------ internal/msggateway/client_conn.go | 229 +++++++++++++++++++++++++++++ internal/msggateway/context.go | 227 +++++++++++++++++----------- internal/msggateway/long_conn.go | 179 ---------------------- internal/msggateway/ws_server.go | 108 +++++++------- 5 files changed, 438 insertions(+), 466 deletions(-) create mode 100644 internal/msggateway/client_conn.go delete mode 100644 internal/msggateway/long_conn.go diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go index 7b9f4bc0e..74b874e95 100644 --- a/internal/msggateway/client.go +++ b/internal/msggateway/client.go @@ -16,7 +16,6 @@ package msggateway import ( "context" - "encoding/json" "fmt" "sync" "sync/atomic" @@ -31,7 +30,6 @@ import ( "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/mcontext" - "github.com/openimsdk/tools/utils/stringutil" ) var ( @@ -64,7 +62,7 @@ type PingPongHandler func(string) error type Client struct { w *sync.Mutex - conn LongConn + conn ClientConn PlatformID int `json:"platformID"` IsCompress bool `json:"isCompress"` UserID string `json:"userID"` @@ -84,10 +82,10 @@ type Client struct { } // ResetClient updates the client's state with new connection and context information. -func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer LongConnServer) { +func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServer LongConnServer) { c.w = new(sync.Mutex) c.conn = conn - c.PlatformID = stringutil.StringToInt(ctx.GetPlatformID()) + c.PlatformID = ctx.GetPlatformID() c.IsCompress = ctx.GetCompression() c.IsBackground = ctx.GetBackground() c.UserID = ctx.GetUserID() @@ -112,22 +110,6 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer c.subUserIDs = make(map[string]struct{}) } -func (c *Client) pingHandler(appData string) error { - if err := c.conn.SetReadDeadline(pongWait); err != nil { - return err - } - - log.ZDebug(c.ctx, "ping Handler Success.", "appData", appData) - return c.writePongMsg(appData) -} - -func (c *Client) pongHandler(_ string) error { - if err := c.conn.SetReadDeadline(pongWait); err != nil { - return err - } - return nil -} - // readMessage continuously reads messages from the connection. func (c *Client) readMessage() { defer func() { @@ -138,52 +120,25 @@ func (c *Client) readMessage() { c.close() }() - c.conn.SetReadLimit(maxMessageSize) - _ = c.conn.SetReadDeadline(pongWait) - c.conn.SetPongHandler(c.pongHandler) - c.conn.SetPingHandler(c.pingHandler) - c.activeHeartbeat(c.hbCtx) - for { log.ZDebug(c.ctx, "readMessage") - messageType, message, returnErr := c.conn.ReadMessage() + message, returnErr := c.conn.ReadMessage() if returnErr != nil { - log.ZWarn(c.ctx, "readMessage", returnErr, "messageType", messageType) + log.ZWarn(c.ctx, "readMessage", returnErr) c.closedErr = returnErr return } - log.ZDebug(c.ctx, "readMessage", "messageType", messageType) if c.closed.Load() { // The scenario where the connection has just been closed, but the coroutine has not exited c.closedErr = ErrConnClosed return } - switch messageType { - case MessageBinary: - _ = c.conn.SetReadDeadline(pongWait) - parseDataErr := c.handleMessage(message) - if parseDataErr != nil { - c.closedErr = parseDataErr - return - } - case MessageText: - _ = c.conn.SetReadDeadline(pongWait) - parseDataErr := c.handlerTextMessage(message) - if parseDataErr != nil { - c.closedErr = parseDataErr - return - } - case PingMessage: - err := c.writePongMsg("") - log.ZError(c.ctx, "writePongMsg", err) - - case CloseMessage: - c.closedErr = ErrClientClosed + parseDataErr := c.handleMessage(message) + if parseDataErr != nil { + c.closedErr = parseDataErr return - - default: } } } @@ -358,109 +313,13 @@ func (c *Client) writeBinaryMsg(resp Resp) error { c.w.Lock() defer c.w.Unlock() - err = c.conn.SetWriteDeadline(writeWait) - if err != nil { - return err - } - if c.IsCompress { resultBuf, compressErr := c.longConnServer.CompressWithPool(encodedBuf) if compressErr != nil { return compressErr } - return c.conn.WriteMessage(MessageBinary, resultBuf) + return c.conn.WriteMessage(resultBuf) } - return c.conn.WriteMessage(MessageBinary, encodedBuf) -} - -// Actively initiate Heartbeat when platform in Web. -func (c *Client) activeHeartbeat(ctx context.Context) { - if c.PlatformID == constant.WebPlatformID { - go func() { - defer func() { - if r := recover(); r != nil { - log.ZPanic(ctx, "activeHeartbeat Panic", errs.ErrPanic(r)) - } - }() - log.ZDebug(ctx, "server initiative send heartbeat start.") - ticker := time.NewTicker(pingPeriod) - defer ticker.Stop() - - for { - select { - case <-ticker.C: - if err := c.writePingMsg(); err != nil { - log.ZWarn(c.ctx, "send Ping Message error.", err) - return - } - case <-c.hbCtx.Done(): - return - } - } - }() - } -} -func (c *Client) writePingMsg() error { - if c.closed.Load() { - return nil - } - - c.w.Lock() - defer c.w.Unlock() - - err := c.conn.SetWriteDeadline(writeWait) - if err != nil { - return err - } - - return c.conn.WriteMessage(PingMessage, nil) -} - -func (c *Client) writePongMsg(appData string) error { - log.ZDebug(c.ctx, "write Pong Msg in Server", "appData", appData) - if c.closed.Load() { - log.ZWarn(c.ctx, "is closed in server", nil, "appdata", appData, "closed err", c.closedErr) - return nil - } - - c.w.Lock() - defer c.w.Unlock() - - err := c.conn.SetWriteDeadline(writeWait) - if err != nil { - log.ZWarn(c.ctx, "SetWriteDeadline in Server have error", errs.Wrap(err), "writeWait", writeWait, "appData", appData) - return errs.Wrap(err) - } - err = c.conn.WriteMessage(PongMessage, []byte(appData)) - if err != nil { - log.ZWarn(c.ctx, "Write Message have error", errs.Wrap(err), "Pong msg", PongMessage) - } - - return errs.Wrap(err) -} - -func (c *Client) handlerTextMessage(b []byte) error { - var msg TextMessage - if err := json.Unmarshal(b, &msg); err != nil { - return err - } - switch msg.Type { - case TextPong: - return nil - case TextPing: - msg.Type = TextPong - msgData, err := json.Marshal(msg) - if err != nil { - return err - } - c.w.Lock() - defer c.w.Unlock() - if err := c.conn.SetWriteDeadline(writeWait); err != nil { - return err - } - return c.conn.WriteMessage(MessageText, msgData) - default: - return fmt.Errorf("not support message type %s", msg.Type) - } + return c.conn.WriteMessage(encodedBuf) } diff --git a/internal/msggateway/client_conn.go b/internal/msggateway/client_conn.go new file mode 100644 index 000000000..15a0d8c07 --- /dev/null +++ b/internal/msggateway/client_conn.go @@ -0,0 +1,229 @@ +package msggateway + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "sync/atomic" + "time" + + "github.com/gorilla/websocket" + + "github.com/openimsdk/tools/log" +) + +var ErrWriteFull = fmt.Errorf("websocket write buffer full,close connection") + +type ClientConn interface { + ReadMessage() ([]byte, error) + WriteMessage(message []byte) error + Close() error +} + +type websocketMessage struct { + MessageType int + Data []byte +} + +func NewWebSocketClientConn(conn *websocket.Conn, readLimit int64, readTimeout time.Duration, pingInterval time.Duration) ClientConn { + c := &websocketClientConn{ + readTimeout: readTimeout, + conn: conn, + writer: make(chan *websocketMessage, 256), + done: make(chan struct{}), + } + if readLimit > 0 { + c.conn.SetReadLimit(readLimit) + } + c.conn.SetPingHandler(c.pingHandler) + c.conn.SetPongHandler(c.pongHandler) + + go c.loopSend() + if pingInterval > 0 { + go c.doPing(pingInterval) + } + return c +} + +type websocketClientConn struct { + readTimeout time.Duration + conn *websocket.Conn + writer chan *websocketMessage + done chan struct{} + err atomic.Pointer[error] +} + +func (c *websocketClientConn) ReadMessage() ([]byte, error) { + buf, err := c.readMessage() + if err != nil { + return nil, c.closeBy(fmt.Errorf("read message %w", err)) + } + return buf, nil +} + +func (c *websocketClientConn) WriteMessage(message []byte) error { + return c.writeMessage(websocket.BinaryMessage, message) +} + +func (c *websocketClientConn) Close() error { + return c.closeBy(fmt.Errorf("websocket connection closed")) +} + +func (c *websocketClientConn) closeBy(err error) error { + if !c.err.CompareAndSwap(nil, &err) { + return *c.err.Load() + } + close(c.done) + log.ZWarn(context.Background(), "websocket connection closed", err, "remoteAddr", c.conn.RemoteAddr(), + "chan length", len(c.writer)) + return err +} + +func (c *websocketClientConn) writeMessage(messageType int, data []byte) error { + if errPtr := c.err.Load(); errPtr != nil { + return *errPtr + } + select { + case c.writer <- &websocketMessage{MessageType: messageType, Data: data}: + return nil + default: + return c.closeBy(ErrWriteFull) + } +} + +func (c *websocketClientConn) loopSend() { + defer func() { + _ = c.conn.Close() + }() + var err error + for { + select { + case <-c.done: + for { + select { + case msg := <-c.writer: + switch msg.MessageType { + case websocket.TextMessage, websocket.BinaryMessage: + err = c.conn.WriteMessage(msg.MessageType, msg.Data) + default: + err = c.conn.WriteControl(msg.MessageType, msg.Data, time.Time{}) + } + if err != nil { + _ = c.closeBy(err) + return + } + default: + return + } + } + case msg := <-c.writer: + switch msg.MessageType { + case websocket.TextMessage, websocket.BinaryMessage: + err = c.conn.WriteMessage(msg.MessageType, msg.Data) + default: + err = c.conn.WriteControl(msg.MessageType, msg.Data, time.Time{}) + } + if err != nil { + _ = c.closeBy(err) + return + } + } + } +} + +func (c *websocketClientConn) setReadDeadline() error { + deadline := time.Now().Add(c.readTimeout) + return c.conn.SetReadDeadline(deadline) +} + +func (c *websocketClientConn) readMessage() ([]byte, error) { + for { + if err := c.setReadDeadline(); err != nil { + return nil, err + } + messageType, buf, err := c.conn.ReadMessage() + if err != nil { + return nil, err + } + switch messageType { + case websocket.BinaryMessage: + return buf, nil + case websocket.TextMessage: + if err := c.onReadTextMessage(buf); err != nil { + return nil, err + } + case websocket.PingMessage: + if err := c.pingHandler(string(buf)); err != nil { + return nil, err + } + case websocket.PongMessage: + if err := c.pongHandler(string(buf)); err != nil { + return nil, err + } + case websocket.CloseMessage: + if len(buf) == 0 { + return nil, errors.New("websocket connection closed by peer") + } + return nil, fmt.Errorf("websocket connection closed by peer, data %s", string(buf)) + default: + return nil, fmt.Errorf("unknown websocket message type %d", messageType) + } + } +} + +func (c *websocketClientConn) onReadTextMessage(buf []byte) error { + var msg struct { + Type string `json:"type"` + Body json.RawMessage `json:"body"` + } + if err := json.Unmarshal(buf, &msg); err != nil { + return err + } + switch msg.Type { + case TextPong: + return nil + case TextPing: + msg.Type = TextPong + msgData, err := json.Marshal(msg) + if err != nil { + return err + } + return c.writeMessage(websocket.TextMessage, msgData) + default: + return fmt.Errorf("not support text message type %s", msg.Type) + } +} + +func (c *websocketClientConn) pingHandler(appData string) error { + log.ZDebug(context.Background(), "ping handler recv ping", "remoteAddr", c.conn.RemoteAddr(), "appData", appData) + if err := c.setReadDeadline(); err != nil { + return err + } + err := c.conn.WriteControl(websocket.PongMessage, []byte(appData), time.Now().Add(time.Second*1)) + if err != nil { + log.ZWarn(context.Background(), "ping handler write pong error", err, "remoteAddr", c.conn.RemoteAddr(), "appData", appData) + } + log.ZDebug(context.Background(), "ping handler write pong success", "remoteAddr", c.conn.RemoteAddr(), "appData", appData) + return nil +} + +func (c *websocketClientConn) pongHandler(string) error { + return nil +} + +func (c *websocketClientConn) doPing(d time.Duration) { + ticker := time.NewTicker(d) + defer ticker.Stop() + for { + select { + case <-c.done: + return + case <-ticker.C: + if err := c.writeMessage(websocket.PingMessage, nil); err != nil { + _ = c.closeBy(fmt.Errorf("send ping %w", err)) + return + } + } + } +} diff --git a/internal/msggateway/context.go b/internal/msggateway/context.go index 37b5a7cdc..9fa28e667 100644 --- a/internal/msggateway/context.go +++ b/internal/msggateway/context.go @@ -15,6 +15,8 @@ package msggateway import ( + "encoding/base64" + "encoding/json" "net/http" "net/url" "strconv" @@ -24,10 +26,21 @@ import ( "github.com/openimsdk/protocol/constant" "github.com/openimsdk/tools/utils/encrypt" - "github.com/openimsdk/tools/utils/stringutil" "github.com/openimsdk/tools/utils/timeutil" ) +type UserConnContextInfo struct { + Token string `json:"token"` + UserID string `json:"userID"` + PlatformID int `json:"platformID"` + OperationID string `json:"operationID"` + Compression string `json:"compression"` + SDKType string `json:"sdkType"` + SendResponse bool `json:"sendResponse"` + Background bool `json:"background"` + SDKVersion string `json:"sdkVersion"` +} + type UserConnContext struct { RespWriter http.ResponseWriter Req *http.Request @@ -35,6 +48,7 @@ type UserConnContext struct { Method string RemoteAddr string ConnID string + info *UserConnContextInfo } func (c *UserConnContext) Deadline() (deadline time.Time, ok bool) { @@ -58,9 +72,11 @@ func (c *UserConnContext) Value(key any) any { case constant.ConnID: return c.GetConnID() case constant.OpUserPlatform: - return constant.PlatformIDToName(stringutil.StringToInt(c.GetPlatformID())) + return c.GetPlatformID() case constant.RemoteAddr: return c.RemoteAddr + case SDKVersion: + return c.info.SDKVersion default: return "" } @@ -83,30 +99,92 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont func newTempContext() *UserConnContext { return &UserConnContext{ - Req: &http.Request{URL: &url.URL{}}, + Req: &http.Request{URL: &url.URL{}}, + info: &UserConnContextInfo{}, } } +func (c *UserConnContext) ParseEssentialArgs() error { + query := c.Req.URL.Query() + if data := query.Get("v"); data != "" { + return c.parseByJson(data) + } else { + return c.parseByQuery(query, c.Req.Header) + } +} + +func (c *UserConnContext) parseByQuery(query url.Values, header http.Header) error { + info := UserConnContextInfo{ + Token: query.Get(Token), + UserID: query.Get(WsUserID), + OperationID: query.Get(OperationID), + Compression: query.Get(Compression), + SDKType: query.Get(SDKType), + SDKVersion: query.Get(SDKVersion), + } + platformID, err := strconv.Atoi(query.Get(PlatformID)) + if err != nil { + return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int") + } + info.PlatformID = platformID + if val := query.Get(SendResponse); val != "" { + ok, err := strconv.ParseBool(val) + if err != nil { + return servererrs.ErrConnArgsErr.WrapMsg("isMsgResp is not bool") + } + info.SendResponse = ok + } + if info.Compression == "" { + info.Compression = header.Get(Compression) + } + background, err := strconv.ParseBool(query.Get(BackgroundStatus)) + if err != nil { + return err + } + info.Background = background + return c.checkInfo(&info) +} + +func (c *UserConnContext) parseByJson(data string) error { + reqInfo, err := base64.RawURLEncoding.DecodeString(data) + if err != nil { + return servererrs.ErrConnArgsErr.WrapMsg("data is not base64") + } + var info UserConnContextInfo + if err := json.Unmarshal(reqInfo, &info); err != nil { + return servererrs.ErrConnArgsErr.WrapMsg("data is not json", "info", err.Error()) + } + return c.checkInfo(&info) +} + +func (c *UserConnContext) checkInfo(info *UserConnContextInfo) error { + if info.OperationID == "" { + return servererrs.ErrConnArgsErr.WrapMsg("operationID is empty") + } + if info.Token == "" { + return servererrs.ErrConnArgsErr.WrapMsg("token is empty") + } + if info.UserID == "" { + return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty") + } + if _, ok := constant.PlatformID2Name[info.PlatformID]; !ok { + return servererrs.ErrConnArgsErr.WrapMsg("platformID is invalid") + } + switch info.SDKType { + case "": + info.SDKType = GoSDK + case GoSDK, JsSDK: + default: + return servererrs.ErrConnArgsErr.WrapMsg("sdkType is invalid") + } + c.info = info + return nil +} + func (c *UserConnContext) GetRemoteAddr() string { return c.RemoteAddr } -func (c *UserConnContext) Query(key string) (string, bool) { - var value string - if value = c.Req.URL.Query().Get(key); value == "" { - return value, false - } - return value, true -} - -func (c *UserConnContext) GetHeader(key string) (string, bool) { - var value string - if value = c.Req.Header.Get(key); value == "" { - return value, false - } - return value, true -} - func (c *UserConnContext) SetHeader(key, value string) { c.RespWriter.Header().Set(key, value) } @@ -120,97 +198,76 @@ func (c *UserConnContext) GetConnID() string { } func (c *UserConnContext) GetUserID() string { - return c.Req.URL.Query().Get(WsUserID) + if c == nil || c.info == nil { + return "" + } + return c.info.UserID } -func (c *UserConnContext) GetPlatformID() string { - return c.Req.URL.Query().Get(PlatformID) +func (c *UserConnContext) GetPlatformID() int { + if c == nil || c.info == nil { + return 0 + } + return c.info.PlatformID } func (c *UserConnContext) GetOperationID() string { - return c.Req.URL.Query().Get(OperationID) + if c == nil || c.info == nil { + return "" + } + return c.info.OperationID } func (c *UserConnContext) SetOperationID(operationID string) { - values := c.Req.URL.Query() - values.Set(OperationID, operationID) - c.Req.URL.RawQuery = values.Encode() + if c.info == nil { + c.info = &UserConnContextInfo{} + } + c.info.OperationID = operationID } func (c *UserConnContext) GetToken() string { - return c.Req.URL.Query().Get(Token) -} - -func (c *UserConnContext) GetSDKVersion() string { - return c.Req.URL.Query().Get(SDKVersion) + if c == nil || c.info == nil { + return "" + } + return c.info.Token } func (c *UserConnContext) GetCompression() bool { - compression, exists := c.Query(Compression) - if exists && compression == GzipCompressionProtocol { - return true - } else { - compression, exists := c.GetHeader(Compression) - if exists && compression == GzipCompressionProtocol { - return true - } - } - return false + return c != nil && c.info != nil && c.info.Compression == GzipCompressionProtocol } func (c *UserConnContext) GetSDKType() string { - sdkType := c.Req.URL.Query().Get(SDKType) - if sdkType == "" { - sdkType = GoSDK + if c == nil || c.info == nil { + return GoSDK } - return sdkType + switch c.info.SDKType { + case "", GoSDK: + return GoSDK + case JsSDK: + return JsSDK + default: + return "" + } +} + +func (c *UserConnContext) GetSDKVersion() string { + if c == nil || c.info == nil { + return "" + } + return c.info.SDKVersion } func (c *UserConnContext) ShouldSendResp() bool { - errResp, exists := c.Query(SendResponse) - if exists { - b, err := strconv.ParseBool(errResp) - if err != nil { - return false - } else { - return b - } - } - return false + return c != nil && c.info != nil && c.info.SendResponse } func (c *UserConnContext) SetToken(token string) { - c.Req.URL.RawQuery = Token + "=" + token + if c.info == nil { + c.info = &UserConnContextInfo{} + } + c.info.Token = token } func (c *UserConnContext) GetBackground() bool { - b, err := strconv.ParseBool(c.Req.URL.Query().Get(BackgroundStatus)) - if err != nil { - return false - } - return b -} -func (c *UserConnContext) ParseEssentialArgs() error { - _, exists := c.Query(Token) - if !exists { - return servererrs.ErrConnArgsErr.WrapMsg("token is empty") - } - _, exists = c.Query(WsUserID) - if !exists { - return servererrs.ErrConnArgsErr.WrapMsg("sendID is empty") - } - platformIDStr, exists := c.Query(PlatformID) - if !exists { - return servererrs.ErrConnArgsErr.WrapMsg("platformID is empty") - } - _, err := strconv.Atoi(platformIDStr) - if err != nil { - return servererrs.ErrConnArgsErr.WrapMsg("platformID is not int") - } - switch sdkType, _ := c.Query(SDKType); sdkType { - case "", GoSDK, JsSDK: - default: - return servererrs.ErrConnArgsErr.WrapMsg("sdkType is not go or js") - } - return nil + return c != nil && c.info != nil && c.info.Background } diff --git a/internal/msggateway/long_conn.go b/internal/msggateway/long_conn.go deleted file mode 100644 index c1b3e27c9..000000000 --- a/internal/msggateway/long_conn.go +++ /dev/null @@ -1,179 +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. - -package msggateway - -import ( - "encoding/json" - "net/http" - "time" - - "github.com/openimsdk/tools/apiresp" - - "github.com/gorilla/websocket" - "github.com/openimsdk/tools/errs" -) - -type LongConn interface { - // Close this connection - Close() error - // WriteMessage Write message to connection,messageType means data type,can be set binary(2) and text(1). - WriteMessage(messageType int, message []byte) error - // ReadMessage Read message from connection. - ReadMessage() (int, []byte, error) - // SetReadDeadline sets the read deadline on the underlying network connection, - // after a read has timed out, will return an error. - SetReadDeadline(timeout time.Duration) error - // SetWriteDeadline sets to write deadline when send message,when read has timed out,will return error. - SetWriteDeadline(timeout time.Duration) error - // Dial Try to dial a connection,url must set auth args,header can control compress data - Dial(urlStr string, requestHeader http.Header) (*http.Response, error) - // IsNil Whether the connection of the current long connection is nil - IsNil() bool - // SetConnNil Set the connection of the current long connection to nil - SetConnNil() - // SetReadLimit sets the maximum size for a message read from the peer.bytes - SetReadLimit(limit int64) - SetPongHandler(handler PingPongHandler) - SetPingHandler(handler PingPongHandler) - // GenerateLongConn Check the connection of the current and when it was sent are the same - GenerateLongConn(w http.ResponseWriter, r *http.Request) error -} -type GWebSocket struct { - protocolType int - conn *websocket.Conn - handshakeTimeout time.Duration - writeBufferSize int -} - -func newGWebSocket(protocolType int, handshakeTimeout time.Duration, wbs int) *GWebSocket { - return &GWebSocket{protocolType: protocolType, handshakeTimeout: handshakeTimeout, writeBufferSize: wbs} -} - -func (d *GWebSocket) Close() error { - return d.conn.Close() -} - -func (d *GWebSocket) GenerateLongConn(w http.ResponseWriter, r *http.Request) error { - upgrader := &websocket.Upgrader{ - HandshakeTimeout: d.handshakeTimeout, - CheckOrigin: func(r *http.Request) bool { return true }, - } - if d.writeBufferSize > 0 { // default is 4kb. - upgrader.WriteBufferSize = d.writeBufferSize - } - - conn, err := upgrader.Upgrade(w, r, nil) - if err != nil { - // The upgrader.Upgrade method usually returns enough error messages to diagnose problems that may occur during the upgrade - return errs.WrapMsg(err, "GenerateLongConn: WebSocket upgrade failed") - } - d.conn = conn - return nil -} - -func (d *GWebSocket) WriteMessage(messageType int, message []byte) error { - // d.setSendConn(d.conn) - return d.conn.WriteMessage(messageType, message) -} - -// func (d *GWebSocket) setSendConn(sendConn *websocket.Conn) { -// d.sendConn = sendConn -//} - -func (d *GWebSocket) ReadMessage() (int, []byte, error) { - return d.conn.ReadMessage() -} - -func (d *GWebSocket) SetReadDeadline(timeout time.Duration) error { - return d.conn.SetReadDeadline(time.Now().Add(timeout)) -} - -func (d *GWebSocket) SetWriteDeadline(timeout time.Duration) error { - if timeout <= 0 { - return errs.New("timeout must be greater than 0") - } - - // TODO SetWriteDeadline Future add error handling - if err := d.conn.SetWriteDeadline(time.Now().Add(timeout)); err != nil { - return errs.WrapMsg(err, "GWebSocket.SetWriteDeadline failed") - } - return nil -} - -func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Response, error) { - conn, httpResp, err := websocket.DefaultDialer.Dial(urlStr, requestHeader) - if err != nil { - return httpResp, errs.WrapMsg(err, "GWebSocket.Dial failed", "url", urlStr) - } - d.conn = conn - return httpResp, nil -} - -func (d *GWebSocket) IsNil() bool { - return d.conn == nil - // - // if d.conn != nil { - // return false - // } - // return true -} - -func (d *GWebSocket) SetConnNil() { - d.conn = nil -} - -func (d *GWebSocket) SetReadLimit(limit int64) { - d.conn.SetReadLimit(limit) -} - -func (d *GWebSocket) SetPongHandler(handler PingPongHandler) { - d.conn.SetPongHandler(handler) -} - -func (d *GWebSocket) SetPingHandler(handler PingPongHandler) { - d.conn.SetPingHandler(handler) -} - -func (d *GWebSocket) RespondWithError(err error, w http.ResponseWriter, r *http.Request) error { - if err := d.GenerateLongConn(w, r); err != nil { - return err - } - data, err := json.Marshal(apiresp.ParseError(err)) - if err != nil { - _ = d.Close() - return errs.WrapMsg(err, "json marshal failed") - } - - if err := d.WriteMessage(MessageText, data); err != nil { - _ = d.Close() - return errs.WrapMsg(err, "WriteMessage failed") - } - _ = d.Close() - return nil -} - -func (d *GWebSocket) RespondWithSuccess() error { - data, err := json.Marshal(apiresp.ParseError(nil)) - if err != nil { - _ = d.Close() - return errs.WrapMsg(err, "json marshal failed") - } - - if err := d.WriteMessage(MessageText, data); err != nil { - _ = d.Close() - return errs.WrapMsg(err, "WriteMessage failed") - } - return nil -} diff --git a/internal/msggateway/ws_server.go b/internal/msggateway/ws_server.go index d490cc8b9..0f7e1f8e6 100644 --- a/internal/msggateway/ws_server.go +++ b/internal/msggateway/ws_server.go @@ -2,18 +2,20 @@ package msggateway import ( "context" + "encoding/json" "fmt" "net/http" "sync" "sync/atomic" "time" + "github.com/gorilla/websocket" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" + "github.com/openimsdk/tools/apiresp" "github.com/openimsdk/open-im-server/v3/pkg/common/webhook" "github.com/openimsdk/open-im-server/v3/pkg/rpccache" pbAuth "github.com/openimsdk/protocol/auth" - "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/mcontext" "github.com/go-playground/validator/v10" @@ -23,10 +25,11 @@ import ( "github.com/openimsdk/protocol/msggateway" "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/log" - "github.com/openimsdk/tools/utils/stringutil" "golang.org/x/sync/errgroup" ) +var wsSuccessResponse, _ = json.Marshal(&apiresp.ApiResponse{}) + type LongConnServer interface { Run(ctx context.Context) error wsHandler(w http.ResponseWriter, r *http.Request) @@ -43,6 +46,7 @@ type LongConnServer interface { } type WsServer struct { + websocket *websocket.Upgrader msgGatewayConfig *Config port int wsMaxConnNum int64 @@ -136,9 +140,13 @@ func NewWsServer(msgGatewayConfig *Config, opts ...Option) *WsServer { o(&config) } //userRpcClient := rpcclient.NewUserRpcClient(client, config.Discovery.RpcService.User, config.Share.IMAdminUser) - + upgrader := &websocket.Upgrader{ + HandshakeTimeout: config.handshakeTimeout, + CheckOrigin: func(r *http.Request) bool { return true }, + } v := validator.New() return &WsServer{ + websocket: upgrader, msgGatewayConfig: msgGatewayConfig, port: config.port, wsMaxConnNum: config.maxConnNum, @@ -260,8 +268,7 @@ func (ws *WsServer) registerClient(client *Client) { ) oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID) - log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID, - "sdkVersion", client.SDKVersion) + log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID) if !userOK { ws.clients.Set(client.UserID, client) @@ -448,7 +455,7 @@ func (ws *WsServer) unregisterClient(client *Client) { // validateRespWithRequest checks if the response matches the expected userID and platformID. func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.ParseTokenResp) error { userID := ctx.GetUserID() - platformID := stringutil.StringToInt32(ctx.GetPlatformID()) + platformID := int32(ctx.GetPlatformID()) if resp.UserID != userID { return servererrs.ErrTokenInvalid.WrapMsg(fmt.Sprintf("token uid %s != userID %s", resp.UserID, userID)) } @@ -458,19 +465,37 @@ func (ws *WsServer) validateRespWithRequest(ctx *UserConnContext, resp *pbAuth.P return nil } +func (ws *WsServer) handlerError(ctx *UserConnContext, w http.ResponseWriter, r *http.Request, err error) { + if !ctx.ShouldSendResp() { + httpError(ctx, err) + return + } + // the browser cannot get the response of upgrade failure + data, err := json.Marshal(apiresp.ParseError(err)) + if err != nil { + log.ZError(ctx, "json marshal failed", err) + return + } + conn, upgradeErr := ws.websocket.Upgrade(w, r, nil) + if upgradeErr != nil { + log.ZWarn(ctx, "websocket upgrade failed", upgradeErr, "respErr", err, "resp", string(data)) + return + } + defer conn.Close() + if err := conn.WriteMessage(websocket.TextMessage, data); err != nil { + log.ZWarn(ctx, "WriteMessage failed", err, "respErr", err, "resp", string(data)) + return + } +} + func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) { // Create a new connection context connContext := newContext(w, r) - if !ws.ready.Load() { - httpError(connContext, errs.New("ws server not ready")) - return - } - // Check if the current number of online user connections exceeds the maximum limit if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum { // If it exceeds the maximum connection number, return an error via HTTP and stop processing - httpError(connContext, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit")) + ws.handlerError(connContext, w, r, servererrs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit")) return } @@ -478,31 +503,14 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) { err := connContext.ParseEssentialArgs() if err != nil { // If there's an error during parsing, return an error via HTTP and stop processing - - httpError(connContext, err) - return - } - - if ws.authClient == nil { - httpError(connContext, errs.New("auth client is not initialized")) + ws.handlerError(connContext, w, r, err) return } // Call the authentication client to parse the Token obtained from the context resp, err := ws.authClient.ParseToken(connContext, connContext.GetToken()) if err != nil { - // If there's an error parsing the Token, decide whether to send the error message via WebSocket based on the context flag - shouldSendError := connContext.ShouldSendResp() - if shouldSendError { - // Create a WebSocket connection object and attempt to send the error message via WebSocket - wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize) - if err := wsLongConn.RespondWithError(err, w, r); err == nil { - // If the error message is successfully sent via WebSocket, stop processing - return - } - } - // If sending via WebSocket is not required or fails, return the error via HTTP and stop processing - httpError(connContext, err) + ws.handlerError(connContext, w, r, err) return } @@ -510,32 +518,30 @@ func (ws *WsServer) wsHandler(w http.ResponseWriter, r *http.Request) { err = ws.validateRespWithRequest(connContext, resp) if err != nil { // If validation fails, return an error via HTTP and stop processing - httpError(connContext, err) + ws.handlerError(connContext, w, r, err) return } - - log.ZDebug(connContext, "new conn", "token", connContext.GetToken()) - // Create a WebSocket long connection object - wsLongConn := newGWebSocket(WebSocket, ws.handshakeTimeout, ws.writeBufferSize) - if err := wsLongConn.GenerateLongConn(w, r); err != nil { - //If the creation of the long connection fails, the error is handled internally during the handshake process. - log.ZWarn(connContext, "long connection fails", err) + conn, err := ws.websocket.Upgrade(w, r, nil) + if err != nil { + log.ZWarn(connContext, "websocket upgrade failed", err) return - } else { - // Check if a normal response should be sent via WebSocket - shouldSendSuccessResp := connContext.ShouldSendResp() - if shouldSendSuccessResp { - // Attempt to send a success message through WebSocket - if err := wsLongConn.RespondWithSuccess(); err != nil { - // If the success message is successfully sent, end further processing - return - } + } + if connContext.ShouldSendResp() { + if err := conn.WriteMessage(websocket.TextMessage, wsSuccessResponse); err != nil { + log.ZWarn(connContext, "WriteMessage first response", err) + return } } - // Retrieve a client object from the client pool, reset its state, and associate it with the current WebSocket long connection - client := ws.clientPool.Get().(*Client) - client.ResetClient(connContext, wsLongConn, ws) + log.ZDebug(connContext, "new conn", "token", connContext.GetToken()) + + var pingInterval time.Duration + if connContext.GetPlatformID() == constant.WebPlatformID { + pingInterval = pingPeriod + } + + client := new(Client) + client.ResetClient(connContext, NewWebSocketClientConn(conn, maxMessageSize, pongWait, pingInterval), ws) // Register the client with the server and start message processing ws.registerChan <- client From 0a93fb1b6d78d7afbb8d5e0f2a183165e3f781db Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:01:51 +0800 Subject: [PATCH 05/41] fix(group): move member count retrieval after member deletion for accurate updates (#3651) --- internal/rpc/group/group.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index e254033cc..bc8834490 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -606,10 +606,6 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou } } } - num, err := g.db.FindGroupMemberNum(ctx, req.GroupID) - if err != nil { - return nil, err - } ownerUserIDs, err := g.db.GetGroupRoleLevelMemberIDs(ctx, req.GroupID, constant.GroupOwner) if err != nil { return nil, err @@ -621,6 +617,10 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou if err := g.db.DeleteGroupMember(ctx, group.GroupID, req.KickedUserIDs); err != nil { return nil, err } + num, err := g.db.FindGroupMemberNum(ctx, req.GroupID) + if err != nil { + return nil, err + } tips := &sdkws.MemberKickedTips{ Group: &sdkws.GroupInfo{ GroupID: group.GroupID, @@ -630,7 +630,7 @@ func (g *groupServer) KickGroupMember(ctx context.Context, req *pbgroup.KickGrou FaceURL: group.FaceURL, OwnerUserID: ownerUserID, CreateTime: group.CreateTime.UnixMilli(), - MemberCount: num - uint32(len(req.KickedUserIDs)), + MemberCount: num, Ex: group.Ex, Status: group.Status, CreatorUserID: group.CreatorUserID, From fbca49d4319eee0d40395d087b792b0351c069de Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:02:38 +0800 Subject: [PATCH 06/41] fix(group): set max_seq to 0 when join group (#3649) --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/rpc/group/group.go | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index f8c5fa73c..45211ccec 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.73-alpha.17 - github.com/openimsdk/tools v0.0.50-alpha.105 + github.com/openimsdk/protocol v0.0.73-alpha.18 + github.com/openimsdk/tools v0.0.50-alpha.106 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index ea874f8bc..a96abc9c3 100644 --- a/go.sum +++ b/go.sum @@ -349,10 +349,10 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw= github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.73-alpha.17 h1:ddo0QMns1GVwAmrPIPlAQ7uKmThAYLnOt+CIOgLsJyE= -github.com/openimsdk/protocol v0.0.73-alpha.17/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= -github.com/openimsdk/tools v0.0.50-alpha.105 h1:axuCvKXhxY2RGLhpMMFNgBtE0B65T2Sr1JDW3UD9nBs= -github.com/openimsdk/tools v0.0.50-alpha.105/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= +github.com/openimsdk/protocol v0.0.73-alpha.18 h1:LXmDFx3KnMd2mN0/S3Q2U33Ft/DHvplSsINO0/bto/c= +github.com/openimsdk/protocol v0.0.73-alpha.18/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= +github.com/openimsdk/tools v0.0.50-alpha.106 h1:gaqU08IbRxOdL16ZEQNyYLhCTf7K1HNkrik8KZLA+BM= +github.com/openimsdk/tools v0.0.50-alpha.106/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index bc8834490..359ecfa6f 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -17,7 +17,6 @@ package group import ( "context" "fmt" - "math" "math/big" "math/rand" "strconv" @@ -1040,7 +1039,7 @@ func (g *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro func (g *groupServer) setMemberJoinSeq(ctx context.Context, groupID string, userIDs []string) error { conversationID := msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, groupID) - return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, math.MaxInt64) + return g.conversationClient.SetConversationMaxSeq(ctx, conversationID, userIDs, 0) } func (g *groupServer) SetGroupInfo(ctx context.Context, req *pbgroup.SetGroupInfoReq) (*pbgroup.SetGroupInfoResp, error) { From a0e6d9aa69f8a49852c1d82a2dc13221da7ad540 Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Thu, 15 Jan 2026 14:24:17 +0800 Subject: [PATCH 07/41] fix: Mongo Malloc upsert overwrites min_seq initialization (#3657) * fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation * refactor: replace LongConn with ClientConn interface and simplify message handling * refactor: replace LongConn with ClientConn interface and simplify message handling * fix: seq use $setOnInsert for min_seq in conversation update --- pkg/common/storage/database/mgo/seq_conversation.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/storage/database/mgo/seq_conversation.go b/pkg/common/storage/database/mgo/seq_conversation.go index 7971b7e1a..b9eb6c2a9 100644 --- a/pkg/common/storage/database/mgo/seq_conversation.go +++ b/pkg/common/storage/database/mgo/seq_conversation.go @@ -57,8 +57,8 @@ func (s *seqConversationMongo) Malloc(ctx context.Context, conversationID string } filter := map[string]any{"conversation_id": conversationID} update := map[string]any{ - "$inc": map[string]any{"max_seq": size}, - "$set": map[string]any{"min_seq": int64(0)}, + "$inc": map[string]any{"max_seq": size}, + "$setOnInsert": map[string]any{"min_seq": int64(0)}, } opt := options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After).SetProjection(map[string]any{"_id": 0, "max_seq": 1}) lastSeq, err := mongoutil.FindOneAndUpdate[int64](ctx, s.coll, filter, update, opt) From 579db3bd4861cc61cd829764f7ce061a16389b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87bug=E5=9C=A8=E5=93=AA=E9=87=8C?= <35194310+WhereAreBugs@users.noreply.github.com> Date: Wed, 21 Jan 2026 18:10:29 +0800 Subject: [PATCH 08/41] bugfix(conversation):removed unexpectedly called functions and itself to avoid out of index query. (#3668) # Conflicts: # internal/rpc/conversation/conversation.go # pkg/common/storage/database/mgo/conversation.go --- internal/rpc/conversation/conversation.go | 58 ------------------- internal/rpc/msg/delete.go | 9 +-- pkg/common/storage/controller/conversation.go | 6 -- pkg/common/storage/database/conversation.go | 1 - .../storage/database/mgo/conversation.go | 10 ++-- pkg/rpcli/conversation.go | 13 +---- 6 files changed, 10 insertions(+), 87 deletions(-) diff --git a/internal/rpc/conversation/conversation.go b/internal/rpc/conversation/conversation.go index 562a76d82..a48c06051 100644 --- a/internal/rpc/conversation/conversation.go +++ b/internal/rpc/conversation/conversation.go @@ -513,14 +513,6 @@ func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req return &pbconversation.GetUserConversationIDsHashResp{Hash: hash}, nil } -func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbconversation.GetConversationsByConversationIDReq) (*pbconversation.GetConversationsByConversationIDResp, error) { - conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs) - if err != nil { - return nil, err - } - return &pbconversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil -} - func (c *conversationServer) GetConversationOfflinePushUserIDs(ctx context.Context, req *pbconversation.GetConversationOfflinePushUserIDsReq) (*pbconversation.GetConversationOfflinePushUserIDsResp, error) { if req.ConversationID == "" { return nil, errs.ErrArgs.WrapMsg("conversationID is empty") @@ -717,56 +709,6 @@ func (c *conversationServer) GetOwnerConversation(ctx context.Context, req *pbco }, nil } -func (c *conversationServer) GetConversationsNeedClearMsg(ctx context.Context, _ *pbconversation.GetConversationsNeedClearMsgReq) (*pbconversation.GetConversationsNeedClearMsgResp, error) { - num, err := c.conversationDatabase.GetAllConversationIDsNumber(ctx) - if err != nil { - log.ZError(ctx, "GetAllConversationIDsNumber failed", err) - return nil, err - } - const batchNum = 100 - - if num == 0 { - return nil, errs.New("Need Destruct Msg is nil").Wrap() - } - - maxPage := (num + batchNum - 1) / batchNum - - temp := make([]*dbModel.Conversation, 0, maxPage*batchNum) - - for pageNumber := 0; pageNumber < int(maxPage); pageNumber++ { - pagination := &sdkws.RequestPagination{ - PageNumber: int32(pageNumber), - ShowNumber: batchNum, - } - - conversationIDs, err := c.conversationDatabase.PageConversationIDs(ctx, pagination) - if err != nil { - log.ZError(ctx, "PageConversationIDs failed", err, "pageNumber", pageNumber) - continue - } - - // log.ZDebug(ctx, "PageConversationIDs success", "pageNumber", pageNumber, "conversationIDsNum", len(conversationIDs), "conversationIDs", conversationIDs) - if len(conversationIDs) == 0 { - continue - } - - conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, conversationIDs) - if err != nil { - log.ZError(ctx, "GetConversationsByConversationID failed", err, "conversationIDs", conversationIDs) - continue - } - - for _, conversation := range conversations { - if conversation.IsMsgDestruct && conversation.MsgDestructTime != 0 && ((time.Now().UnixMilli() > (conversation.MsgDestructTime + conversation.LatestMsgDestructTime.UnixMilli() + 8*60*60)) || // 8*60*60 is UTC+8 - conversation.LatestMsgDestructTime.IsZero()) { - temp = append(temp, conversation) - } - } - } - - return &pbconversation.GetConversationsNeedClearMsgResp{Conversations: convert.ConversationsDB2Pb(temp)}, nil -} - func (c *conversationServer) GetNotNotifyConversationIDs(ctx context.Context, req *pbconversation.GetNotNotifyConversationIDsReq) (*pbconversation.GetNotNotifyConversationIDsResp, error) { if err := authverify.CheckAccess(ctx, req.UserID); err != nil { return nil, err diff --git a/internal/rpc/msg/delete.go b/internal/rpc/msg/delete.go index d24420ebb..41602e2e6 100644 --- a/internal/rpc/msg/delete.go +++ b/internal/rpc/msg/delete.go @@ -19,7 +19,6 @@ import ( "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/protocol/constant" - "github.com/openimsdk/protocol/conversation" "github.com/openimsdk/protocol/msg" "github.com/openimsdk/protocol/sdkws" "github.com/openimsdk/tools/log" @@ -74,7 +73,7 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms if err := m.MsgDatabase.DeleteMsgsPhysicalBySeqs(ctx, req.ConversationID, req.Seqs); err != nil { return nil, err } - conv, err := m.conversationClient.GetConversationsByConversationID(ctx, req.ConversationID) + conv, err := m.conversationClient.GetConversation(ctx, req.ConversationID, req.UserID) if err != nil { return nil, err } @@ -116,14 +115,12 @@ func (m *msgServer) DeleteMsgPhysical(ctx context.Context, req *msg.DeleteMsgPhy } func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []string, userID string, deleteSyncOpt *msg.DeleteSyncOpt) error { - conversations, err := m.conversationClient.GetConversationsByConversationIDs(ctx, conversationIDs) + conversations, err := m.conversationClient.GetConversations(ctx, conversationIDs, userID) if err != nil { return err } - var existConversations []*conversation.Conversation var existConversationIDs []string for _, conversation := range conversations { - existConversations = append(existConversations, conversation) existConversationIDs = append(existConversationIDs, conversation.ConversationID) } log.ZDebug(ctx, "ClearConversationsMsg", "existConversationIDs", existConversationIDs) @@ -152,7 +149,7 @@ func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []str if err := m.MsgDatabase.SetMinSeqs(ctx, m.getMinSeqs(maxSeqs)); err != nil { return err } - for _, conversation := range existConversations { + for _, conversation := range conversations { tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: []string{conversation.ConversationID}} m.notificationSender.NotificationWithSessionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips) } diff --git a/pkg/common/storage/controller/conversation.go b/pkg/common/storage/controller/conversation.go index d085c7466..5ec62b33c 100644 --- a/pkg/common/storage/controller/conversation.go +++ b/pkg/common/storage/controller/conversation.go @@ -61,8 +61,6 @@ type ConversationDatabase interface { GetAllConversationIDsNumber(ctx context.Context) (int64, error) // PageConversationIDs paginates through conversation IDs based on the specified pagination settings. PageConversationIDs(ctx context.Context, pagination pagination.Pagination) (conversationIDs []string, err error) - // GetConversationsByConversationID retrieves conversations by their IDs. - GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationtb.Conversation, error) // GetConversationIDsNeedDestruct fetches conversations that need to be destructed based on specific criteria. GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationtb.Conversation, error) // GetConversationNotReceiveMessageUserIDs gets user IDs for users in a conversation who have not received messages. @@ -375,10 +373,6 @@ func (c *conversationDatabase) PageConversationIDs(ctx context.Context, paginati return c.conversationDB.PageConversationIDs(ctx, pagination) } -func (c *conversationDatabase) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationtb.Conversation, error) { - return c.conversationDB.GetConversationsByConversationID(ctx, conversationIDs) -} - func (c *conversationDatabase) GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationtb.Conversation, error) { return c.conversationDB.GetConversationIDsNeedDestruct(ctx) } diff --git a/pkg/common/storage/database/conversation.go b/pkg/common/storage/database/conversation.go index 562782346..6a93aa955 100644 --- a/pkg/common/storage/database/conversation.go +++ b/pkg/common/storage/database/conversation.go @@ -39,7 +39,6 @@ type Conversation interface { GetAllConversationIDs(ctx context.Context) ([]string, error) GetAllConversationIDsNumber(ctx context.Context) (int64, error) PageConversationIDs(ctx context.Context, pagination pagination.Pagination) (conversationIDs []string, err error) - GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*model.Conversation, error) GetConversationIDsNeedDestruct(ctx context.Context) ([]*model.Conversation, error) GetConversationNotReceiveMessageUserIDs(ctx context.Context, conversationID string) ([]string, error) FindConversationUserVersion(ctx context.Context, userID string, version uint, limit int) (*model.VersionLog, error) diff --git a/pkg/common/storage/database/mgo/conversation.go b/pkg/common/storage/database/mgo/conversation.go index d5ab046aa..c1d00f0ed 100644 --- a/pkg/common/storage/database/mgo/conversation.go +++ b/pkg/common/storage/database/mgo/conversation.go @@ -47,6 +47,12 @@ func NewConversationMongo(db *mongo.Database) (*ConversationMgo, error) { }, Options: options.Index(), }, + { + Keys: bson.D{ + {Key: "conversation_id", Value: 1}, + }, + Options: options.Index().SetUnique(true), + }, }) if err != nil { return nil, errs.Wrap(err) @@ -232,10 +238,6 @@ func (c *ConversationMgo) PageConversationIDs(ctx context.Context, pagination pa return mongoutil.FindPageOnly[string](ctx, c.coll, bson.M{}, pagination, options.Find().SetProjection(bson.M{"conversation_id": 1})) } -func (c *ConversationMgo) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*model.Conversation, error) { - return mongoutil.Find[*model.Conversation](ctx, c.coll, bson.M{"conversation_id": bson.M{"$in": conversationIDs}}) -} - func (c *ConversationMgo) GetConversationIDsNeedDestruct(ctx context.Context) ([]*model.Conversation, error) { // "is_msg_destruct = 1 && msg_destruct_time != 0 && (UNIX_TIMESTAMP(NOW()) > (msg_destruct_time + UNIX_TIMESTAMP(latest_msg_destruct_time)) || latest_msg_destruct_time is NULL)" return mongoutil.Find[*model.Conversation](ctx, c.coll, bson.M{ diff --git a/pkg/rpcli/conversation.go b/pkg/rpcli/conversation.go index ba5b90cb3..a5b7446a1 100644 --- a/pkg/rpcli/conversation.go +++ b/pkg/rpcli/conversation.go @@ -2,6 +2,7 @@ package rpcli import ( "context" + "github.com/openimsdk/protocol/conversation" "google.golang.org/grpc" ) @@ -30,18 +31,6 @@ func (x *ConversationClient) SetConversations(ctx context.Context, ownerUserIDs return ignoreResp(x.ConversationClient.SetConversations(ctx, req)) } -func (x *ConversationClient) GetConversationsByConversationIDs(ctx context.Context, conversationIDs []string) ([]*conversation.Conversation, error) { - if len(conversationIDs) == 0 { - return nil, nil - } - req := &conversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs} - return extractField(ctx, x.ConversationClient.GetConversationsByConversationID, req, (*conversation.GetConversationsByConversationIDResp).GetConversations) -} - -func (x *ConversationClient) GetConversationsByConversationID(ctx context.Context, conversationID string) (*conversation.Conversation, error) { - return firstValue(x.GetConversationsByConversationIDs(ctx, []string{conversationID})) -} - func (x *ConversationClient) SetConversationMinSeq(ctx context.Context, conversationID string, ownerUserIDs []string, minSeq int64) error { if len(ownerUserIDs) == 0 { return nil From b7200c163c45c5e855b717ceb5be5093a70a7bd5 Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Thu, 22 Jan 2026 16:34:00 +0800 Subject: [PATCH 09/41] feat: add error code for handled friend requests and improve error handling in friend operations (#3670) * fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation * refactor: replace LongConn with ClientConn interface and simplify message handling * refactor: replace LongConn with ClientConn interface and simplify message handling * fix: seq use $setOnInsert for min_seq in conversation update * feat: add error code for handled friend requests and improve error handling in friend operations --- pkg/common/servererrs/code.go | 1 + pkg/common/servererrs/predefine.go | 9 +++++---- pkg/common/storage/controller/friend.go | 18 ++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/common/servererrs/code.go b/pkg/common/servererrs/code.go index 906f890a5..153199b1b 100644 --- a/pkg/common/servererrs/code.go +++ b/pkg/common/servererrs/code.go @@ -70,6 +70,7 @@ const ( BlockedByPeer = 1302 // Blocked by the peer NotPeersFriend = 1303 // Not the peer's friend RelationshipAlreadyError = 1304 // Already in a friend relationship + FriendRequestHandled = 1305 // Friend request has already been handled // Message error codes. MessageHasReadDisable = 1401 diff --git a/pkg/common/servererrs/predefine.go b/pkg/common/servererrs/predefine.go index b1d6b06a9..06f036ae4 100644 --- a/pkg/common/servererrs/predefine.go +++ b/pkg/common/servererrs/predefine.go @@ -51,10 +51,11 @@ var ( ErrMessageHasReadDisable = errs.NewCodeError(MessageHasReadDisable, "MessageHasReadDisable") - ErrCanNotAddYourself = errs.NewCodeError(CanNotAddYourselfError, "CanNotAddYourselfError") - ErrBlockedByPeer = errs.NewCodeError(BlockedByPeer, "BlockedByPeer") - ErrNotPeersFriend = errs.NewCodeError(NotPeersFriend, "NotPeersFriend") - ErrRelationshipAlready = errs.NewCodeError(RelationshipAlreadyError, "RelationshipAlreadyError") + ErrCanNotAddYourself = errs.NewCodeError(CanNotAddYourselfError, "CanNotAddYourselfError") + ErrBlockedByPeer = errs.NewCodeError(BlockedByPeer, "BlockedByPeer") + ErrNotPeersFriend = errs.NewCodeError(NotPeersFriend, "NotPeersFriend") + ErrRelationshipAlready = errs.NewCodeError(RelationshipAlreadyError, "RelationshipAlreadyError") + ErrFriendRequestHandled = errs.NewCodeError(FriendRequestHandled, "FriendRequestHandled") ErrMutedInGroup = errs.NewCodeError(MutedInGroup, "MutedInGroup") ErrMutedGroup = errs.NewCodeError(MutedGroup, "MutedGroup") diff --git a/pkg/common/storage/controller/friend.go b/pkg/common/storage/controller/friend.go index 806468ea1..b2ae3e732 100644 --- a/pkg/common/storage/controller/friend.go +++ b/pkg/common/storage/controller/friend.go @@ -16,9 +16,9 @@ package controller import ( "context" - "fmt" "time" + "github.com/openimsdk/open-im-server/v3/pkg/common/servererrs" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" @@ -109,15 +109,13 @@ func (f *friendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) ( // Retrieve friend IDs of userID1 from the cache userID1FriendIDs, err := f.cache.GetFriendIDs(ctx, userID1) if err != nil { - err = fmt.Errorf("error retrieving friend IDs for user %s: %w", userID1, err) - return + return false, false, err } // Retrieve friend IDs of userID2 from the cache userID2FriendIDs, err := f.cache.GetFriendIDs(ctx, userID2) if err != nil { - err = fmt.Errorf("error retrieving friend IDs for user %s: %w", userID2, err) - return + return false, false, err } // Check if userID2 is in userID1's friend list and vice versa @@ -214,12 +212,12 @@ func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest // Attempt to retrieve the friend request from the database. fr, err := f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID) if err != nil { - return fmt.Errorf("failed to retrieve friend request from %s to %s: %w", friendRequest.FromUserID, friendRequest.ToUserID, err) + return err } // Check if the friend request has already been handled. if fr.HandleResult != 0 { - return fmt.Errorf("friend request from %s to %s has already been processed", friendRequest.FromUserID, friendRequest.ToUserID) + return servererrs.ErrFriendRequestHandled.WrapMsg("friend request has already been processed", "from", friendRequest.FromUserID, "to", friendRequest.ToUserID) } // Log the action of refusing the friend request for debugging and auditing purposes. @@ -232,7 +230,7 @@ func (f *friendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest friendRequest.HandleResult = constant.FriendResponseRefuse friendRequest.HandleTime = time.Now() if err := f.friendRequest.Update(ctx, friendRequest); err != nil { - return fmt.Errorf("failed to update friend request from %s to %s as refused: %w", friendRequest.FromUserID, friendRequest.ToUserID, err) + return err } return nil @@ -350,9 +348,9 @@ func (f *friendDatabase) PageFriendRequestToMe(ctx context.Context, userID strin func (f *friendDatabase) FindFriendsWithError(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*model.Friend, err error) { friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs) if err != nil { - return + return nil, err } - return + return friends, nil } func (f *friendDatabase) FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error) { From 942d155d2dbb0926d25ddbfc4b0d16755d477653 Mon Sep 17 00:00:00 2001 From: icey-yu <119291641+icey-yu@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:44:36 +0800 Subject: [PATCH 10/41] feat: update protocol support botPlatform (#3696) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 45211ccec..01ff77945 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.73-alpha.18 + github.com/openimsdk/protocol v0.0.73-alpha.19 github.com/openimsdk/tools v0.0.50-alpha.106 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 diff --git a/go.sum b/go.sum index a96abc9c3..e77b3cade 100644 --- a/go.sum +++ b/go.sum @@ -349,8 +349,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw= github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.73-alpha.18 h1:LXmDFx3KnMd2mN0/S3Q2U33Ft/DHvplSsINO0/bto/c= -github.com/openimsdk/protocol v0.0.73-alpha.18/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= +github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s= +github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= github.com/openimsdk/tools v0.0.50-alpha.106 h1:gaqU08IbRxOdL16ZEQNyYLhCTf7K1HNkrik8KZLA+BM= github.com/openimsdk/tools v0.0.50-alpha.106/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= From d16a617ba8ff690cb668558bb2e597b4f3cbecf6 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 19 Mar 2026 12:09:02 +0800 Subject: [PATCH 11/41] feat: gomake upgrade (#3702) --- go.mod | 25 ++++++++++++++----------- go.sum | 45 ++++++++++++++++++++++++++------------------- magefile.go | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 38 deletions(-) diff --git a/go.mod b/go.mod index 01ff77945..163f1c9f8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3 -go 1.22.7 +go 1.25.0 require ( firebase.google.com/go/v4 v4.14.1 @@ -13,10 +13,10 @@ require ( github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/openimsdk/protocol v0.0.73-alpha.19 - github.com/openimsdk/tools v0.0.50-alpha.106 + github.com/openimsdk/tools v0.0.50-alpha.113 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 go.mongodb.org/mongo-driver v1.14.0 google.golang.org/api v0.170.0 google.golang.org/grpc v1.71.0 @@ -35,7 +35,7 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/kelindar/bitmap v1.5.2 github.com/likexian/gokit v0.25.13 - github.com/openimsdk/gomake v0.0.15-alpha.11 + github.com/openimsdk/gomake v0.0.17 github.com/redis/go-redis/v9 v9.4.0 github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil v3.21.11+incompatible @@ -76,6 +76,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect github.com/aws/smithy-go v1.22.1 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -90,6 +91,7 @@ require ( github.com/eapache/go-resiliency v1.6.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect + github.com/ebitengine/purego v0.10.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect @@ -98,7 +100,7 @@ require ( github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.4 // indirect @@ -108,7 +110,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/s2a-go v0.1.7 // indirect @@ -135,7 +137,7 @@ require ( github.com/leodido/go-urn v1.4.0 // indirect github.com/lestrrat-go/strftime v1.0.6 // indirect github.com/lithammer/shortuuid v3.0.0+incompatible // indirect - github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de // indirect + github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 // indirect github.com/magefile/mage v1.15.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -152,7 +154,7 @@ require ( github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect + github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect @@ -163,6 +165,7 @@ require ( github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sercand/kuberesolver/v6 v6.0.1 // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect + github.com/shirou/gopsutil/v4 v4.26.2 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect @@ -171,8 +174,8 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect - github.com/tklauser/go-sysconf v0.3.13 // indirect - github.com/tklauser/numcpus v0.7.0 // indirect + github.com/tklauser/go-sysconf v0.3.16 // indirect + github.com/tklauser/numcpus v0.11.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect @@ -196,7 +199,7 @@ require ( golang.org/x/image v0.15.0 // indirect golang.org/x/net v0.34.0 // indirect golang.org/x/oauth2 v0.25.0 // indirect - golang.org/x/sys v0.29.0 // indirect + golang.org/x/sys v0.42.0 // indirect golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index e77b3cade..eb895c91a 100644 --- a/go.sum +++ b/go.sum @@ -61,6 +61,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs= +github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -103,6 +105,8 @@ 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/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU= +github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -134,8 +138,9 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -202,8 +207,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= @@ -303,8 +308,8 @@ github.com/likexian/gokit v0.25.13 h1:p2Uw3+6fGG53CwdU2Dz0T6bOycdb2+bAFAa3ymwWVk github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4= github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w= github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= -github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de h1:V53FWzU6KAZVi1tPp5UIsMoUWJ2/PNwYIDXnu7QuBCE= -github.com/lufia/plan9stats v0.0.0-20230110061619-bbe2e5e100de/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= +github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 h1:PTw+yKnXcOFCR6+8hHTyWBeQ/P4Nb7dd4/0ohEcWQuM= +github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -347,12 +352,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= -github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw= -github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= +github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1YH8= +github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg= github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s= github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= -github.com/openimsdk/tools v0.0.50-alpha.106 h1:gaqU08IbRxOdL16ZEQNyYLhCTf7K1HNkrik8KZLA+BM= -github.com/openimsdk/tools v0.0.50-alpha.106/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= +github.com/openimsdk/tools v0.0.50-alpha.113 h1:rhLWaSJuhjgJFNVzmpChLCG7dPXS0+bte+CPI0008Us= +github.com/openimsdk/tools v0.0.50-alpha.113/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= @@ -363,8 +368,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b h1:0LFwY6Q3gMACTjAbMZBjXAqTOzOwFaj2Ld6cjeQ7Rig= -github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= +github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= @@ -403,6 +408,8 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= +github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI= +github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -433,18 +440,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4= github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE= -github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= -github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= -github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= -github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= +github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= +github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= +github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= +github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= @@ -567,8 +574,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= +golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= 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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/magefile.go b/magefile.go index b9861bd5e..9b34dfa60 100644 --- a/magefile.go +++ b/magefile.go @@ -5,9 +5,12 @@ package main import ( "flag" + "fmt" "os" "github.com/openimsdk/gomake/mageutil" + "github.com/openimsdk/open-im-server/v3/version" + "github.com/openimsdk/tools/utils/datautil" ) var Default = Build @@ -25,7 +28,6 @@ var ( customToolsDir = "tools" // tools source code directory, default is "tools" ) - // Build support specifical binary build. // // Example: `mage build openim-api openim-rpc-user seq` @@ -35,8 +37,7 @@ func Build() { if len(bin) != 0 { bin = bin[1:] } - - mageutil.Build(bin, nil) + mageutil.WithSpinner("Building binaries...", func() { mageutil.Build(bin, nil, nil) }) } func BuildWithCustomConfig() { @@ -53,7 +54,9 @@ func BuildWithCustomConfig() { ToolsDir: &customToolsDir, } - mageutil.Build(bin, config) + mageutil.WithSpinner("Building binaries with custom config...", func() { + mageutil.Build(bin, config, nil) + }) } func Start() { @@ -70,7 +73,9 @@ func Start() { bin = bin[1:] } - mageutil.StartToolsAndServices(bin, nil) + mageutil.WithSpinner("Starting...", func() { + mageutil.StartToolsAndServices(bin, nil) + }) } func StartWithCustomConfig() { @@ -93,13 +98,42 @@ func StartWithCustomConfig() { ConfigDir: &customConfigDir, } - mageutil.StartToolsAndServices(bin, config) + mageutil.WithSpinner("Starting with custom config...", func() { + mageutil.StartToolsAndServices(bin, config) + }) } func Stop() { - mageutil.StopAndCheckBinaries() + mageutil.WithSpinner("Stopping...", mageutil.StopAndCheckBinaries) } func Check() { - mageutil.CheckAndReportBinariesStatus() + mageutil.WithSpinner("Checking binaries...", mageutil.CheckAndReportBinariesStatus) +} + +func Export() { + mappingPaths, err := mageutil.GetDefaultExportMappingPaths([]string{ + "cmd", + "internal", + "pkg", + "test", + "tools", + "**/*.go", + "go.mod", + "go.work", + }) + if err != nil { + mageutil.PrintRed("GetDefaultExportMappingPaths failed " + err.Error()) + os.Exit(1) + } + + mageutil.WithSpinner("Exporting...", func() { + mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{ + ProjectName: datautil.ToPtr(fmt.Sprintf("open-im-server_%s", version.Version)), + BuildOpt: &mageutil.BuildOptions{ + Release: datautil.ToPtr(true), + Compress: datautil.ToPtr(true), + }, + }) + }) } From 6b3faaef1aaf1d5154bc81d7fdeb575b6f00f1e0 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 28 May 2026 16:48:32 +0800 Subject: [PATCH 12/41] chore: update tools ver (#3730) --- go.mod | 40 +++++----- go.sum | 107 ++++++++++++++------------ pkg/common/prommetrics/prommetrics.go | 4 +- 3 files changed, 81 insertions(+), 70 deletions(-) diff --git a/go.mod b/go.mod index 163f1c9f8..f00a6ee40 100644 --- a/go.mod +++ b/go.mod @@ -8,19 +8,19 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/go-playground/validator/v10 v10.20.0 github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.1 + github.com/golang-jwt/jwt/v4 v4.5.2 github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/openimsdk/protocol v0.0.73-alpha.19 - github.com/openimsdk/tools v0.0.50-alpha.113 + github.com/openimsdk/tools v0.0.50-alpha.117 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.11.1 go.mongodb.org/mongo-driver v1.14.0 google.golang.org/api v0.170.0 - google.golang.org/grpc v1.71.0 - google.golang.org/protobuf v1.36.4 + google.golang.org/grpc v1.79.3 + google.golang.org/protobuf v1.36.10 gopkg.in/yaml.v3 v3.0.1 ) @@ -42,7 +42,7 @@ require ( github.com/spf13/viper v1.18.2 go.etcd.io/etcd/client/v3 v3.5.13 go.uber.org/automaxprocs v1.5.3 - golang.org/x/sync v0.10.0 + golang.org/x/sync v0.20.0 k8s.io/api v0.31.2 k8s.io/apimachinery v0.31.2 k8s.io/client-go v0.31.2 @@ -50,7 +50,7 @@ require ( require ( cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute/metadata v0.6.0 // indirect + cloud.google.com/go/compute/metadata v0.9.0 // indirect cloud.google.com/go/firestore v1.15.0 // indirect cloud.google.com/go/iam v1.1.7 // indirect cloud.google.com/go/longrunning v0.5.5 // indirect @@ -98,7 +98,7 @@ require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect @@ -186,27 +186,27 @@ require ( go.etcd.io/etcd/api/v3 v3.5.13 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.34.0 // indirect - go.opentelemetry.io/otel/metric v1.34.0 // indirect - go.opentelemetry.io/otel/trace v1.34.0 // indirect + go.opentelemetry.io/otel v1.39.0 // indirect + go.opentelemetry.io/otel/metric v1.39.0 // indirect + go.opentelemetry.io/otel/trace v1.39.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.7.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/image v0.15.0 // indirect - golang.org/x/net v0.34.0 // indirect - golang.org/x/oauth2 v0.25.0 // indirect - golang.org/x/sys v0.42.0 // indirect - golang.org/x/term v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect + golang.org/x/image v0.39.0 // indirect + golang.org/x/net v0.55.0 // indirect + golang.org/x/oauth2 v0.34.0 // indirect + golang.org/x/sys v0.45.0 // indirect + golang.org/x/term v0.43.0 // indirect + golang.org/x/text v0.37.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine/v2 v2.0.2 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gorm.io/gorm v1.25.8 // indirect @@ -225,6 +225,6 @@ require ( github.com/spf13/cobra v1.8.0 github.com/ugorji/go/codec v1.2.12 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.32.0 // indirect + golang.org/x/crypto v0.52.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index eb895c91a..0da371b9f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= -cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I= -cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg= +cloud.google.com/go/compute/metadata v0.9.0 h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs= +cloud.google.com/go/compute/metadata v0.9.0/go.mod h1:E0bWwX5wTnLPedCKqk3pJmVgCBSM6qQI1yTBdEb3C10= cloud.google.com/go/firestore v1.15.0 h1:/k8ppuWOtNuDHt2tsRV42yI21uaGnKDEQnRFeBpbFF8= cloud.google.com/go/firestore v1.15.0/go.mod h1:GWOxFXcv8GZUtYpWHw/w6IuYNux/BtmeVTMmjrm4yhk= cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM= @@ -82,6 +82,8 @@ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w= +github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -112,7 +114,12 @@ github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRr 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/go-control-plane v0.14.0 h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA= +github.com/envoyproxy/go-control-plane/envoy v1.36.0 h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g= +github.com/envoyproxy/go-control-plane/envoy v1.36.0/go.mod h1:ty89S1YCCVruQAm9OtKeEkQLTb+Lkz0k8v9W0Oxsv98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4= +github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -134,8 +141,8 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm 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/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -176,8 +183,8 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= -github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= +github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= @@ -356,8 +363,8 @@ github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1Y github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg= github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s= github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= -github.com/openimsdk/tools v0.0.50-alpha.113 h1:rhLWaSJuhjgJFNVzmpChLCG7dPXS0+bte+CPI0008Us= -github.com/openimsdk/tools v0.0.50-alpha.113/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4= +github.com/openimsdk/tools v0.0.50-alpha.117 h1:ACfijEVCeBcttT7OOkNGOOOvq14pJtb9szNIMHLm6Vc= +github.com/openimsdk/tools v0.0.50-alpha.117/go.mod h1:I0WESSa7ghPIo9BL+ETlH/qEIbO6+KZioM1jwNuDwz0= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= @@ -365,6 +372,8 @@ github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -393,8 +402,8 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= -github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= 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= @@ -481,22 +490,22 @@ go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= -go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= -go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= -go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= -go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= -go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= -go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= -go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= -go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= -go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= +go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= +go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= +go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= +go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= +go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= +go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= +go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= +go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= +go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= @@ -517,13 +526,13 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= +golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= -golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww= +golang.org/x/image v0.39.0/go.mod h1:sIbmppfU+xFLPIG0FoVUTvyBMmgng1/XAMhQ2ft0hpA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -546,19 +555,19 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= -golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= +golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= +golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= -golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -574,14 +583,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo= -golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= +golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= 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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= -golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= +golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= 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= @@ -590,8 +599,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= +golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -603,14 +612,16 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= +golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/api v0.170.0 h1:zMaruDePM88zxZBG+NG8+reALO2rfLhe/JShitLyT48= google.golang.org/api v0.170.0/go.mod h1:/xql9M2btF85xac/VAm4PsLMTLVGUOpq4BE9R8jyNy8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -622,17 +633,17 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= -google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24= -google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= +google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls= +google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= -google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE= +google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -642,8 +653,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= -google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= 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= diff --git a/pkg/common/prommetrics/prommetrics.go b/pkg/common/prommetrics/prommetrics.go index 3f683a50e..68e37a013 100644 --- a/pkg/common/prommetrics/prommetrics.go +++ b/pkg/common/prommetrics/prommetrics.go @@ -100,11 +100,11 @@ type RespTarget struct { } func BuildDiscoveryKeyPrefix(name string) string { - return fmt.Sprintf("%s/%s/%s", "openim", "prometheus_discovery", name) + return fmt.Sprintf("%s/%s", "prometheus_discovery", name) } func BuildDiscoveryKey(name string, index int) string { - return fmt.Sprintf("%s/%s/%s/%d", "openim", "prometheus_discovery", name, index) + return fmt.Sprintf("%s/%s/%d", "prometheus_discovery", name, index) } func BuildDefaultTarget(host string, ip int) Target { From fd61ea4b03d5b6c2100df196b99ea6a46b11dfbe Mon Sep 17 00:00:00 2001 From: Derek YU <154693526+TonyDerek-dot@users.noreply.github.com> Date: Thu, 4 Jun 2026 16:12:55 +0800 Subject: [PATCH 13/41] fix: remove duplicate conversation_id unique index (#3713) Group conversations store one record per owner_user_id and conversation_id pair, so a global unique index on conversation_id breaks group conversation creation with duplicate key errors. --- pkg/common/storage/database/mgo/conversation.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/common/storage/database/mgo/conversation.go b/pkg/common/storage/database/mgo/conversation.go index c1d00f0ed..2f9c063cc 100644 --- a/pkg/common/storage/database/mgo/conversation.go +++ b/pkg/common/storage/database/mgo/conversation.go @@ -47,12 +47,6 @@ func NewConversationMongo(db *mongo.Database) (*ConversationMgo, error) { }, Options: options.Index(), }, - { - Keys: bson.D{ - {Key: "conversation_id", Value: 1}, - }, - Options: options.Index().SetUnique(true), - }, }) if err != nil { return nil, errs.Wrap(err) From 9118b3a339ac089dab33567516a84891d71a9465 Mon Sep 17 00:00:00 2001 From: wsy6543 <1948870933@qq.com> Date: Thu, 4 Jun 2026 18:02:42 +0800 Subject: [PATCH 14/41] fix GetMaxSeqs (#3561) --- pkg/common/storage/cache/mcache/seq_conversation.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/storage/cache/mcache/seq_conversation.go b/pkg/common/storage/cache/mcache/seq_conversation.go index 27f00de15..879b03535 100644 --- a/pkg/common/storage/cache/mcache/seq_conversation.go +++ b/pkg/common/storage/cache/mcache/seq_conversation.go @@ -32,7 +32,7 @@ func (x *seqConversationCache) GetMinSeq(ctx context.Context, conversationID str func (x *seqConversationCache) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { res := make(map[string]int64) for _, conversationID := range conversationIDs { - seq, err := x.GetMinSeq(ctx, conversationID) + seq, err := x.GetMaxSeq(ctx, conversationID) if err != nil { return nil, err } @@ -44,7 +44,7 @@ func (x *seqConversationCache) GetMaxSeqs(ctx context.Context, conversationIDs [ func (x *seqConversationCache) GetMaxSeqsWithTime(ctx context.Context, conversationIDs []string) (map[string]database.SeqTime, error) { res := make(map[string]database.SeqTime) for _, conversationID := range conversationIDs { - seq, err := x.GetMinSeq(ctx, conversationID) + seq, err := x.GetMaxSeq(ctx, conversationID) if err != nil { return nil, err } From 8f913ca13b4233b79de0eb920815499bd62160a5 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:09:07 +0800 Subject: [PATCH 15/41] refactor(ci): actions and dockerfile (#3732) * feat(build): add unified server image build flow Consolidate service image definitions into a single server build setup, and update CI workflows to use it. * fix(ci): correct Docker image tag generation --- ...cker-build-and-release-services-images.yml | 105 ++++++++------ .github/workflows/go-build-test.yml | 6 +- Dockerfile | 54 ++----- build/build.sh | 133 ++++++++++++++++++ build/images/Dockerfile | 24 ---- build/images/openim-api/Dockerfile | 36 ----- build/images/openim-crontask/Dockerfile | 39 ----- build/images/openim-msggateway/Dockerfile | 39 ----- build/images/openim-msgtransfer/Dockerfile | 39 ----- build/images/openim-push/Dockerfile | 39 ----- build/images/openim-rpc-auth/Dockerfile | 39 ----- .../images/openim-rpc-conversation/Dockerfile | 39 ----- build/images/openim-rpc-friend/Dockerfile | 39 ----- build/images/openim-rpc-group/Dockerfile | 39 ----- build/images/openim-rpc-msg/Dockerfile | 39 ----- build/images/openim-rpc-third/Dockerfile | 39 ----- build/images/openim-rpc-user/Dockerfile | 37 ----- build/images/openim-server/Dockerfile | 30 ++++ .../docker-compose.build.override.yml | 72 ++++++++++ .../openim-server/docker-compose.build.yml | 120 ++++++++++++++++ .../images/openim-tools/component/Dockerfile | 108 -------------- 21 files changed, 436 insertions(+), 679 deletions(-) create mode 100755 build/build.sh delete mode 100644 build/images/Dockerfile delete mode 100644 build/images/openim-api/Dockerfile delete mode 100644 build/images/openim-crontask/Dockerfile delete mode 100644 build/images/openim-msggateway/Dockerfile delete mode 100644 build/images/openim-msgtransfer/Dockerfile delete mode 100644 build/images/openim-push/Dockerfile delete mode 100644 build/images/openim-rpc-auth/Dockerfile delete mode 100644 build/images/openim-rpc-conversation/Dockerfile delete mode 100644 build/images/openim-rpc-friend/Dockerfile delete mode 100644 build/images/openim-rpc-group/Dockerfile delete mode 100644 build/images/openim-rpc-msg/Dockerfile delete mode 100644 build/images/openim-rpc-third/Dockerfile delete mode 100644 build/images/openim-rpc-user/Dockerfile create mode 100644 build/images/openim-server/Dockerfile create mode 100644 build/images/openim-server/docker-compose.build.override.yml create mode 100644 build/images/openim-server/docker-compose.build.yml delete mode 100644 build/images/openim-tools/component/Dockerfile diff --git a/.github/workflows/docker-build-and-release-services-images.yml b/.github/workflows/docker-build-and-release-services-images.yml index 407589f1e..1d085e153 100644 --- a/.github/workflows/docker-build-and-release-services-images.yml +++ b/.github/workflows/docker-build-and-release-services-images.yml @@ -16,11 +16,17 @@ on: jobs: build-and-push: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3.3.0 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.8.0 @@ -44,48 +50,63 @@ jobs: username: ${{ secrets.ALIREGISTRY_USERNAME }} password: ${{ secrets.ALIREGISTRY_TOKEN }} - - name: Extract metadata for Docker (tags, labels) - id: meta - uses: docker/metadata-action@v5.6.0 - with: - tags: | - type=ref,event=tag - type=schedule - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern=v{{version}} - type=semver,pattern=release-{{raw}} - type=sha - type=raw,value=${{ github.event.inputs.tag }} + - name: Resolve Docker image tags + id: tags + env: + INPUT_TAG: ${{ github.event.inputs.tag }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + set -euo pipefail + + tags=() + declare -A seen=() + + add_tag() { + local tag="$1" + [[ -n "$tag" ]] || return 0 + + tag="${tag//\//-}" + if [[ -z "${seen[$tag]+x}" ]]; then + tags+=("$tag") + seen["$tag"]=1 + fi + } + + add_tag_with_semver_alias() { + local tag="$1" + add_tag "$tag" + if [[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then + add_tag "${BASH_REMATCH[1]}" + add_tag "release-$tag" + fi + } + + add_tag_with_semver_alias "${INPUT_TAG:-}" + add_tag_with_semver_alias "${RELEASE_TAG:-}" + + if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then + add_tag_with_semver_alias "${GITHUB_REF_NAME}" + elif [[ "${GITHUB_REF_TYPE:-}" == "branch" ]]; then + add_tag "${GITHUB_REF_NAME}" + fi + + add_tag "sha-${GITHUB_SHA::7}" + + { + echo "tags<> "$GITHUB_OUTPUT" - name: Build and push Docker images + env: + RELEASE: "true" + PUSH: "true" + PLATFORMS: linux/amd64,linux/arm64 + IMAGE_TAGS: ${{ steps.tags.outputs.tags }} + IMAGE_REGISTRIES: | + ${{ secrets.DOCKER_USERNAME }} + ghcr.io/${{ github.repository_owner }} + registry.cn-hangzhou.aliyuncs.com/openimsdk run: | - IMG_DIR="build/images" - for dir in "$IMG_DIR"/*/; do - # Find Dockerfile or *.dockerfile in a case-insensitive manner - dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1) - - if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then - IMAGE_NAME=$(basename "$dir") - echo "Building Docker image for $IMAGE_NAME with tags:" - - # Initialize tag arguments - tag_args=() - - # Read each tag and append --tag arguments - while IFS= read -r tag; do - tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag") - tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag") - tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag") - done <<< "${{ steps.meta.outputs.tags }}" - - # Build and push the Docker image with all tags - docker buildx build --platform linux/amd64,linux/arm64 \ - --file "$dockerfile" \ - "${tag_args[@]}" \ - --push \ - "." - else - echo "No valid Dockerfile found in $dir" - fi - done + bash build/build.sh diff --git a/.github/workflows/go-build-test.yml b/.github/workflows/go-build-test.yml index 9e2aa3f1c..8425293e9 100644 --- a/.github/workflows/go-build-test.yml +++ b/.github/workflows/go-build-test.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go_version: ["1.22.x"] + go_version: ["1.25.x"] steps: - name: Checkout Server repository @@ -188,7 +188,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go_version: ["1.22.x"] + go_version: ["1.25.x"] steps: - name: Checkout Server repository @@ -237,7 +237,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: ["1.22"] + go_version: ["1.25.x"] steps: - name: Checkout Repository diff --git a/Dockerfile b/Dockerfile index 8a95b6851..30af8f7ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,25 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder +FROM golang:1.25-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server +ARG RELEASE=false +ARG COMPRESS=false +WORKDIR /openim-server -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR +RUN apk add --no-cache upx -# Set the Go proxy to improve dependency resolution speed -# ENV GOPROXY=https://goproxy.io,direct +RUN go install github.com/magefile/mage@latest -# Copy all files from the current directory into the container COPY . . - RUN go mod download +RUN RELEASE=${RELEASE} COMPRESS=${COMPRESS} mage build +RUN mage -compile ./mage -ldflags "-s -w" -# Install Mage to use for building the application -RUN go install github.com/magefile/mage@v1.15.0 +FROM alpine:latest -# Optionally build your application if needed -RUN mage build +WORKDIR /openim-server -# Using Alpine Linux with Go environment for the final image -FROM golang:1.22-alpine +COPY --from=builder /openim-server/_output ./_output +COPY --from=builder /openim-server/config ./config +COPY --from=builder /openim-server/start-config.yml ./start-config.yml +COPY --from=builder /openim-server/mage ./mage -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config -COPY --from=builder /go/bin/mage /usr/local/bin/mage -COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/ - -RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.1 - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"] +ENTRYPOINT ["sh", "-c", "./mage start && sleep infinity"] \ No newline at end of file diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 000000000..354cd3945 --- /dev/null +++ b/build/build.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CYAN='\033[0;36m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NO_COLOR='\033[0m' + +BASE_DIR="$(cd "$(dirname "$0")" && pwd)" +COMPOSE_FILE="$BASE_DIR/images/openim-server/docker-compose.build.yml" +RELEASE="${RELEASE:-false}" +PUSH="${PUSH:-false}" +DRY_RUN="${DRY_RUN:-false}" +PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}" +IMAGE_TAGS="${IMAGE_TAGS:-}" +IMAGE_REGISTRIES="${IMAGE_REGISTRIES:-}" + +if [[ ! -f "$COMPOSE_FILE" ]]; then + echo -e "${RED}docker-compose.build.yml not found: $COMPOSE_FILE${NO_COLOR}" + exit 1 +fi + +cd "$BASE_DIR/.." || exit 1 + +split_values() { + printf '%s\n' "$1" | tr ', ' '\n\n' | while IFS= read -r value; do + [[ -n "$value" ]] && printf '%s\n' "$value" + done +} + +print_command() { + printf '%q ' "$@" + printf '\n' +} + +run_or_print() { + if [[ "$DRY_RUN" == "true" ]]; then + print_command "$@" + else + "$@" + fi +} + +build_local() { + echo -e "${CYAN}Building all services...${NO_COLOR}" + RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build + + echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}" + while IFS= read -r built_image; do + [[ -n "$built_image" ]] || continue + compatibility_tag="${built_image##*/}" + + if [[ "$built_image" != "$compatibility_tag" ]]; then + docker tag "$built_image" "$compatibility_tag" + fi + done < <(docker compose -f "$COMPOSE_FILE" config --images) + + echo -e "${GREEN}Successfully built all services${NO_COLOR}" +} + +build_push() { + if ! command -v jq >/dev/null 2>&1; then + echo -e "${RED}jq is required for PUSH=true${NO_COLOR}" + exit 1 + fi + + if [[ -z "$IMAGE_TAGS" || -z "$IMAGE_REGISTRIES" ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES are required for PUSH=true${NO_COLOR}" + exit 1 + fi + + image_tags=() + while IFS= read -r tag; do + image_tags+=("$tag") + done < <(split_values "$IMAGE_TAGS") + + image_registries=() + while IFS= read -r registry; do + image_registries+=("$registry") + done < <(split_values "$IMAGE_REGISTRIES") + + if [[ ${#image_tags[@]} -eq 0 || ${#image_registries[@]} -eq 0 ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES must contain at least one value${NO_COLOR}" + exit 1 + fi + + compose_config=$(docker compose -f "$COMPOSE_FILE" config --format json) + + echo -e "${CYAN}Building and pushing service images...${NO_COLOR}" + while IFS= read -r service; do + context=$(jq -r --arg service "$service" '.services[$service].build.context // empty' <<< "$compose_config") + dockerfile=$(jq -r --arg service "$service" '.services[$service].build.dockerfile // empty' <<< "$compose_config") + cmd_path=$(jq -r --arg service "$service" '.services[$service].build.args.CMD_PATH // empty' <<< "$compose_config") + binary_name=$(jq -r --arg service "$service" '.services[$service].build.args.BINARY_NAME // empty' <<< "$compose_config") + + if [[ -z "$context" || -z "$dockerfile" || -z "$cmd_path" || -z "$binary_name" ]]; then + echo -e "${RED}Invalid build config for $service${NO_COLOR}" + exit 1 + fi + + if [[ ! -d "$cmd_path" && ! -f "$cmd_path/main.go" ]]; then + echo -e "${CYAN}Skipping $service because $cmd_path does not exist${NO_COLOR}" + continue + fi + + tag_args=() + for registry in "${image_registries[@]}"; do + for tag in "${image_tags[@]}"; do + tag_args+=(--tag "$registry/$binary_name:$tag") + done + done + + echo -e "${CYAN}Building $binary_name for $PLATFORMS...${NO_COLOR}" + run_or_print docker buildx build \ + --platform "$PLATFORMS" \ + --file "$dockerfile" \ + --build-arg "CMD_PATH=$cmd_path" \ + --build-arg "BINARY_NAME=$binary_name" \ + --build-arg "RELEASE=$RELEASE" \ + "${tag_args[@]}" \ + --push \ + "$context" + done < <(jq -r '.services | keys[]' <<< "$compose_config" | sort) + + echo -e "${GREEN}Successfully pushed service images${NO_COLOR}" +} + +if [[ "$PUSH" == "true" ]]; then + build_push +else + build_local +fi diff --git a/build/images/Dockerfile b/build/images/Dockerfile deleted file mode 100644 index 020d50786..000000000 --- a/build/images/Dockerfile +++ /dev/null @@ -1,24 +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. - -# FROM BASE_IMAGE - -# WORKDIR ${SERVER_WORKDIR} - -# # Set HTTP proxy -# ARG BINARY_NAME - -# COPY BINARY_NAME ./bin/BINARY_NAME - -# ENTRYPOINT ["./bin/BINARY_NAME"] \ No newline at end of file diff --git a/build/images/openim-api/Dockerfile b/build/images/openim-api/Dockerfile deleted file mode 100644 index eb9971c9b..000000000 --- a/build/images/openim-api/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder - -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - -RUN go build -o _output/openim-api ./cmd/openim-api - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-api"] diff --git a/build/images/openim-crontask/Dockerfile b/build/images/openim-crontask/Dockerfile deleted file mode 100644 index 863ef4e65..000000000 --- a/build/images/openim-crontask/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-crontask ./cmd/openim-crontask - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-crontask"] diff --git a/build/images/openim-msggateway/Dockerfile b/build/images/openim-msggateway/Dockerfile deleted file mode 100644 index 981c8215b..000000000 --- a/build/images/openim-msggateway/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-msggateway ./cmd/openim-msggateway - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-msggateway"] diff --git a/build/images/openim-msgtransfer/Dockerfile b/build/images/openim-msgtransfer/Dockerfile deleted file mode 100644 index b765b01ed..000000000 --- a/build/images/openim-msgtransfer/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-msgtransfer ./cmd/openim-msgtransfer - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-msgtransfer"] diff --git a/build/images/openim-push/Dockerfile b/build/images/openim-push/Dockerfile deleted file mode 100644 index ee5ede79a..000000000 --- a/build/images/openim-push/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-push ./cmd/openim-push - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-push"] diff --git a/build/images/openim-rpc-auth/Dockerfile b/build/images/openim-rpc-auth/Dockerfile deleted file mode 100644 index b09258eee..000000000 --- a/build/images/openim-rpc-auth/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-auth ./cmd/openim-rpc/openim-rpc-auth - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-auth"] diff --git a/build/images/openim-rpc-conversation/Dockerfile b/build/images/openim-rpc-conversation/Dockerfile deleted file mode 100644 index ff6b315b2..000000000 --- a/build/images/openim-rpc-conversation/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-conversation ./cmd/openim-rpc/openim-rpc-conversation - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-conversation"] diff --git a/build/images/openim-rpc-friend/Dockerfile b/build/images/openim-rpc-friend/Dockerfile deleted file mode 100644 index 540678310..000000000 --- a/build/images/openim-rpc-friend/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-friend ./cmd/openim-rpc/openim-rpc-friend - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-friend"] diff --git a/build/images/openim-rpc-group/Dockerfile b/build/images/openim-rpc-group/Dockerfile deleted file mode 100644 index d1aab9ad9..000000000 --- a/build/images/openim-rpc-group/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-group ./cmd/openim-rpc/openim-rpc-group - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-group"] diff --git a/build/images/openim-rpc-msg/Dockerfile b/build/images/openim-rpc-msg/Dockerfile deleted file mode 100644 index da40bb293..000000000 --- a/build/images/openim-rpc-msg/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-msg ./cmd/openim-rpc/openim-rpc-msg - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-msg"] diff --git a/build/images/openim-rpc-third/Dockerfile b/build/images/openim-rpc-third/Dockerfile deleted file mode 100644 index 52cdb0de8..000000000 --- a/build/images/openim-rpc-third/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - - - -RUN go build -o _output/openim-rpc-third ./cmd/openim-rpc/openim-rpc-third - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-third"] diff --git a/build/images/openim-rpc-user/Dockerfile b/build/images/openim-rpc-user/Dockerfile deleted file mode 100644 index 1b3481c66..000000000 --- a/build/images/openim-rpc-user/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod tidy - -RUN go build -o _output/openim-rpc-user ./cmd/openim-rpc/openim-rpc-user - - -# Using Alpine Linux for the final image -FROM alpine:latest - -# Install necessary packages, such as bash -RUN apk add --no-cache bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -# COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "_output/openim-rpc-user"] diff --git a/build/images/openim-server/Dockerfile b/build/images/openim-server/Dockerfile new file mode 100644 index 000000000..e821260a6 --- /dev/null +++ b/build/images/openim-server/Dockerfile @@ -0,0 +1,30 @@ +FROM golang:1.25-alpine AS builder + +ARG CMD_PATH +ARG BINARY_NAME +ARG RELEASE=false + +ENV SERVER_DIR=/openim-server +WORKDIR $SERVER_DIR + +COPY . . +RUN go mod tidy + +RUN if [ "$RELEASE" = "true" ]; then \ + go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \ + else \ + go build -o _output/${BINARY_NAME} ./${CMD_PATH}; \ + fi + +FROM alpine:latest + +RUN apk add --no-cache bash + +ARG BINARY_NAME +ENV BINARY_NAME=${BINARY_NAME} +ENV SERVER_DIR=/openim-server +WORKDIR $SERVER_DIR + +COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output + +ENTRYPOINT ["sh", "-c", "_output/${BINARY_NAME}"] \ No newline at end of file diff --git a/build/images/openim-server/docker-compose.build.override.yml b/build/images/openim-server/docker-compose.build.override.yml new file mode 100644 index 000000000..7ef19f988 --- /dev/null +++ b/build/images/openim-server/docker-compose.build.override.yml @@ -0,0 +1,72 @@ +services: + openim-api: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-crontask: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-msggateway: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-msgtransfer: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-push: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-auth: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-conversation: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-friend: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-group: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-msg: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-third: + build: + platforms: + - linux/amd64 + - linux/arm64 + + openim-rpc-user: + build: + platforms: + - linux/amd64 + - linux/arm64 diff --git a/build/images/openim-server/docker-compose.build.yml b/build/images/openim-server/docker-compose.build.yml new file mode 100644 index 000000000..1837fa836 --- /dev/null +++ b/build/images/openim-server/docker-compose.build.yml @@ -0,0 +1,120 @@ +services: + openim-api: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-api + BINARY_NAME: openim-api + RELEASE: ${RELEASE:-false} + image: openim-api:test + + openim-crontask: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-crontask + BINARY_NAME: openim-crontask + RELEASE: ${RELEASE:-false} + image: openim-crontask:test + + openim-msggateway: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-msggateway + BINARY_NAME: openim-msggateway + RELEASE: ${RELEASE:-false} + image: openim-msggateway:test + + openim-msgtransfer: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-msgtransfer + BINARY_NAME: openim-msgtransfer + RELEASE: ${RELEASE:-false} + image: openim-msgtransfer:test + + openim-push: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-push + BINARY_NAME: openim-push + RELEASE: ${RELEASE:-false} + image: openim-push:test + + openim-rpc-auth: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-auth + BINARY_NAME: openim-rpc-auth + RELEASE: ${RELEASE:-false} + image: openim-rpc-auth:test + + openim-rpc-conversation: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-conversation + BINARY_NAME: openim-rpc-conversation + RELEASE: ${RELEASE:-false} + image: openim-rpc-conversation:test + + openim-rpc-friend: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-friend + BINARY_NAME: openim-rpc-friend + RELEASE: ${RELEASE:-false} + image: openim-rpc-friend:test + + openim-rpc-group: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-group + BINARY_NAME: openim-rpc-group + RELEASE: ${RELEASE:-false} + image: openim-rpc-group:test + + openim-rpc-msg: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-msg + BINARY_NAME: openim-rpc-msg + RELEASE: ${RELEASE:-false} + image: openim-rpc-msg:test + + openim-rpc-third: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-third + BINARY_NAME: openim-rpc-third + RELEASE: ${RELEASE:-false} + image: openim-rpc-third:test + + openim-rpc-user: + build: + context: ../../.. + dockerfile: build/images/openim-server/Dockerfile + args: + CMD_PATH: cmd/openim-rpc/openim-rpc-user + BINARY_NAME: openim-rpc-user + RELEASE: ${RELEASE:-false} + image: openim-rpc-user:test diff --git a/build/images/openim-tools/component/Dockerfile b/build/images/openim-tools/component/Dockerfile deleted file mode 100644 index ae8de800f..000000000 --- a/build/images/openim-tools/component/Dockerfile +++ /dev/null @@ -1,108 +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. - -# # OpenIM base image: https://github.com/openim-sigs/openim-base-image - -# # Set go mod installation source and proxy - -# FROM golang:1.20 AS builder - -# - -# WORKDIR /openim/openim-server - -# -# ENV GOPROXY=$GOPROXY - -# COPY go.mod go.sum ./ -# RUN go mod download - -# COPY . . - -# RUN make clean -# RUN make build BINS=component - -# # FROM ghcr.io/openim-sigs/openim-bash-image:latest -# FROM ghcr.io/openim-sigs/openim-bash-image:latest - -# WORKDIR /openim/openim-server - -# COPY --from=builder /openim/openim-server/_output/bin/tools /openim/openim-server/_output/bin/tools/ -# COPY --from=builder /openim/openim-server/config /openim/openim-server/config - -# ENV OPENIM_SERVER_CONFIG_NAME=/openim/openim-server/config - -# RUN mv ${OPENIM_SERVER_BINDIR}/platforms/$(get_os)/$(get_arch)/component /usr/bin/component - -# ENTRYPOINT ["bash", "-c", "component -c $OPENIM_SERVER_CONFIG_NAME"] - - -# Use Go 1.22 Alpine as the base image for building the application -FROM golang:1.22-alpine AS builder -# Define the base directory for the application as an environment variable -ENV SERVER_DIR=/openim-server - -# Set the working directory inside the container based on the environment variable -WORKDIR $SERVER_DIR - -# Set the Go proxy to improve dependency resolution speed - -#ENV GOPROXY=https://goproxy.io,direct - -# Copy all files from the current directory into the container -COPY . . - -RUN go mod download - -# Install Mage to use for building the application -RUN go install github.com/magefile/mage@v1.15.0 - -# ENV BINS=openim-rpc-user - -# Optionally build your application if needed -# RUN mage build ${BINS} check-free-memory seq || true -RUN mage build check-free-memory seq || true - -# Using Alpine Linux with Go environment for the final image -FROM golang:1.22-alpine - -# Install necessary packages, such as bash -RUN apk add bash - -# Set the environment and work directory -ENV SERVER_DIR=/openim-server -WORKDIR $SERVER_DIR - - -# Copy the compiled binaries and mage from the builder image to the final image -COPY --from=builder $SERVER_DIR/_output $SERVER_DIR/_output -COPY --from=builder $SERVER_DIR/config $SERVER_DIR/config -COPY --from=builder /go/bin/mage /usr/local/bin/mage -COPY --from=builder $SERVER_DIR/magefile_windows.go $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/magefile_unix.go $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/magefile.go $SERVER_DIR/ -# COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/ -COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/ - - -RUN echo -e "serviceBinaries:\n \n" \ - > $SERVER_DIR/start-config.yml && \ - echo -e "toolBinaries:\n - check-free-memory\n - seq\n" >> $SERVER_DIR/start-config.yml && \ - echo "maxFileDescriptors: 10000" >> $SERVER_DIR/start-config.yml - -RUN go get github.com/openimsdk/gomake@v0.0.15-alpha.1 - -# Set the command to run when the container starts -ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"] From 1ac6a259dd5f16bfcb40622fc3d281398a0690d6 Mon Sep 17 00:00:00 2001 From: buvidk1234 <161066602+buvidk1234@users.noreply.github.com> Date: Thu, 4 Jun 2026 20:03:52 +0800 Subject: [PATCH 16/41] Modify conversation_id index options (#3722) * Modify conversation_id index options Removed the unique constraint from the conversation_id index. * fix(msggateway): reset read deadline in pong handler to prevent Web client timeout Root cause: Due to browser API restrictions, Web (Wasm) clients cannot actively send standard WebSocket Ping frames. They rely entirely on server-initiated Pings (every 27s) and automatic browser Pong responses to maintain the connection. The `pongHandler` was empty and failed to reset the connection's read deadline upon receiving a Pong, causing the server's read loop to strictly time out at 30 seconds. Solution: Call `c.setReadDeadline()` inside the `pongHandler` to properly extend the connection's lifespan when a Pong frame is received. --------- Co-authored-by: OpenIM-Gordon <1432970085@qq.com> --- internal/msggateway/client_conn.go | 6 +++++- pkg/common/storage/database/mgo/conversation.go | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/msggateway/client_conn.go b/internal/msggateway/client_conn.go index 15a0d8c07..0fb1620a6 100644 --- a/internal/msggateway/client_conn.go +++ b/internal/msggateway/client_conn.go @@ -208,7 +208,11 @@ func (c *websocketClientConn) pingHandler(appData string) error { return nil } -func (c *websocketClientConn) pongHandler(string) error { +func (c *websocketClientConn) pongHandler(appData string) error { + log.ZDebug(context.Background(), "pong handler recv pong", "remoteAddr", c.conn.RemoteAddr(), "appData", appData) + if err := c.setReadDeadline(); err != nil { + return err + } return nil } diff --git a/pkg/common/storage/database/mgo/conversation.go b/pkg/common/storage/database/mgo/conversation.go index 2f9c063cc..30f08f5e5 100644 --- a/pkg/common/storage/database/mgo/conversation.go +++ b/pkg/common/storage/database/mgo/conversation.go @@ -47,6 +47,12 @@ func NewConversationMongo(db *mongo.Database) (*ConversationMgo, error) { }, Options: options.Index(), }, + { + Keys: bson.D{ + {Key: "conversation_id", Value: 1}, + }, + Options: options.Index(), + }, }) if err != nil { return nil, errs.Wrap(err) From 7c242b8491146be18f91205d31fee0cb6dff799b Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 4 Jun 2026 20:05:40 +0800 Subject: [PATCH 17/41] refactor(group): optimize group notification and cache handling (#3704) * refactor(group): optimize group notification and cache handling - Improve notification sender with bulk operations and fallback logic - Enhance group cache with new methods for member counts and version handling - Refactor group controller with better cache integration - Add more robust error handling and logging fix(group): optimize group cache implementation This commit refactors the GroupCacheRedis implementation to improve code organization and maintainability. The changes include: - Added proper import organization and removed unused imports - Implemented batchGetCache2 function calls for efficient data retrieval - Added comprehensive cache key management functions - Improved version tracking for group members and requests - Enhanced error handling and logging - Added batch operations for better performance - Refactored complex functions into smaller, more manageable pieces The changes focus on improving the overall structure and performance of the group cache system while maintaining backward compatibility. refactor(group): improve notification error handling and add admin context - Convert notification methods to return errors for better error propagation - Add admin context checking for bulk notifications - Enhance group info retrieval with proper error handling - Improve notification sender with fallback user information fix(group): handle nil group member map in notification Add nil check for groupMemberMap[groupInfo.GroupID] before accessing to prevent nil pointer panic. Skip iteration if map is nil. refactor(group): update group notification methods to use UserInfo struct Renamed function parameter from groupMemberUserID string to changedUserInfo *sdkws.UserInfo Updated function logic to use changedUserInfo.UserID instead of separate parameter Refactored notification methods to use consistent UserInfo struct pattern Added proper error handling for opUser retrieval Updated function signatures and internal logic for GroupMemberInfoSetNotificationBulk fix: batchGetGroupRoleLevelMemberIDs with BatchCache fix: GetGroupMemberNums BatchCache perf(group): optimize notification logic for group member operations # Conflicts: # internal/rpc/group/group.go # pkg/common/storage/cache/redis/group.go * fix: import --- internal/rpc/group/group.go | 8 +- internal/rpc/group/notification.go | 191 ++++++++++++++++++++++-- pkg/common/storage/cache/group.go | 1 + pkg/common/storage/cache/redis/group.go | 167 +++++++++++++++++++-- pkg/common/storage/controller/group.go | 14 ++ 5 files changed, 358 insertions(+), 23 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 359ecfa6f..cc51fdf18 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -23,9 +23,11 @@ import ( "strings" "time" + "github.com/openimsdk/tools/utils/stringutil" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" - "google.golang.org/grpc" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct" @@ -143,8 +145,8 @@ func (g *groupServer) NotificationUserInfoUpdate(ctx context.Context, req *pbgro return nil, err } } - for _, groupID := range groupIDs { - g.notification.GroupMemberInfoSetNotification(ctx, groupID, req.UserID) + if err = g.notification.GroupMemberInfoSetNotificationBulk(ctx, groupIDs, req.NewUserInfo); err != nil { + log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err) } if err = g.db.DeleteGroupMemberHash(ctx, groupIDs); err != nil { return nil, err diff --git a/internal/rpc/group/notification.go b/internal/rpc/group/notification.go index 5a3cbbe26..8cf214459 100644 --- a/internal/rpc/group/notification.go +++ b/internal/rpc/group/notification.go @@ -802,6 +802,182 @@ func (g *NotificationSender) GroupCancelMutedNotification(ctx context.Context, g g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips) } +func (g *NotificationSender) getPublicUserInfos(ctx context.Context, userIDs []string) ([]*sdkws.PublicUserInfo, error) { + users, err := g.getUsersInfo(ctx, userIDs) + if err != nil { + return nil, err + } + userMap := make(map[string]common_user.CommonUser) + for _, user := range users { + userMap[user.GetUserID()] = user + } + for _, userID := range userIDs { + if _, ok := userMap[userID]; !ok { + return nil, servererrs.ErrUserIDNotFound.WrapMsg(fmt.Sprintf("user %s not found", userID)) + } + } + + return datautil.Slice(users, func(e common_user.CommonUser) *sdkws.PublicUserInfo { + return &sdkws.PublicUserInfo{ + UserID: e.GetUserID(), + Nickname: e.GetNickname(), + FaceURL: e.GetFaceURL(), + Ex: e.GetEx(), + } + }), nil +} + +func (g *NotificationSender) getGroupMembersForUser(ctx context.Context, groupIDs []string, userID string) ([]*sdkws.GroupMemberFullInfo, error) { + members, err := g.db.FindGroupMemberUser(ctx, groupIDs, userID) + if err != nil { + return nil, err + } + if err := g.PopulateGroupMember(ctx, members...); err != nil { + return nil, err + } + log.ZDebug(ctx, "getGroupMembers", "members", members) + return datautil.Slice(members, func(e *model.GroupMember) *sdkws.GroupMemberFullInfo { return g.groupMemberDB2PB(e, 0) }), nil +} + +func (g *NotificationSender) getGroupMemberMapForUser(ctx context.Context, groupIDs []string, userID string) (map[string]*sdkws.GroupMemberFullInfo, error) { + members, err := g.getGroupMembersForUser(ctx, groupIDs, userID) + if err != nil { + return nil, err + } + m := make(map[string]*sdkws.GroupMemberFullInfo) + for i, member := range members { + m[member.GroupID] = members[i] + } + return m, nil +} + +func (g *NotificationSender) migrateFallbackToGroupMemberFullInfo(groupMemberFullInfo *sdkws.GroupMemberFullInfo, publicUserInfo *sdkws.PublicUserInfo) *sdkws.GroupMemberFullInfo { + if groupMemberFullInfo == nil { + groupMemberFullInfo = &sdkws.GroupMemberFullInfo{} + } + if publicUserInfo == nil { + publicUserInfo = &sdkws.PublicUserInfo{} + } + + firstNotEmpty := func(s ...string) string { + for _, s := range s { + if s != "" { + return s + } + } + return "" + } + + return &sdkws.GroupMemberFullInfo{ + GroupID: groupMemberFullInfo.GroupID, + UserID: firstNotEmpty(groupMemberFullInfo.UserID, publicUserInfo.UserID), + RoleLevel: groupMemberFullInfo.RoleLevel, + JoinTime: groupMemberFullInfo.JoinTime, + Nickname: firstNotEmpty(groupMemberFullInfo.Nickname, publicUserInfo.Nickname), + FaceURL: firstNotEmpty(groupMemberFullInfo.FaceURL, publicUserInfo.FaceURL), + AppMangerLevel: groupMemberFullInfo.AppMangerLevel, + JoinSource: groupMemberFullInfo.JoinSource, + OperatorUserID: firstNotEmpty(groupMemberFullInfo.OperatorUserID, publicUserInfo.UserID), + InviterUserID: groupMemberFullInfo.InviterUserID, + Ex: groupMemberFullInfo.Ex, + MuteEndTime: groupMemberFullInfo.MuteEndTime, + } +} + +func (g *NotificationSender) getGroupInfos(ctx context.Context, groupIDs []string) ([]*sdkws.GroupInfo, error) { + var err error + defer func() { + if err != nil { + log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err) + } + }() + + groups, err := g.db.FindGroup(ctx, groupIDs) + if err != nil { + return nil, err + } + numMap, err := g.db.FindGroupMemberNums(ctx, groupIDs) + if err != nil { + return nil, err + } + owners, err := g.db.FindGroupsOwner(ctx, groupIDs) + if err != nil { + return nil, err + } + ownerMap := make(map[string]string) + for _, owner := range owners { + ownerMap[owner.GroupID] = owner.UserID + } + + return datautil.Slice(groups, func(group *model.Group) *sdkws.GroupInfo { + return convert.Db2PbGroupInfo(group, ownerMap[group.GroupID], numMap[group.GroupID]) + }), nil +} + +func (g *NotificationSender) GroupMemberInfoSetNotificationBulk(ctx context.Context, groupIDs []string, changedUserInfo *sdkws.UserInfo) error { + opUserID := mcontext.GetOpUserID(ctx) + opIsAdmin := authverify.CheckUserIsAdmin(ctx, opUserID) + + groupInfos, err := g.getGroupInfos(ctx, groupIDs) + if err != nil { + return err + } + + groupMemberMap, err := g.getGroupMemberMapForUser(ctx, groupIDs, changedUserInfo.UserID) + if err != nil { + return err + } + + opMemberMap := groupMemberMap + if opUserID != changedUserInfo.UserID { + opMemberMap, err = g.getGroupMemberMapForUser(ctx, groupIDs, opUserID) + if err != nil { + return err + } + } + + opPublicUser := &sdkws.PublicUserInfo{ + UserID: changedUserInfo.GetUserID(), + Nickname: changedUserInfo.GetNickname(), + FaceURL: changedUserInfo.GetFaceURL(), + Ex: changedUserInfo.GetEx(), + } + if opUserID != changedUserInfo.UserID { + opPublicUser, err = g.getUser(ctx, opUserID) + if err != nil { + return err + } + } + + for _, groupInfo := range groupInfos { + if groupMemberMap[groupInfo.GroupID] == nil { + continue + } + + opUserGroupMemberFullInfo := datautil.If(opIsAdmin, &sdkws.GroupMemberFullInfo{ + GroupID: groupInfo.GroupID, + UserID: opUserID, + RoleLevel: constant.GroupAdmin, + AppMangerLevel: constant.AppAdmin, + }, opMemberMap[groupInfo.GroupID]) + if opUserGroupMemberFullInfo == nil { + opUserGroupMemberFullInfo = &sdkws.GroupMemberFullInfo{} + } + opUserGroupMemberFullInfo.GroupID = groupInfo.GroupID + + tips := &sdkws.GroupMemberInfoSetTips{ + Group: groupInfo, + OpUser: g.migrateFallbackToGroupMemberFullInfo(opUserGroupMemberFullInfo, opPublicUser), + ChangedUser: groupMemberMap[groupInfo.GroupID], + } + + g.setSortVersion(ctx, &tips.GroupMemberVersion, &tips.GroupMemberVersionID, database.GroupMemberVersionName, tips.Group.GroupID, &tips.GroupSortVersion) + g.Notification(ctx, opUserID, groupInfo.GroupID, constant.GroupMemberInfoSetNotification, tips) + } + + return nil +} + func (g *NotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) { var err error defer func() { @@ -809,13 +985,11 @@ func (g *NotificationSender) GroupMemberInfoSetNotification(ctx context.Context, log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err) } }() - var group *sdkws.GroupInfo - group, err = g.getGroupInfo(ctx, groupID) + group, err := g.getGroupInfo(ctx, groupID) if err != nil { return } - var user map[string]*sdkws.GroupMemberFullInfo - user, err = g.getGroupMemberMap(ctx, groupID, []string{groupMemberUserID}) + user, err := g.getGroupMemberMap(ctx, groupID, []string{groupMemberUserID}) if err != nil { return } @@ -834,8 +1008,7 @@ func (g *NotificationSender) GroupMemberSetToAdminNotification(ctx context.Conte log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err) } }() - var group *sdkws.GroupInfo - group, err = g.getGroupInfo(ctx, groupID) + group, err := g.getGroupInfo(ctx, groupID) if err != nil { return } @@ -858,13 +1031,11 @@ func (g *NotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx contex log.ZError(ctx, stringutil.GetFuncName(1)+" failed", err) } }() - var group *sdkws.GroupInfo - group, err = g.getGroupInfo(ctx, groupID) + group, err := g.getGroupInfo(ctx, groupID) if err != nil { return } - var user map[string]*sdkws.GroupMemberFullInfo - user, err = g.getGroupMemberMap(ctx, groupID, []string{mcontext.GetOpUserID(ctx), groupMemberUserID}) + user, err := g.getGroupMemberMap(ctx, groupID, []string{mcontext.GetOpUserID(ctx), groupMemberUserID}) if err != nil { return } diff --git a/pkg/common/storage/cache/group.go b/pkg/common/storage/cache/group.go index 05b75745a..4be494bf1 100644 --- a/pkg/common/storage/cache/group.go +++ b/pkg/common/storage/cache/group.go @@ -57,6 +57,7 @@ type GroupCache interface { GetGroupRoleLevelMemberInfo(ctx context.Context, groupID string, roleLevel int32) ([]*model.GroupMember, error) GetGroupRolesLevelMemberInfo(ctx context.Context, groupID string, roleLevels []int32) ([]*model.GroupMember, error) GetGroupMemberNum(ctx context.Context, groupID string) (memberNum int64, err error) + GetGroupMemberNums(ctx context.Context, groupIDs []string) (memberNumMap map[string]int64, err error) DelGroupsMemberNum(groupID ...string) GroupCache //FindSortGroupMemberUserIDs(ctx context.Context, groupID string) ([]string, error) diff --git a/pkg/common/storage/cache/redis/group.go b/pkg/common/storage/cache/redis/group.go index d66716404..2c727666b 100644 --- a/pkg/common/storage/cache/redis/group.go +++ b/pkg/common/storage/cache/redis/group.go @@ -2,9 +2,13 @@ package redis import ( "context" + "encoding/json" "fmt" "time" + "github.com/openimsdk/tools/utils/datautil" + "github.com/redis/go-redis/v9" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" @@ -14,7 +18,6 @@ import ( "github.com/openimsdk/protocol/constant" "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" - "github.com/redis/go-redis/v9" ) const ( @@ -258,6 +261,57 @@ func (g *GroupCacheRedis) GetGroupMemberNum(ctx context.Context, groupID string) }) } +type groupMemberNumCache struct { + GroupID string `json:"group_id"` + MemberNum int64 `json:"member_num"` +} + +type groupMemberNumBatchCache struct { + GroupID string + MemberNum int64 +} + +func (r *groupMemberNumBatchCache) BatchCache(groupID string) { + r.GroupID = groupID +} +func (r *groupMemberNumBatchCache) UnmarshalJSON(bytes []byte) error { + return json.Unmarshal(bytes, &r.MemberNum) +} +func (r *groupMemberNumBatchCache) MarshalJSON() ([]byte, error) { + return json.Marshal(r.MemberNum) +} +func (g *GroupCacheRedis) GetGroupMemberNums(ctx context.Context, groupIDs []string) (map[string]int64, error) { + items, err := batchGetCache2( + ctx, + g.rcClient, + g.expireTime, + groupIDs, + func(groupID string) string { return g.getGroupMemberNumKey(groupID) }, + func(v *groupMemberNumBatchCache) string { return v.GroupID }, + func(ctx context.Context, ids []string) ([]*groupMemberNumBatchCache, error) { + res := make([]*groupMemberNumBatchCache, 0, len(ids)) + for _, groupID := range ids { + num, err := g.groupMemberDB.TakeGroupMemberNum(ctx, groupID) + if err != nil { + return nil, err + } + res = append(res, &groupMemberNumBatchCache{ + GroupID: groupID, + MemberNum: num, + }) + } + return res, nil + }, + ) + if err != nil { + return nil, err + } + + return datautil.SliceToMapAny(items, func(item *groupMemberNumBatchCache) (string, int64) { + return item.GroupID, item.MemberNum + }), nil +} + func (g *GroupCacheRedis) DelGroupsMemberNum(groupID ...string) cache.GroupCache { keys := make([]string, 0, len(groupID)) for _, groupID := range groupID { @@ -280,18 +334,111 @@ func (g *GroupCacheRedis) GetGroupOwner(ctx context.Context, groupID string) (*m return members[0], nil } -func (g *GroupCacheRedis) GetGroupsOwner(ctx context.Context, groupIDs []string) ([]*model.GroupMember, error) { - members := make([]*model.GroupMember, 0, len(groupIDs)) - for _, groupID := range groupIDs { - items, err := g.GetGroupRoleLevelMemberInfo(ctx, groupID, constant.GroupOwner) - if err != nil { - return nil, err +type groupRoleLevelMemberIDsBatchCache struct { + GroupID string + UserIDs []string +} + +func (r *groupRoleLevelMemberIDsBatchCache) BatchCache(groupID string) { + r.GroupID = groupID +} +func (r *groupRoleLevelMemberIDsBatchCache) UnmarshalJSON(bytes []byte) (err error) { + return json.Unmarshal(bytes, &r.UserIDs) +} +func (r *groupRoleLevelMemberIDsBatchCache) MarshalJSON() ([]byte, error) { + return json.Marshal(r.UserIDs) +} + +func (g *GroupCacheRedis) batchGetGroupRoleLevelMemberIDs(ctx context.Context, groupIDs []string, roleLevel int32) (map[string][]string, error) { + items, err := batchGetCache2( + ctx, + g.rcClient, + g.expireTime, + groupIDs, + func(groupID string) string { + return g.getGroupRoleLevelMemberIDsKey(groupID, roleLevel) + }, + func(v *groupRoleLevelMemberIDsBatchCache) string { + return v.GroupID + }, + func(ctx context.Context, ids []string) ([]*groupRoleLevelMemberIDsBatchCache, error) { + res := make([]*groupRoleLevelMemberIDsBatchCache, 0, len(ids)) + for _, groupID := range ids { + userIDs, err := g.groupMemberDB.FindRoleLevelUserIDs(ctx, groupID, roleLevel) + if err != nil { + return nil, err + } + res = append(res, &groupRoleLevelMemberIDsBatchCache{ + GroupID: groupID, + UserIDs: userIDs, + }) + } + return res, nil + }, + ) + if err != nil { + return nil, err + } + + return datautil.SliceToMapAny(items, func(item *groupRoleLevelMemberIDsBatchCache) (string, []string) { + return item.GroupID, item.UserIDs + }), nil +} + +type groupUserIDPair struct { + GroupID string + UserID string +} + +func (g *GroupCacheRedis) batchGetGroupMembersByPairs(ctx context.Context, ids []groupUserIDPair) ([]*model.GroupMember, error) { + return batchGetCache2(ctx, g.rcClient, g.expireTime, ids, func(id groupUserIDPair) string { + return g.getGroupMemberInfoKey(id.GroupID, id.UserID) + }, func(member *model.GroupMember) groupUserIDPair { + return groupUserIDPair{GroupID: member.GroupID, UserID: member.UserID} + }, func(ctx context.Context, ids []groupUserIDPair) ([]*model.GroupMember, error) { + groupIDsByUser := make(map[string][]string) + for _, id := range ids { + groupIDsByUser[id.UserID] = append(groupIDsByUser[id.UserID], id.GroupID) } - if len(items) > 0 { - members = append(members, items[0]) + members := make([]*model.GroupMember, 0, len(ids)) + for userID, groupIDs := range groupIDsByUser { + items, err := g.groupMemberDB.FindInGroup(ctx, userID, groupIDs) + if err != nil { + return nil, err + } + members = append(members, items...) + } + return members, nil + }) +} + +func (g *GroupCacheRedis) GetGroupsOwner(ctx context.Context, groupIDs []string) ([]*model.GroupMember, error) { + ownerIDs, err := g.batchGetGroupRoleLevelMemberIDs(ctx, groupIDs, constant.GroupOwner) + if err != nil { + return nil, err + } + pairs := make([]groupUserIDPair, 0, len(groupIDs)) + for _, groupID := range groupIDs { + ids := ownerIDs[groupID] + if len(ids) == 0 { + continue + } + pairs = append(pairs, groupUserIDPair{GroupID: groupID, UserID: ids[0]}) + } + members, err := g.batchGetGroupMembersByPairs(ctx, pairs) + if err != nil { + return nil, err + } + memberMap := datautil.SliceToMapAny(members, func(member *model.GroupMember) (groupUserIDPair, *model.GroupMember) { + return groupUserIDPair{GroupID: member.GroupID, UserID: member.UserID}, member + }) + result := make([]*model.GroupMember, 0, len(pairs)) + for _, pair := range pairs { + if member, ok := memberMap[pair]; ok { + result = append(result, member) } } - return members, nil + return result, nil } func (g *GroupCacheRedis) GetGroupRoleLevelMemberIDs(ctx context.Context, groupID string, roleLevel int32) ([]string, error) { diff --git a/pkg/common/storage/controller/group.go b/pkg/common/storage/controller/group.go index 24209cd6c..17de62444 100644 --- a/pkg/common/storage/controller/group.go +++ b/pkg/common/storage/controller/group.go @@ -65,6 +65,8 @@ type GroupDatabase interface { FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error) // FindGroupMemberNum retrieves the number of members in a group. FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error) + // FindGroupMemberNums retrieves the number of members for multiple groups. + FindGroupMemberNums(ctx context.Context, groupIDs []string) (map[string]uint32, error) // FindUserManagedGroupID retrieves group IDs managed by a user. FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error) // PageGroupRequest paginates through group requests for specified groups. @@ -232,6 +234,18 @@ func (g *groupDatabase) FindGroupMemberNum(ctx context.Context, groupID string) return uint32(num), nil } +func (g *groupDatabase) FindGroupMemberNums(ctx context.Context, groupIDs []string) (map[string]uint32, error) { + nums, err := g.cache.GetGroupMemberNums(ctx, groupIDs) + if err != nil { + return nil, err + } + result := make(map[string]uint32, len(nums)) + for groupID, num := range nums { + result[groupID] = uint32(num) + } + return result, nil +} + func (g *groupDatabase) TakeGroup(ctx context.Context, groupID string) (*model.Group, error) { return g.cache.GetGroupInfo(ctx, groupID) } From 1036e81eb483e09a3a606cc8dd7970c7c5f74c70 Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Fri, 5 Jun 2026 18:25:13 +0800 Subject: [PATCH 18/41] refactor(msg): update regex pattern for conversationID to include a trailing colon (#3737) (cherry picked from commit 82f87551d6067983f4e31f8dacb905c740d58639) --- pkg/common/storage/database/mgo/msg.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/storage/database/mgo/msg.go b/pkg/common/storage/database/mgo/msg.go index 315f4530b..2d49e7c1b 100644 --- a/pkg/common/storage/database/mgo/msg.go +++ b/pkg/common/storage/database/mgo/msg.go @@ -956,7 +956,7 @@ func (m *MsgMgo) GetLastMessageSeqByTime(ctx context.Context, conversationID str { "$match": bson.M{ "doc_id": bson.M{ - "$regex": fmt.Sprintf("^%s", conversationID), + "$regex": fmt.Sprintf("^%s:", conversationID), }, }, }, @@ -1008,7 +1008,7 @@ func (m *MsgMgo) GetLastMessage(ctx context.Context, conversationID string) (*mo { "$match": bson.M{ "doc_id": bson.M{ - "$regex": fmt.Sprintf("^%s", conversationID), + "$regex": fmt.Sprintf("^%s:", conversationID), }, }, }, From 30074d16ae32fa1d50f7ef6a69e4db7b41c59022 Mon Sep 17 00:00:00 2001 From: buvidk1234 <161066602+buvidk1234@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:04:47 +0800 Subject: [PATCH 19/41] perf(cache): fix slice capacity under-allocation in SetUserOnline (#3746) --- pkg/common/storage/cache/redis/online.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/storage/cache/redis/online.go b/pkg/common/storage/cache/redis/online.go index c11473695..d09c44e9a 100644 --- a/pkg/common/storage/cache/redis/online.go +++ b/pkg/common/storage/cache/redis/online.go @@ -112,7 +112,7 @@ func (s *userOnline) SetUserOnline(ctx context.Context, userID string, online, o end ` now := time.Now() - argv := make([]any, 0, 2+len(online)+len(offline)) + argv := make([]any, 0, 4+len(online)+len(offline)) argv = append(argv, int32(s.expire/time.Second), now.Unix(), now.Add(s.expire).Unix(), int32(len(offline))) for _, platformID := range offline { argv = append(argv, platformID) From b3a7342a42ca7daf3e01e275fb0e7d166fb16a58 Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Fri, 26 Jun 2026 01:00:00 -0700 Subject: [PATCH 20/41] pkg/tools/batcher: stop scheduler panicking when b.data is closed externally (#3714) * pkg/tools/batcher: stop scheduler panicking when b.data is closed externally scheduler()'s defer unconditionally calls close(b.data). If the channel was closed by the caller (or an upstream producer) instead of via the normal Close()-sends-nil path, the receive on b.data returns ok == false, scheduler returns, and the deferred close(b.data) then fires on an already-closed channel: panic: close of closed channel reliably reproducible under the #3653 steps (manually closing b.data while Start() is running). Track whether we observed the external-close via a local `externallyClosed` flag set in the `ok == false` branch. The defer only closes b.data when that flag is false, i.e. when the scheduler exited through the nil-message or ticker paths and still owns the channel. No behaviour change on the graceful Close() path. Fixes #3653 * ci: retrigger after transient gha outage Signed-off-by: SAY-5 --------- Signed-off-by: SAY-5 --- pkg/tools/batcher/batcher.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/tools/batcher/batcher.go b/pkg/tools/batcher/batcher.go index 93a31ed8f..bbaa2ca93 100644 --- a/pkg/tools/batcher/batcher.go +++ b/pkg/tools/batcher/batcher.go @@ -151,12 +151,21 @@ func (b *Batcher[T]) Put(ctx context.Context, data *T) error { func (b *Batcher[T]) scheduler() { ticker := time.NewTicker(b.config.interval) + // Track whether b.data was closed by an external caller so the + // cleanup below does not close it a second time. The only routes + // out of this function that leave b.data open are the nil-message + // and ticker paths; the ok == false branch means someone already + // closed the channel, and calling close(b.data) again there would + // panic with "close of closed channel" (#3653). + externallyClosed := false defer func() { ticker.Stop() for _, ch := range b.chArrays { close(ch) } - close(b.data) + if !externallyClosed { + close(b.data) + } b.wait.Done() }() @@ -169,6 +178,7 @@ func (b *Batcher[T]) scheduler() { case data, ok := <-b.data: if !ok { // If the data channel is closed unexpectedly + externallyClosed = true return } if data == nil { From 7cc4ac813b1faf2b5608bee12381c1726aea8aad Mon Sep 17 00:00:00 2001 From: buvidk1234 <161066602+buvidk1234@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:10:37 +0800 Subject: [PATCH 21/41] chore(msg_gateway): remove redundant codes (#3741) --- pkg/rpccache/online.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/rpccache/online.go b/pkg/rpccache/online.go index fb7f18393..fa6fc73d3 100644 --- a/pkg/rpccache/online.go +++ b/pkg/rpccache/online.go @@ -214,8 +214,6 @@ func (o *defaultOnlineCache) GetUserOnlinePlatform(ctx context.Context, userID s if err != nil { return nil, err } - tmp := make([]int32, len(platformIDs)) - copy(tmp, platformIDs) return platformIDs, nil } From 19b0bb24792dba5a931e021ebd0b2750aa6176a2 Mon Sep 17 00:00:00 2001 From: icey-yu <119291641+icey-yu@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:42:41 +0800 Subject: [PATCH 22/41] feat: enhance configuration files with detailed comments for better clarity (#3706) --- config/alertmanager.yml | 42 +++++++++++++------------ config/email.tmpl | 3 ++ config/instance-down-rules.yml | 27 ++++++++-------- config/openim-api.yml | 2 +- config/openim-msggateway.yml | 2 +- config/openim-msgtransfer.yml | 2 +- config/openim-push.yml | 2 +- config/openim-rpc-auth.yml | 2 +- config/openim-rpc-conversation.yml | 2 +- config/openim-rpc-friend.yml | 2 +- config/openim-rpc-group.yml | 2 +- config/openim-rpc-msg.yml | 2 +- config/openim-rpc-third.yml | 2 +- config/openim-rpc-user.yml | 2 +- config/prometheus.yml | 49 +++++++++++++++--------------- 15 files changed, 74 insertions(+), 69 deletions(-) diff --git a/config/alertmanager.yml b/config/alertmanager.yml index 6c675ab6f..0f4d9875f 100644 --- a/config/alertmanager.yml +++ b/config/alertmanager.yml @@ -1,34 +1,36 @@ +# Global Alertmanager runtime and SMTP settings. global: - resolve_timeout: 5m - smtp_from: alert@openim.io - smtp_smarthost: smtp.163.com:465 - smtp_auth_username: alert@openim.io - smtp_auth_password: YOURAUTHPASSWORD - smtp_require_tls: false - smtp_hello: xxx + resolve_timeout: 5m # Wait time before an alert is considered resolved when no further updates are received. + smtp_from: alert@openim.io # Sender address displayed in alert emails. + smtp_smarthost: smtp.163.com:465 # SMTP relay endpoint in host:port format. + smtp_auth_username: alert@openim.io # SMTP authentication username (commonly the same as smtp_from). + smtp_auth_password: YOURAUTHPASSWORD # SMTP authorization token or app password. + smtp_require_tls: false # Set to true when your SMTP provider requires STARTTLS. + smtp_hello: xxx # HELO/EHLO identity presented to the SMTP server. templates: - - /etc/alertmanager/email.tmpl + - /etc/alertmanager/email.tmpl # Go template file used to render HTML email content. +# Root routing tree for all incoming alerts. route: - group_by: [ 'alertname' ] - group_wait: 5s - group_interval: 5s - repeat_interval: 5m - receiver: email + group_by: [ 'alertname' ] # Alerts sharing this label value are batched into one notification. + group_wait: 5s # Initial delay before sending the first notification for a new alert group. + group_interval: 5s # Minimum interval between notifications for the same alert group. + repeat_interval: 5m # Reminder interval while an alert group remains firing. + receiver: email # Default receiver when no child route matches. routes: - matchers: - - alertname = "XXX" - group_by: [ 'instance' ] + - alertname = "XXX" # Example matcher; replace with a real alert name or remove this route. + group_by: [ 'instance' ] # Override grouping for this specific route. group_wait: 5s group_interval: 5s repeat_interval: 5m receiver: email receivers: - - name: email + - name: email # Receiver name referenced by route.receiver. email_configs: - - to: 'alert@example.com' - html: '{{ template "email.to.html" . }}' - headers: { Subject: "[OPENIM-SERVER]Alarm" } - send_resolved: true + - to: 'alert@example.com' # Recipient mailbox for alert notifications. + html: '{{ template "email.to.html" . }}' # Rendered with the template declared in email.tmpl. + headers: { Subject: "[OPENIM-SERVER]Alarm" } # Custom email subject line. + send_resolved: true # Also send a notification when the alert recovers. diff --git a/config/email.tmpl b/config/email.tmpl index 824144e9d..ab9642e85 100644 --- a/config/email.tmpl +++ b/config/email.tmpl @@ -1,3 +1,6 @@ +{{/* OpenIM Alertmanager email template. +This template renders both firing and resolved alerts. +Each alert entry reads labels and annotations from Prometheus rule definitions. */}} {{ define "email.to.html" }} {{ if eq .Status "firing" }} {{ range .Alerts }} diff --git a/config/instance-down-rules.yml b/config/instance-down-rules.yml index bcac7ba60..60b26e33f 100644 --- a/config/instance-down-rules.yml +++ b/config/instance-down-rules.yml @@ -1,30 +1,31 @@ +# Default Prometheus alert groups for OpenIM. groups: - - name: instance_down + - name: instance_down # Fires when a monitored target remains unreachable. rules: - alert: InstanceDown - expr: up == 0 - for: 1m + expr: up == 0 # The built-in "up" metric is 0 when the latest scrape fails. + for: 1m # Trigger only if the condition remains true for more than 1 minute. labels: - severity: critical + severity: critical # Used by Alertmanager for routing and notification priority. annotations: summary: "Instance {{ $labels.instance }} down" - description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes." + description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute." - - name: database_insert_failure_alerts + - name: database_insert_failure_alerts # Detects failures when persisting messages to Redis or MongoDB. rules: - alert: DatabaseInsertFailed - expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) - for: 1m + expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) # Any positive increase indicates write failures occurred in the last 5 minutes. + for: 1m # Avoid firing on very short spikes. labels: severity: critical annotations: summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected" - description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter has increased in the last 5 minutes, indicating failures in message insert operations to Redis or MongoDB,maybe the redis or mongodb is crash." + description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter increased in the last 5 minutes, indicating message insert failures to Redis or MongoDB and a possible backend outage." - - name: registrations_few + - name: registrations_few # Operational early-warning rule for unusually low login/registration activity. rules: - alert: RegistrationsFew - expr: increase(user_login_total[1h]) == 0 + expr: increase(user_login_total[1h]) == 0 # No successful login/registration events observed in 1 hour. for: 1m labels: severity: info @@ -32,10 +33,10 @@ groups: summary: "Too few registrations within the time frame" description: "The number of registrations in the last hour is 0. There might be some issues." - - name: messages_few + - name: messages_few # Operational early-warning rule for unusually low messaging activity. rules: - alert: MessagesFew - expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0 + expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0 # No successful single or group messages observed in 1 hour. for: 1m labels: severity: info diff --git a/config/openim-api.yml b/config/openim-api.yml index df0177d24..89be50123 100644 --- a/config/openim-api.yml +++ b/config/openim-api.yml @@ -8,7 +8,7 @@ api: prometheus: - # Whether to enable prometheus + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # autoSetPorts indicates whether to automatically set the ports autoSetPorts: true diff --git a/config/openim-msggateway.yml b/config/openim-msggateway.yml index 8ac07faae..7c2f17158 100644 --- a/config/openim-msggateway.yml +++ b/config/openim-msggateway.yml @@ -9,7 +9,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-msgtransfer.yml b/config/openim-msgtransfer.yml index c6ea06803..972a378b7 100644 --- a/config/openim-msgtransfer.yml +++ b/config/openim-msgtransfer.yml @@ -1,5 +1,5 @@ prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # autoSetPorts indicates whether to automatically set the ports autoSetPorts: true diff --git a/config/openim-push.yml b/config/openim-push.yml index 58784f13d..ab65a2eee 100644 --- a/config/openim-push.yml +++ b/config/openim-push.yml @@ -28,7 +28,7 @@ circuitBreaker: request: 500 # Request threshold; circuit breaker evaluation occurs when reached prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: false # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-auth.yml b/config/openim-rpc-auth.yml index 09ceef0f4..e1c359120 100644 --- a/config/openim-rpc-auth.yml +++ b/config/openim-rpc-auth.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-conversation.yml b/config/openim-rpc-conversation.yml index 1135ffe6e..f07710ba7 100644 --- a/config/openim-rpc-conversation.yml +++ b/config/openim-rpc-conversation.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-friend.yml b/config/openim-rpc-friend.yml index 1135ffe6e..f07710ba7 100644 --- a/config/openim-rpc-friend.yml +++ b/config/openim-rpc-friend.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-group.yml b/config/openim-rpc-group.yml index 154b149e1..20ac70af2 100644 --- a/config/openim-rpc-group.yml +++ b/config/openim-rpc-group.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-msg.yml b/config/openim-rpc-msg.yml index e05eeb7e4..d3fadb941 100644 --- a/config/openim-rpc-msg.yml +++ b/config/openim-rpc-msg.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-third.yml b/config/openim-rpc-third.yml index f6fbee695..29f05a027 100644 --- a/config/openim-rpc-third.yml +++ b/config/openim-rpc-third.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Enable or disable Prometheus monitoring + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup # It will only take effect when autoSetPorts is set to false. diff --git a/config/openim-rpc-user.yml b/config/openim-rpc-user.yml index c46db7f37..9b16b85ec 100644 --- a/config/openim-rpc-user.yml +++ b/config/openim-rpc-user.yml @@ -11,7 +11,7 @@ rpc: ports: prometheus: - # Whether to enable prometheus + # Enable Prometheus metrics exposure for this service; set to true to allow scraping. enable: true # Prometheus listening ports, must be consistent with the number of rpc.ports # It will only take effect when autoSetPorts is set to false. diff --git a/config/prometheus.yml b/config/prometheus.yml index 0b13326d1..68a9e7c45 100644 --- a/config/prometheus.yml +++ b/config/prometheus.yml @@ -1,35 +1,34 @@ -# my global config +# Global Prometheus runtime settings. global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. - # scrape_timeout is set to the global default (10s). + # scrape_timeout defaults to 10s unless overridden in a specific scrape job. -# Alertmanager configuration +# Alertmanager endpoints that receive alert events from Prometheus. alerting: alertmanagers: - static_configs: - - targets: [127.0.0.1:19093] + - targets: [127.0.0.1:19093] # Alertmanager address in host:port format. -# Load rules once and periodically evaluate them according to the global evaluation_interval. +# Rule files loaded by Prometheus. rule_files: - - instance-down-rules.yml + - instance-down-rules.yml # Default OpenIM alert rules; add more files here if needed. # - first_rules.yml # - second_rules.yml -# A scrape configuration containing exactly one endpoint to scrape: -# Here it's Prometheus itself. +# Scrape jobs used to collect infrastructure and OpenIM service metrics. scrape_configs: - # The job name is added as a label "job=job_name" to any timeseries scraped from this config. - # Monitored information captured by prometheus - - # prometheus fetches application services + # The job_name value is attached as the "job" label in collected time series. - job_name: node_exporter static_configs: - - targets: [ 127.0.0.1:19100 ] + - targets: [ 127.0.0.1:19100 ] # node_exporter endpoint for host CPU, memory, disk, and network metrics. + + # OpenIM services are discovered dynamically from the admin API. + # For multi-host deployments, replace 127.0.0.1 with a reachable internal address. - job_name: openimserver-openim-api http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/api" + - url: "http://127.0.0.1:10002/prometheus_discovery/api" # Service discovery endpoint for OpenIM API instances. # static_configs: # - targets: [ 127.0.0.1:12002 ] # labels: @@ -37,7 +36,7 @@ scrape_configs: - job_name: openimserver-openim-msggateway http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" # Service discovery endpoint for msggateway instances. # static_configs: # - targets: [ 127.0.0.1:12140 ] # # - targets: [ 127.0.0.1:12140, 127.0.0.1:12141, 127.0.0.1:12142, 127.0.0.1:12143, 127.0.0.1:12144, 127.0.0.1:12145, 127.0.0.1:12146, 127.0.0.1:12147, 127.0.0.1:12148, 127.0.0.1:12149, 127.0.0.1:12150, 127.0.0.1:12151, 127.0.0.1:12152, 127.0.0.1:12153, 127.0.0.1:12154, 127.0.0.1:12155 ] @@ -46,7 +45,7 @@ scrape_configs: - job_name: openimserver-openim-msgtransfer http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" # Service discovery endpoint for msgtransfer instances. # static_configs: # - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027 ] # # - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027, 127.0.0.1:12028, 127.0.0.1:12029, 127.0.0.1:12030, 127.0.0.1:12031, 127.0.0.1:12032, 127.0.0.1:12033, 127.0.0.1:12034, 127.0.0.1:12035 ] @@ -55,7 +54,7 @@ scrape_configs: - job_name: openimserver-openim-push http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/push" + - url: "http://127.0.0.1:10002/prometheus_discovery/push" # Service discovery endpoint for push service instances. # static_configs: # - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177 ] ## - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177, 127.0.0.1:12178, 127.0.0.1:12179, 127.0.0.1:12180, 127.0.0.1:12182, 127.0.0.1:12183, 127.0.0.1:12184, 127.0.0.1:12185, 127.0.0.1:12186 ] @@ -64,7 +63,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-auth http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/auth" + - url: "http://127.0.0.1:10002/prometheus_discovery/auth" # Service discovery endpoint for auth RPC instances. # static_configs: # - targets: [ 127.0.0.1:12200 ] # labels: @@ -72,7 +71,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-conversation http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/conversation" + - url: "http://127.0.0.1:10002/prometheus_discovery/conversation" # Service discovery endpoint for conversation RPC instances. # static_configs: # - targets: [ 127.0.0.1:12220 ] # labels: @@ -80,7 +79,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-friend http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/friend" + - url: "http://127.0.0.1:10002/prometheus_discovery/friend" # Service discovery endpoint for friend RPC instances. # static_configs: # - targets: [ 127.0.0.1:12240 ] # labels: @@ -88,7 +87,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-group http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/group" + - url: "http://127.0.0.1:10002/prometheus_discovery/group" # Service discovery endpoint for group RPC instances. # static_configs: # - targets: [ 127.0.0.1:12260 ] # labels: @@ -96,7 +95,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-msg http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/msg" + - url: "http://127.0.0.1:10002/prometheus_discovery/msg" # Service discovery endpoint for msg RPC instances. # static_configs: # - targets: [ 127.0.0.1:12280 ] # labels: @@ -104,7 +103,7 @@ scrape_configs: - job_name: openimserver-openim-rpc-third http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/third" + - url: "http://127.0.0.1:10002/prometheus_discovery/third" # Service discovery endpoint for third-party RPC instances. # static_configs: # - targets: [ 127.0.0.1:12300 ] # labels: @@ -112,8 +111,8 @@ scrape_configs: - job_name: openimserver-openim-rpc-user http_sd_configs: - - url: "http://127.0.0.1:10002/prometheus_discovery/user" + - url: "http://127.0.0.1:10002/prometheus_discovery/user" # Service discovery endpoint for user RPC instances. # static_configs: # - targets: [ 127.0.0.1:12320 ] # labels: -# namespace: default \ No newline at end of file +# namespace: default From 88da73f2b3bf9338517e2c3d6ea81d7e4a847f33 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:46:37 +0800 Subject: [PATCH 23/41] Update CHANGELOG for release v3.8.3-patch.7 (#3492) Co-authored-by: mo3et <34803812+mo3et@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.8.md | 70 ++++---------------------------------- 1 file changed, 6 insertions(+), 64 deletions(-) diff --git a/CHANGELOG/CHANGELOG-3.8.md b/CHANGELOG/CHANGELOG-3.8.md index 9ae41e6a3..bf4409efd 100644 --- a/CHANGELOG/CHANGELOG-3.8.md +++ b/CHANGELOG/CHANGELOG-3.8.md @@ -1,70 +1,12 @@ -## [v3.8.3-patch.6](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.6) (2025-07-23) - -### Bug Fixes -* fix: Add friend DB in notification sender [#3438](https://github.com/openimsdk/open-im-server/pull/3438) -* fix: remove update version file workflows have new line in 3.8.3-patch branch. [#3452](https://github.com/openimsdk/open-im-server/pull/3452) -* fix: s3 aws init [#3454](https://github.com/openimsdk/open-im-server/pull/3454) -* fix: use safe submodule init in workflows in v3.8.3-patch. [#3469](https://github.com/openimsdk/open-im-server/pull/3469) - -**Full Changelog**: [v3.8.3-patch.5...v3.8.3-patch.6](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.5...v3.8.3-patch.6) - -## [v3.8.3-patch.5](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.5) (2025-06-10) +## [v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.7) (2025-07-29) ### New Features -* feat: optimize friend and group applications [#3396](https://github.com/openimsdk/open-im-server/pull/3396) +* feat: add filtering for invalid messages and invalid conversations to… [#3483](https://github.com/openimsdk/open-im-server/pull/3483) ### Bug Fixes -* fix: solve unocrrect invite notification [Created [#3219](https://github.com/openimsdk/open-im-server/pull/3219) +* fix: correctly aggregate read seqs [#3482](https://github.com/openimsdk/open-im-server/pull/3482) +* fix: import friends send notification in v3.8.3-patch [#3488](https://github.com/openimsdk/open-im-server/pull/3488) +* fix: solve redis config db field in v3.8.3-patch [#3490](https://github.com/openimsdk/open-im-server/pull/3490) -### Builds -* build: update gomake version in dockerfile.[Patch branch] [#3416](https://github.com/openimsdk/open-im-server/pull/3416) +**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7) -**Full Changelog**: [v3.8.3...v3.8.3-patch.5](https://github.com/openimsdk/open-im-server/compare/v3.8.3...v3.8.3-patch.5) - -## [v3.8.3-patch.4](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.4) (2025-03-13) - -### Bug Fixes -* fix: solve unocrrect invite notificationfrom #3213 - -**Full Changelog**: [v3.8.3-patch.3...v3.8.3-patch.4](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.3...v3.8.3-patch.4) - -## [v3.8.3-patch.3](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.3) (2025-03-07) - -### New Features -* feat: optimizing BatchGetIncrementalGroupMember #3180 - -### Bug Fixes -* fix: solve uncorrect notification when set group info #3172 -* fix: the sorting is wrong after canceling the administrator in group settings #3185 -* fix: solve uncorrect GroupMember enter group notification type. #3188 - -### Refactors -* refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. #3173 - -**Full Changelog**: [v3.8.3-patch.2...v3.8.3-patch.3](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.2...v3.8.3-patch.3) - -## [v3.8.3-patch.2](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.2) (2025-02-28) - -### Bug Fixes -* fix: Offline push does not have a badge && Android offline push (#3146) [#3174](https://github.com/openimsdk/open-im-server/pull/3174) - -**Full Changelog**: [v3.8.3-patch.1...v3.8.3-patch.2](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.1...v3.8.3-patch.2) - -## [v3.8.3-patch.1](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.1) (2025-02-25) - -### New Features -* feat: add backup volume && optimize log print [Created [#3121](https://github.com/openimsdk/open-im-server/pull/3121) - -### Bug Fixes -* fix: seq conversion failed without exiting [Created [#3120](https://github.com/openimsdk/open-im-server/pull/3120) -* fix: check error in BatchSetTokenMapByUidPid [Created [#3123](https://github.com/openimsdk/open-im-server/pull/3123) -* fix: DeleteDoc crash [Created [#3124](https://github.com/openimsdk/open-im-server/pull/3124) -* fix: the abnormal message has no sending time, causing the SDK to be abnormal [Created [#3126](https://github.com/openimsdk/open-im-server/pull/3126) -* fix: crash caused [#3127](https://github.com/openimsdk/open-im-server/pull/3127) -* fix: the user sets the conversation timer cleanup timestamp unit incorrectly [Created [#3128](https://github.com/openimsdk/open-im-server/pull/3128) -* fix: seq conversion not reading env in docker environment [Created [#3131](https://github.com/openimsdk/open-im-server/pull/3131) - -### Builds -* build: improve workflows contents. [Created [#3125](https://github.com/openimsdk/open-im-server/pull/3125) - -**Full Changelog**: [v3.8.3-e-v1.1.5...v3.8.3-patch.1-e-v1.1.5](https://github.com/openimsdk/open-im-server-enterprise/compare/v3.8.3-e-v1.1.5...v3.8.3-patch.1-e-v1.1.5) \ No newline at end of file From 42bf2c35b45d88fcf857bac97676770c5f1f8de7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:50:03 +0800 Subject: [PATCH 24/41] Update CHANGELOG for release v3.8.3-patch.8 (#3520) Co-authored-by: mo3et <34803812+mo3et@users.noreply.github.com> Co-authored-by: chao <48119764+withchao@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.8.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG/CHANGELOG-3.8.md b/CHANGELOG/CHANGELOG-3.8.md index bf4409efd..394f9562c 100644 --- a/CHANGELOG/CHANGELOG-3.8.md +++ b/CHANGELOG/CHANGELOG-3.8.md @@ -1,3 +1,11 @@ +## [v3.8.3-patch.8](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.8) (2025-08-13) + +### Bug Fixes +* fix: fix incorrect kicked logic and PCAndOther Login policy In v3.8.3-patch [#3511](https://github.com/openimsdk/open-im-server/pull/3511) +* fix: solve batch incorrect error in Find DocIDs in v3.8.3-patch branch. [#3515](https://github.com/openimsdk/open-im-server/pull/3515) + +**Full Changelog**: [v3.8.3-patch.7...v3.8.3-patch.8](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.7...v3.8.3-patch.8) + ## [v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.7) (2025-07-29) ### New Features @@ -8,5 +16,4 @@ * fix: import friends send notification in v3.8.3-patch [#3488](https://github.com/openimsdk/open-im-server/pull/3488) * fix: solve redis config db field in v3.8.3-patch [#3490](https://github.com/openimsdk/open-im-server/pull/3490) -**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7) - +**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7) \ No newline at end of file From 5803ae8da011157db93c08ff3e824f3b4a07531d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:51:54 +0800 Subject: [PATCH 25/41] Update CHANGELOG for release v3.8.3-patch.9 (#3536) Co-authored-by: mo3et <34803812+mo3et@users.noreply.github.com> Co-authored-by: chao <48119764+withchao@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.8.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG/CHANGELOG-3.8.md b/CHANGELOG/CHANGELOG-3.8.md index 394f9562c..63d8bf303 100644 --- a/CHANGELOG/CHANGELOG-3.8.md +++ b/CHANGELOG/CHANGELOG-3.8.md @@ -1,3 +1,13 @@ +## [v3.8.3-patch.9](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.9) (2025-08-19) + +### New Features +* feat: enable redis aof-use-rdb-preamble && disable auto rdb [Created [#3535](https://github.com/openimsdk/open-im-server/pull/3535) + +### Bug Fixes +* fix: fill in the most recent sendTime for a gap message to prevent th… [#3523](https://github.com/openimsdk/open-im-server/pull/3523) + +**Full Changelog**: [v3.8.3-patch.8...v3.8.3-patch.9](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.8...v3.8.3-patch.9) + ## [v3.8.3-patch.8](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.8) (2025-08-13) ### Bug Fixes From 0ed1b4e0b7a0897be971c4066ce77f868d597add Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:53:47 +0800 Subject: [PATCH 26/41] Update CHANGELOG for release v3.8.3-patch.12 (#3603) Co-authored-by: mo3et <34803812+mo3et@users.noreply.github.com> Co-authored-by: chao <48119764+withchao@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.8.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG/CHANGELOG-3.8.md b/CHANGELOG/CHANGELOG-3.8.md index 63d8bf303..27b8c83a9 100644 --- a/CHANGELOG/CHANGELOG-3.8.md +++ b/CHANGELOG/CHANGELOG-3.8.md @@ -1,3 +1,11 @@ +## [v3.8.3-patch.12](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.12) (2025-10-24) + +### Bug Fixes +* fix: full id version [#3589](https://github.com/openimsdk/open-im-server/pull/3589) +* fix: incorrect redis fields. [#3602](https://github.com/openimsdk/open-im-server/pull/3602) + +**Full Changelog**: [v3.8.3-patch.11...v3.8.3-patch.12](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.11...v3.8.3-patch.12) + ## [v3.8.3-patch.9](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.9) (2025-08-19) ### New Features From de3c1ba6300568533420b29dac89e8e685c2aa65 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:10:26 +0800 Subject: [PATCH 27/41] Update CHANGELOG for release v3.8.3-patch.16 (#3703) Co-authored-by: dsx137 <70027572+dsx137@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- CHANGELOG/CHANGELOG-3.8.md | 250 ++++++++++++++++++++++++++++++++++++- 1 file changed, 249 insertions(+), 1 deletion(-) diff --git a/CHANGELOG/CHANGELOG-3.8.md b/CHANGELOG/CHANGELOG-3.8.md index 27b8c83a9..bdec996d9 100644 --- a/CHANGELOG/CHANGELOG-3.8.md +++ b/CHANGELOG/CHANGELOG-3.8.md @@ -1,3 +1,251 @@ +## [v3.8.3-patch.16](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.16) (2026-03-19) + +### New Features +* feat: provide the interface required [#2712](https://github.com/openimsdk/open-im-server/pull/2712) +* feat: add webhooks of online status and remove zookeeper configuration. [#2716](https://github.com/openimsdk/open-im-server/pull/2716) +* feat: Add More Multi Login Policy [#2770](https://github.com/openimsdk/open-im-server/pull/2770) +* feat: Push configuration can ignore case sensitivity [#2775](https://github.com/openimsdk/open-im-server/pull/2775) +* feat: support app update service [#2794](https://github.com/openimsdk/open-im-server/pull/2794) +* feat: implement merge milestone PR to target-branch. [#2796](https://github.com/openimsdk/open-im-server/pull/2796) +* feat: support app update service [#2811](https://github.com/openimsdk/open-im-server/pull/2811) +* feat: ApplicationVersion move chat [#2813](https://github.com/openimsdk/open-im-server/pull/2813) +* feat: Update login policy [#2822](https://github.com/openimsdk/open-im-server/pull/2822) +* feat: support stream message [#2824](https://github.com/openimsdk/open-im-server/pull/2824) +* feat: merge js sdk [#2856](https://github.com/openimsdk/open-im-server/pull/2856) +* feat: Print Panic Log [#2850](https://github.com/openimsdk/open-im-server/pull/2850) +* feat: seq user and conversation seq synchronization [#2924](https://github.com/openimsdk/open-im-server/pull/2924) +* feat: support aws [#2938](https://github.com/openimsdk/open-im-server/pull/2938) +* feat: Prometheus can auto set port [#2943](https://github.com/openimsdk/open-im-server/pull/2943) +* feat: Change upload logs systemType to AppFramework. [#2927](https://github.com/openimsdk/open-im-server/pull/2927) +* feat: support quote ContentType in SendMsg. [#2819](https://github.com/openimsdk/open-im-server/pull/2819) +* feat: Group Monitoring Components, Enable Host Mode && Deprecate reliabilityLevel and unreadCount in notification.yml [#2975](https://github.com/openimsdk/open-im-server/pull/2975) +* feat: Add node_exporter in docker-compose [#2979](https://github.com/openimsdk/open-im-server/pull/2979) +* feat: Optimize Scheduled Task [#2985](https://github.com/openimsdk/open-im-server/pull/2985) +* feat: Optimizing RPC call [#2993](https://github.com/openimsdk/open-im-server/pull/2993) +* feat: optimize error stack information [#2995](https://github.com/openimsdk/open-im-server/pull/2995) +* feat: config center [#2997](https://github.com/openimsdk/open-im-server/pull/2997) +* feat: support message cache [#3007](https://github.com/openimsdk/open-im-server/pull/3007) +* feat: optimize log output [#3026](https://github.com/openimsdk/open-im-server/pull/3026) +* feat: support GetLastMessage [#3029](https://github.com/openimsdk/open-im-server/pull/3029) +* feat: Add enable config center button && fix: grpc connection leakage [#3036](https://github.com/openimsdk/open-im-server/pull/3036) +* feat: change appNotificationAccount to appManagerAccount && fix: enable config center add env check && fix: error return [#3038](https://github.com/openimsdk/open-im-server/pull/3038) +* feat: SendBusinessNotification supported configuration parameters [#3048](https://github.com/openimsdk/open-im-server/pull/3048) +* feat: add backup volume && optimize log print [#3066](https://github.com/openimsdk/open-im-server/pull/3066) +* feat: optimize code and support running in single process mode [#3142](https://github.com/openimsdk/open-im-server/pull/3142) +* feat: Change after webhook filter && feat SendSimpleMsg [#3151](https://github.com/openimsdk/open-im-server/pull/3151) +* feat: the default notification.yml is not configured properly [#3168](https://github.com/openimsdk/open-im-server/pull/3168) +* feat: add a new message type: Markdown text [#3162](https://github.com/openimsdk/open-im-server/pull/3162) +* feat: add a field to specify whether to send a notification message w… [#3163](https://github.com/openimsdk/open-im-server/pull/3163) +* feat: optimizing BatchGetIncrementalGroupMember [#3180](https://github.com/openimsdk/open-im-server/pull/3180) +* feat: system account send msg doesn't need friend verify [#3187](https://github.com/openimsdk/open-im-server/pull/3187) +* feat: sending messages supports returning fields modified [#3192](https://github.com/openimsdk/open-im-server/pull/3192) +* feat: set configs api [#3183](https://github.com/openimsdk/open-im-server/pull/3183) +* feat: check if the secret in config/share.yml has been changed during registration [#3223](https://github.com/openimsdk/open-im-server/pull/3223) +* feat: Implement webhook in createConversation [#3228](https://github.com/openimsdk/open-im-server/pull/3228) +* feat: add a function for business info change to update related conve… [#3225](https://github.com/openimsdk/open-im-server/pull/3225) +* feat: add filtering for invalid messages and invalid conversations to… [#3239](https://github.com/openimsdk/open-im-server/pull/3239) +* feat: implement stress-test tools. [#3261](https://github.com/openimsdk/open-im-server/pull/3261) +* feat: support server-issued configuration, which can be set for individual users [#3271](https://github.com/openimsdk/open-im-server/pull/3271) +* feat: GetConversationsHasReadAndMaxSeq support pinned [#3281](https://github.com/openimsdk/open-im-server/pull/3281) +* feat: Implement stress test v2. [#3292](https://github.com/openimsdk/open-im-server/pull/3292) +* feat: GroupApplicationAgreeMemberEnterNotification splitting [#3297](https://github.com/openimsdk/open-im-server/pull/3297) +* feat: optimize server code [#3319](https://github.com/openimsdk/open-im-server/pull/3319) +* feat: add rpc interface permission check [#3366](https://github.com/openimsdk/open-im-server/pull/3366) +* feat: optimize friend and group applications [#3384](https://github.com/openimsdk/open-im-server/pull/3384) +* feat: support distributed lock in crontask. [#3401](https://github.com/openimsdk/open-im-server/pull/3401) +* feat: Implement etcd and kafka auth. [#3394](https://github.com/openimsdk/open-im-server/pull/3394) +* feat: support redis sentinel. [#3423](https://github.com/openimsdk/open-im-server/pull/3423) +* feat: add api logger [#3427](https://github.com/openimsdk/open-im-server/pull/3427) +* feat: add nickname for adminUser [#3435](https://github.com/openimsdk/open-im-server/pull/3435) +* feat: support mongo replicaset mode. [#3433](https://github.com/openimsdk/open-im-server/pull/3433) +* feat: enable redis aof-use-rdb-preamble && disable auto rdb [#3529](https://github.com/openimsdk/open-im-server/pull/3529) +* feat: implement auth local cache. [#3533](https://github.com/openimsdk/open-im-server/pull/3533) +* feat: add msgDBSave webhook when data save to DB. [#3578](https://github.com/openimsdk/open-im-server/pull/3578) +* feat: implement DeleteConversations interface. [#3549](https://github.com/openimsdk/open-im-server/pull/3549) +* feat: replace LongConn with ClientConn interface and simplify message handling [#3643](https://github.com/openimsdk/open-im-server/pull/3643) +* feat: add error code for handled friend requests and improve error handling in friend operations [#3670](https://github.com/openimsdk/open-im-server/pull/3670) +* feat: update protocol support botPlatform [#3696](https://github.com/openimsdk/open-im-server/pull/3696) +* feat: gomake upgrade [#3702](https://github.com/openimsdk/open-im-server/pull/3702) + +### Bug Fixes +* fix: the message I sent is not set to read seq in mongodb [#2718](https://github.com/openimsdk/open-im-server/pull/2718) +* fix: cannot modify group member avatars [#2719](https://github.com/openimsdk/open-im-server/pull/2719) +* fix: auth package import twice [#2724](https://github.com/openimsdk/open-im-server/pull/2724) +* fix: join the group chat directly, notification type error [#2772](https://github.com/openimsdk/open-im-server/pull/2772) +* fix: change update group member level logic [#2730](https://github.com/openimsdk/open-im-server/pull/2730) +* fix: joinSource check args error. [#2773](https://github.com/openimsdk/open-im-server/pull/2773) +* fix: Change group member roleLevel can`t send notification [#2777](https://github.com/openimsdk/open-im-server/pull/2777) +* fix: client sends message status error to server [#2779](https://github.com/openimsdk/open-im-server/pull/2779) +* fix: del UserB's conversation version cache when userA set conversati… [#2785](https://github.com/openimsdk/open-im-server/pull/2785) +* fix: improve setConversationAtInfo logic. [#2782](https://github.com/openimsdk/open-im-server/pull/2782) +* fix: improve transfer Owner logic when newOwner is mute. [#2790](https://github.com/openimsdk/open-im-server/pull/2790) +* fix: improve getUserInfo logic. [#2792](https://github.com/openimsdk/open-im-server/pull/2792) +* fix: improve time condition check mehtod. [#2804](https://github.com/openimsdk/open-im-server/pull/2804) +* fix: webhook before online push [#2805](https://github.com/openimsdk/open-im-server/pull/2805) +* fix: set own read seq in MongoDB when sender send a message. [#2808](https://github.com/openimsdk/open-im-server/pull/2808) +* fix: solve err Notification when setGroupInfo. [#2806](https://github.com/openimsdk/open-im-server/pull/2806) +* fix: improve condition check. [#2815](https://github.com/openimsdk/open-im-server/pull/2815) +* fix: Write back message to Redis [#2836](https://github.com/openimsdk/open-im-server/pull/2836) +* fix: get group return repeated result [#2842](https://github.com/openimsdk/open-im-server/pull/2842) +* fix: SetConversations can update new conversation [#2838](https://github.com/openimsdk/open-im-server/pull/2838) +* fix(push): push content with jpush [#2844](https://github.com/openimsdk/open-im-server/pull/2844) +* fix #2860 migrate jpns to jpush [#2861](https://github.com/openimsdk/open-im-server/pull/2861) +* fix: concurrent write to websocket connection [#2866](https://github.com/openimsdk/open-im-server/pull/2866) +* fix: Remove admin token in redis [#2871](https://github.com/openimsdk/open-im-server/pull/2871) +* Fix Push2User webhookBeforeOfflinePush [#2862](https://github.com/openimsdk/open-im-server/pull/2862) +* fix: move workflow to correct path [#2837](https://github.com/openimsdk/open-im-server/pull/2837) +* fix: del login Policy [#2825](https://github.com/openimsdk/open-im-server/pull/2825) +* fix: Wrong Redis Error Check [#2876](https://github.com/openimsdk/open-im-server/pull/2876) +* fix: minor log typo [#2881](https://github.com/openimsdk/open-im-server/pull/2881) +* fix: webhookAfterSingleMsgRead will be called correctly [#2884](https://github.com/openimsdk/open-im-server/pull/2884) +* fix: webhookBeforeSendSingleMsg will call before black and friend check [#2885](https://github.com/openimsdk/open-im-server/pull/2885) +* fix: Wrong Redis Error Check [#2891](https://github.com/openimsdk/open-im-server/pull/2891) +* fix: improve crontask delete outdated Data. [#2901](https://github.com/openimsdk/open-im-server/pull/2901) +* fix: go mod [#2906](https://github.com/openimsdk/open-im-server/pull/2906) +* fix: group member update face_url [#2910](https://github.com/openimsdk/open-im-server/pull/2910) +* fix: update set seq implement. [#2911](https://github.com/openimsdk/open-im-server/pull/2911) +* fix https://github.com/openimsdk/open-im-server/issues/2895 [#2896](https://github.com/openimsdk/open-im-server/pull/2896) +* fix: Can choose whether to set the port. [#2929](https://github.com/openimsdk/open-im-server/pull/2929) +* fix: Configure move service discovery into discovery [#2934](https://github.com/openimsdk/open-im-server/pull/2934) +* fix: compilation failed under Windows [#2940](https://github.com/openimsdk/open-im-server/pull/2940) +* fix: server can return isEnd to control fetch messages when sdk pull … [#2949](https://github.com/openimsdk/open-im-server/pull/2949) +* fix:Only print panic function frame && feat: log.ZPanic [#2947](https://github.com/openimsdk/open-im-server/pull/2947) +* fix: seq user and conversation seq synchronization [#2958](https://github.com/openimsdk/open-im-server/pull/2958) +* fix: fetch message return isEnd and endSeq panic. [#2959](https://github.com/openimsdk/open-im-server/pull/2959) +* fix: rpc panic recover [#2957](https://github.com/openimsdk/open-im-server/pull/2957) +* fix: modifying other fields while setting IsPrivateChat does not take effect [#2972](https://github.com/openimsdk/open-im-server/pull/2972) +* fix: when fetching a referenced message, it indicates that the original message has been deleted. [#2977](https://github.com/openimsdk/open-im-server/pull/2977) +* fix: when unable EnableHistoryForNewMembers, new group member can read last one message. [#3001](https://github.com/openimsdk/open-im-server/pull/3001) +* fix: redis save error when KickTokens [#3002](https://github.com/openimsdk/open-im-server/pull/3002) +* fix: The message @ information will be set only for members in the gr… [#3009](https://github.com/openimsdk/open-im-server/pull/3009) +* fix: restart permission check [#3011](https://github.com/openimsdk/open-im-server/pull/3011) +* fix: The system cannot be restarted the first time the configuration is set. [#3013](https://github.com/openimsdk/open-im-server/pull/3013) +* fix: jssdk not init [#3016](https://github.com/openimsdk/open-im-server/pull/3016) +* fix: online status error [#3022](https://github.com/openimsdk/open-im-server/pull/3022) +* fix: GetUsersOnline returns an error in the online list [#3040](https://github.com/openimsdk/open-im-server/pull/3040) +* fix: seq conversion failed without exiting [#3052](https://github.com/openimsdk/open-im-server/pull/3052) +* fix: check error in BatchSetTokenMapByUidPid [#3076](https://github.com/openimsdk/open-im-server/pull/3076) +* fix: DeleteDoc crash [#3078](https://github.com/openimsdk/open-im-server/pull/3078) +* fix: the abnormal message has no sending time, causing the SDK to be abnormal [#3087](https://github.com/openimsdk/open-im-server/pull/3087) +* fix: crash caused [#3100](https://github.com/openimsdk/open-im-server/pull/3100) +* fix: the user sets the conversation timer cleanup timestamp unit incorrectly [#3102](https://github.com/openimsdk/open-im-server/pull/3102) +* fix: solve workflows stop when merge failed [#3106](https://github.com/openimsdk/open-im-server/pull/3106) +* fix: seq conversion not reading env in docker environment [#3130](https://github.com/openimsdk/open-im-server/pull/3130) +* fix: the source message of the reference is withdrawn, and the referenced message is deleted [#3137](https://github.com/openimsdk/open-im-server/pull/3137) +* fix: Offline push does not have a badge && Android offline push [#3146](https://github.com/openimsdk/open-im-server/pull/3146) +* fix: PCAndOther multi login policy can`t get old clients correctly [#3158](https://github.com/openimsdk/open-im-server/pull/3158) +* fix: solve uncorrect notification when set group info [#3172](https://github.com/openimsdk/open-im-server/pull/3172) +* fix: the sorting is wrong after canceling the administrator in group settings [#3185](https://github.com/openimsdk/open-im-server/pull/3185) +* fix: solve uncorrect GroupMember enter group notification type. [#3188](https://github.com/openimsdk/open-im-server/pull/3188) +* fix: solve unocrrect invite notification [#3213](https://github.com/openimsdk/open-im-server/pull/3213) +* fix: AdminToken save to redis && limit 1 for each userID [#3224](https://github.com/openimsdk/open-im-server/pull/3224) +* fix: improve stress test tools parms. [#3265](https://github.com/openimsdk/open-im-server/pull/3265) +* fix: oss specifies content-type when uploading [#3267](https://github.com/openimsdk/open-im-server/pull/3267) +* fix: transferring the group owner to a muted member, incremental version error [#3284](https://github.com/openimsdk/open-im-server/pull/3284) +* fix: group status in GroupDismissedNotification [#3286](https://github.com/openimsdk/open-im-server/pull/3286) +* fix: data version SetVersion will add record [#3304](https://github.com/openimsdk/open-im-server/pull/3304) +* fix: delete token [#3313](https://github.com/openimsdk/open-im-server/pull/3313) +* fix: optimize grpc option and fix some interface permission checks [#3327](https://github.com/openimsdk/open-im-server/pull/3327) +* fix: standalone mode cannot be used [#3360](https://github.com/openimsdk/open-im-server/pull/3360) +* fix: solve user not found when notification invitedUserID is zero in … [#3375](https://github.com/openimsdk/open-im-server/pull/3375) +* fix: send simple msg [#3362](https://github.com/openimsdk/open-im-server/pull/3362) +* fix: solve updateUserInfoEx null pointer. [#3326](https://github.com/openimsdk/open-im-server/pull/3326) +* fix: add rpc interface permission check [#3377](https://github.com/openimsdk/open-im-server/pull/3377) +* fix: optimize friend and group applications [#3389](https://github.com/openimsdk/open-im-server/pull/3389) +* fix redis config db field [#3395](https://github.com/openimsdk/open-im-server/pull/3395) +* fix: prometheus discovery [#3408](https://github.com/openimsdk/open-im-server/pull/3408) +* fix: import friends send notification [#3420](https://github.com/openimsdk/open-im-server/pull/3420) +* fix: improve mileston PR workflows contents. [#3382](https://github.com/openimsdk/open-im-server/pull/3382) +* fix: solve webhook incorrect attentionID references. [#3411](https://github.com/openimsdk/open-im-server/pull/3411) +* fix: solve `createTime` not set in setConversation and Create Conversation. [#3447](https://github.com/openimsdk/open-im-server/pull/3447) +* fix: update log level in crontask dist look. [#3440](https://github.com/openimsdk/open-im-server/pull/3440) +* fix: use safe submodule init in workflows. [#3468](https://github.com/openimsdk/open-im-server/pull/3468) +* fix: fix incorrect kicked logic. [#3480](https://github.com/openimsdk/open-im-server/pull/3480) +* fix: added AtUserIDList to the @ message for API sending. [#3472](https://github.com/openimsdk/open-im-server/pull/3472) +* fix: solve batch incorrect error in Find DocIDs [#3476](https://github.com/openimsdk/open-im-server/pull/3476) +* fix: correctly aggregate read seqs [#3442](https://github.com/openimsdk/open-im-server/pull/3442) +* fix: performance issues with Kafka caused [#3485](https://github.com/openimsdk/open-im-server/pull/3485) +* fix: searchMessage method has potential NPE bug [Created [#3289](https://github.com/openimsdk/open-im-server/pull/3289) +* fix: admin token in standalone mode [#3499](https://github.com/openimsdk/open-im-server/pull/3499) +* fix: revert contentType in API msg [#3509](https://github.com/openimsdk/open-im-server/pull/3509) +* fix: optimize to lru local cache. [#3514](https://github.com/openimsdk/open-im-server/pull/3514) +* fix: fill in the most recent sendTime for a gap message to prevent th… [#3522](https://github.com/openimsdk/open-im-server/pull/3522) +* fix: solve incorrect batchGetIncrGroupMember when group dismissed. [#3526](https://github.com/openimsdk/open-im-server/pull/3526) +* fix: GetSortedConversationList nil pointer when chatlog not found. [#3531](https://github.com/openimsdk/open-im-server/pull/3531) +* fix: switch kafka & etcd image namespace to bitnamilegacy [#3555](https://github.com/openimsdk/open-im-server/pull/3555) +* fix: solve incorrect time.Unix and logger asyncwrite [#3584](https://github.com/openimsdk/open-im-server/pull/3584) +* fix: db manager [#3600](https://github.com/openimsdk/open-im-server/pull/3600) +* fix: update JSON field names to camelCase in conversation structs [#3609](https://github.com/openimsdk/open-im-server/pull/3609) +* Fix: Resolved the issue of incorrect generation of conversationID [#3581](https://github.com/openimsdk/open-im-server/pull/3581) +* fix: solve msg wsHandler panic. [#3595](https://github.com/openimsdk/open-im-server/pull/3595) +* fix: resolve deadlock in cache eviction and improve GetBatch implementation and full id version [#3591](https://github.com/openimsdk/open-im-server/pull/3591) +* fix: reset user conversation seq when rejoining group to resolve message recall issue [#3640](https://github.com/openimsdk/open-im-server/pull/3640) +* fix(group): move member count retrieval after member deletion for accurate updates [#3651](https://github.com/openimsdk/open-im-server/pull/3651) +* fix(group): set max_seq to 0 when join group [#3649](https://github.com/openimsdk/open-im-server/pull/3649) +* fix: Mongo Malloc upsert overwrites min_seq initialization [#3657](https://github.com/openimsdk/open-im-server/pull/3657) + +### Chores +* chore: remove unused content [#2786](https://github.com/openimsdk/open-im-server/pull/2786) +* chore: update admin front image version [#2893](https://github.com/openimsdk/open-im-server/pull/2893) + +### Refactors +* refactor: Refactor rpc call && auto gen rpc_call code [#2969](https://github.com/openimsdk/open-im-server/pull/2969) +* refactor: improve workflows logic. [#3072](https://github.com/openimsdk/open-im-server/pull/3072) +* refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. [#3173](https://github.com/openimsdk/open-im-server/pull/3173) +* refactor: improve setConversations method. [#3194](https://github.com/openimsdk/open-im-server/pull/3194) +* refactor: move stress-test tools location. [#3295](https://github.com/openimsdk/open-im-server/pull/3295) +* refactor: support modified config and args in mage. [#3466](https://github.com/openimsdk/open-im-server/pull/3466) + +### Builds +* build: improve workflows logic. [#2801](https://github.com/openimsdk/open-im-server/pull/2801) +* build: implement version file update when release. [#2826](https://github.com/openimsdk/open-im-server/pull/2826) +* build: update mongo and kafka start logic. [#2858](https://github.com/openimsdk/open-im-server/pull/2858) +* build: create changelog tool and workflows. [#2869](https://github.com/openimsdk/open-im-server/pull/2869) +* build(deps): bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 [#2851](https://github.com/openimsdk/open-im-server/pull/2851) +* build: update Server version. [#2887](https://github.com/openimsdk/open-im-server/pull/2887) +* build: implement services image build and CI release. [#2920](https://github.com/openimsdk/open-im-server/pull/2920) +* build: update kubernetes deployment Run. [#2919](https://github.com/openimsdk/open-im-server/pull/2919) +* build: fix uncorrect path. [#3020](https://github.com/openimsdk/open-im-server/pull/3020) +* build: fix docker images build. [#3024](https://github.com/openimsdk/open-im-server/pull/3024) +* build: keep conflict is true. [#3103](https://github.com/openimsdk/open-im-server/pull/3103) +* build: comment out admin services. [#3537](https://github.com/openimsdk/open-im-server/pull/3537) +* build: improve publish docker image workflow. [#3552](https://github.com/openimsdk/open-im-server/pull/3552) +* build: add sdk version log in registerClient [#3574](https://github.com/openimsdk/open-im-server/pull/3574) + +### Others +* Revert: Change group member roleLevel can`t send notification [#2789](https://github.com/openimsdk/open-im-server/pull/2789) +* Introducing OpenIM Guru on Gurubase.io [#2788](https://github.com/openimsdk/open-im-server/pull/2788) +* revert: write msg to redis [#2883](https://github.com/openimsdk/open-im-server/pull/2883) +* Add a lead time for the token's issuance time. [#2914](https://github.com/openimsdk/open-im-server/pull/2914) +* docs: improve deployment docs in kubernetes. [#2973](https://github.com/openimsdk/open-im-server/pull/2973) +* update: env image version [#3055](https://github.com/openimsdk/open-im-server/pull/3055) +* License [#3293](https://github.com/openimsdk/open-im-server/pull/3293) +* docs: update slack link. [#3479](https://github.com/openimsdk/open-im-server/pull/3479) +* Update CHANGELOG for release v3.8.3-patch.1 [#3164](https://github.com/openimsdk/open-im-server/pull/3164) +* Update CHANGELOG for release v3.8.3-patch.2 [#3175](https://github.com/openimsdk/open-im-server/pull/3175) +* Update CHANGELOG for release v3.8.3-patch.3 [#3206](https://github.com/openimsdk/open-im-server/pull/3206) +* Update CHANGELOG for release v3.8.3-patch.4 [#3226](https://github.com/openimsdk/open-im-server/pull/3226) +* Update CHANGELOG for release v3.8.3-patch.5 [#3405](https://github.com/openimsdk/open-im-server/pull/3405) +* Update CHANGELOG for release v3.8.3-patch.6 [#3473](https://github.com/openimsdk/open-im-server/pull/3473) +* docs: update readme of config file. [#3356](https://github.com/openimsdk/open-im-server/pull/3356) +* ​Build: Implement rate limiting and circuit breaker for API and RPC services.​​ [#3572](https://github.com/openimsdk/open-im-server/pull/3572) +* merge: pre-release-v3.8.4 [#3623](https://github.com/openimsdk/open-im-server/pull/3623) +* Simplify iOS background push gating (#3611) [#3612](https://github.com/openimsdk/open-im-server/pull/3612) +* bugfix(conversation):removed unexpectedly called functions and itself… [#3668](https://github.com/openimsdk/open-im-server/pull/3668) +* @lkzz made their first contribution in https://github.com/openimsdk/open-im-server/pull/2724 [#2724](https://github.com/openimsdk/open-im-server/pull/2724) +* @alilestera made their first contribution in https://github.com/openimsdk/open-im-server/pull/2773 [#2773](https://github.com/openimsdk/open-im-server/pull/2773) +* @kursataktas made their first contribution in https://github.com/openimsdk/open-im-server/pull/2788 [#2788](https://github.com/openimsdk/open-im-server/pull/2788) +* @yoyo930021 made their first contribution in https://github.com/openimsdk/open-im-server/pull/2844 [#2844](https://github.com/openimsdk/open-im-server/pull/2844) +* @wikylyu made their first contribution in https://github.com/openimsdk/open-im-server/pull/2861 [#2861](https://github.com/openimsdk/open-im-server/pull/2861) +* @storyn26383 made their first contribution in https://github.com/openimsdk/open-im-server/pull/2862 [#2862](https://github.com/openimsdk/open-im-server/pull/2862) +* @morya made their first contribution in https://github.com/openimsdk/open-im-server/pull/2881 [#2881](https://github.com/openimsdk/open-im-server/pull/2881) +* @HonQii made their first contribution in https://github.com/openimsdk/open-im-server/pull/3395 [#3395](https://github.com/openimsdk/open-im-server/pull/3395) +* @github-actions[bot] made their first contribution in https://github.com/openimsdk/open-im-server/pull/3164 [#3164](https://github.com/openimsdk/open-im-server/pull/3164) +* @xuzhijvn made their first contribution in https://github.com/openimsdk/open-im-server/pull/3289 [#3289](https://github.com/openimsdk/open-im-server/pull/3289) +* @ozudev made their first contribution in https://github.com/openimsdk/open-im-server/pull/3612 [#3612](https://github.com/openimsdk/open-im-server/pull/3612) + +**Full Changelog**: [v3.8.3-patch.15...v3.8.3-patch.16](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.15...v3.8.3-patch.16) + ## [v3.8.3-patch.12](https://github.com/openimsdk/open-im-server/releases/tag/v3.8.3-patch.12) (2025-10-24) ### Bug Fixes @@ -34,4 +282,4 @@ * fix: import friends send notification in v3.8.3-patch [#3488](https://github.com/openimsdk/open-im-server/pull/3488) * fix: solve redis config db field in v3.8.3-patch [#3490](https://github.com/openimsdk/open-im-server/pull/3490) -**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7) \ No newline at end of file +**Full Changelog**: [v3.8.3-patch.6...v3.8.3-patch.7](https://github.com/openimsdk/open-im-server/compare/v3.8.3-patch.6...v3.8.3-patch.7) From 7aab6a8e167ddf516cd13ee045a6c51b9c290bfd Mon Sep 17 00:00:00 2001 From: WangZhonghui Date: Fri, 26 Jun 2026 17:46:48 +0800 Subject: [PATCH 28/41] fix: get online users (#3461) get online users fail --- pkg/common/cmd/api.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/common/cmd/api.go b/pkg/common/cmd/api.go index 1356f90d6..8ffce5177 100644 --- a/pkg/common/cmd/api.go +++ b/pkg/common/cmd/api.go @@ -92,7 +92,9 @@ func (a *ApiCmd) runE() error { &a.apiConfig.Notification, a.apiConfig, []string{}, - []string{}, + []string{ + a.apiConfig.Discovery.RpcService.MessageGateway, + }, api.Start, ) } From 7848d7c7354945fe7b40f6b990db8b6013a9037c Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:37:22 +0800 Subject: [PATCH 29/41] refactor(changelog): modernize generator and workflows (#3753) * refactor(changelog): modernize generator and workflows * test(core): use stable Go in build test workflow * refactor(core): use golang alpine base image * fix(build): limit docker compose parallelism * refactor(build): inline compose build logic * fix(core): reorder Dockerfile ARG declarations --- .github/workflows/auto-assign-issue.yml | 10 +-- .github/workflows/auto-invite-comment.yml | 2 +- .github/workflows/changelog.yml | 9 ++- .github/workflows/cla-assistant.yml | 2 +- .../cleanup-after-milestone-prs-merged.yml | 12 ++-- .github/workflows/codeql-analysis.yml | 8 +-- .github/workflows/comment-check.yml | 2 +- ...cker-build-and-release-services-images.yml | 12 ++-- .github/workflows/go-build-test.yml | 24 +++---- .github/workflows/help-comment-issue.yml | 2 +- .github/workflows/merge-from-milestone.yml | 2 +- .github/workflows/publish-docker-image.yml | 17 +++-- .github/workflows/remove-unused-labels.yml | 8 +-- .github/workflows/reopen-issue.yml | 8 +-- .../update-version-file-on-release.yml | 4 +- .github/workflows/user-first-interaction.yml | 10 +-- Dockerfile | 2 +- build/build.sh | 16 ++--- build/images/openim-server/Dockerfile | 10 +-- .../docker-compose.build.override.yml | 72 ------------------- tools/changelog/changelog.go | 41 ++++++++--- 21 files changed, 111 insertions(+), 162 deletions(-) delete mode 100644 build/images/openim-server/docker-compose.build.override.yml diff --git a/.github/workflows/auto-assign-issue.yml b/.github/workflows/auto-assign-issue.yml index 320174d8c..875432a46 100644 --- a/.github/workflows/auto-assign-issue.yml +++ b/.github/workflows/auto-assign-issue.yml @@ -5,23 +5,23 @@ on: jobs: assign-issue: if: | - contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept') && + (contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept')) && !contains(github.event.comment.user.login, 'openim-robot') runs-on: ubuntu-latest permissions: issues: write steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Assign the issue run: | - export LETASE_MILESTONES=$(curl 'https://api.github.com/repos/$OWNER/$PEPO/milestones' | jq -r 'last(.[]).title') + export LATEST_MILESTONE=$(curl "https://api.github.com/repos/$OWNER/$REPO/milestones" | jq -r 'last(.[]).title') gh issue edit ${{ github.event.issue.number }} --add-assignee "${{ github.event.comment.user.login }}" gh issue edit ${{ github.event.issue.number }} --add-label "accepted" - gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you. I set the milestones for this issue to [$LETASE_MILESTONES](https://github.com/$OWNER/$PEPO/milestones), We are looking forward to your PR!" + gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you. I set the milestones for this issue to [$LATEST_MILESTONE](https://github.com/$OWNER/$REPO/milestones), We are looking forward to your PR!" - # gh issue edit ${{ github.event.issue.number }} --milestone "$LETASE_MILESTONES" + # gh issue edit ${{ github.event.issue.number }} --milestone "$LATEST_MILESTONE" env: GH_TOKEN: ${{ secrets.BOT_TOKEN }} ISSUE: ${{ github.event.issue.html_url }} diff --git a/.github/workflows/auto-invite-comment.yml b/.github/workflows/auto-invite-comment.yml index dde36eaf1..a4b1f1bf0 100644 --- a/.github/workflows/auto-invite-comment.yml +++ b/.github/workflows/auto-invite-comment.yml @@ -12,7 +12,7 @@ jobs: issues: write steps: - name: Invite user to join OpenIM Community - uses: peter-evans/create-or-update-comment@v4 + uses: peter-evans/create-or-update-comment@v5.0.0 with: token: ${{ secrets.BOT_GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index b97036d91..09584ffa1 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -13,7 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 + + - name: Set up Go + uses: actions/setup-go@v6.5.0 + with: + go-version-file: go.mod - name: Run Go Changelog Generator run: | @@ -66,7 +71,7 @@ jobs: rm -f "${{ github.event.release.tag_name }}-changelog.md" - name: Create Pull Request - uses: peter-evans/create-pull-request@v7.0.5 + uses: peter-evans/create-pull-request@v8.1.1 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Update CHANGELOG for release ${{ github.event.release.tag_name }}" diff --git a/.github/workflows/cla-assistant.yml b/.github/workflows/cla-assistant.yml index 7d44b05eb..88c16c8c7 100644 --- a/.github/workflows/cla-assistant.yml +++ b/.github/workflows/cla-assistant.yml @@ -18,7 +18,7 @@ jobs: steps: - name: "CLA Assistant" if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - uses: contributor-assistant/github-action@v2.4.0 + uses: contributor-assistant/github-action@v2.6.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PERSONAL_ACCESS_TOKEN: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/cleanup-after-milestone-prs-merged.yml b/.github/workflows/cleanup-after-milestone-prs-merged.yml index 8a3e381d6..8d7868de4 100644 --- a/.github/workflows/cleanup-after-milestone-prs-merged.yml +++ b/.github/workflows/cleanup-after-milestone-prs-merged.yml @@ -11,14 +11,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4.2.0 + uses: actions/checkout@v7.0.0 - name: Get the PR title and extract PR numbers id: extract_pr_numbers + env: + PR_TITLE: ${{ github.event.pull_request.title }} run: | - # Get the PR title - PR_TITLE="${{ github.event.pull_request.title }}" - echo "PR Title: $PR_TITLE" # Extract PR numbers from the title @@ -57,9 +56,8 @@ jobs: - name: Delete branch after PR close if: steps.extract_pr_numbers.outputs.proceed == 'true' || contains(github.event.pull_request.labels.*.name, 'milestone-merge') + env: + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} run: | - BRANCH_NAME="${{ github.event.pull_request.head.ref }}" echo "Branch to delete: $BRANCH_NAME" git push origin --delete "$BRANCH_NAME" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fd871e2b5..340d23614 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,11 +35,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@v4.36.2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,7 +50,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@v4.36.2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -64,4 +64,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 \ No newline at end of file + uses: github/codeql-action/analyze@v4.36.2 diff --git a/.github/workflows/comment-check.yml b/.github/workflows/comment-check.yml index e994b5259..ec4a1e3ac 100644 --- a/.github/workflows/comment-check.yml +++ b/.github/workflows/comment-check.yml @@ -17,7 +17,7 @@ jobs: EXCLUDE_FILES: "*.md *.txt *.html *.css *.min.js *.mdx" steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7.0.0 - name: Search for Non-English comments run: | diff --git a/.github/workflows/docker-build-and-release-services-images.yml b/.github/workflows/docker-build-and-release-services-images.yml index 1d085e153..941f83cfa 100644 --- a/.github/workflows/docker-build-and-release-services-images.yml +++ b/.github/workflows/docker-build-and-release-services-images.yml @@ -22,29 +22,29 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Set up QEMU - uses: docker/setup-qemu-action@v3.3.0 + uses: docker/setup-qemu-action@v4.1.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.8.0 + uses: docker/setup-buildx-action@v4.1.0 - name: Log in to Docker Hub - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Aliyun Container Registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: registry: registry.cn-hangzhou.aliyuncs.com username: ${{ secrets.ALIREGISTRY_USERNAME }} diff --git a/.github/workflows/go-build-test.yml b/.github/workflows/go-build-test.yml index 8425293e9..98995ecce 100644 --- a/.github/workflows/go-build-test.yml +++ b/.github/workflows/go-build-test.yml @@ -22,14 +22,14 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go_version: ["1.25.x"] + go_version: ["stable"] steps: - name: Checkout Server repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Set up Go ${{ matrix.go_version }} - uses: actions/setup-go@v5 + uses: actions/setup-go@v6.5.0 with: go-version: ${{ matrix.go_version }} @@ -40,7 +40,7 @@ jobs: go mod download - name: Set up infra services - uses: hoverkraft-tech/compose-action@v2.0.1 + uses: hoverkraft-tech/compose-action@v3.0.0 with: compose-file: "./docker-compose.yml" @@ -67,7 +67,7 @@ jobs: mage check - name: Checkout Chat repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: repository: "openimsdk/chat" path: "chat-repo" @@ -188,21 +188,21 @@ jobs: strategy: matrix: os: [ubuntu-latest] - go_version: ["1.25.x"] + go_version: ["stable"] steps: - name: Checkout Server repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Checkout SDK repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: repository: "openimsdk/openim-sdk-core" ref: "main" path: ${{ env.SDK_DIR }} - name: Set up Go ${{ matrix.go_version }} - uses: actions/setup-go@v5 + uses: actions/setup-go@v6.5.0 with: go-version: ${{ matrix.go_version }} @@ -237,14 +237,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: ["1.25.x"] + go_version: ["stable"] steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Set up Go ${{ matrix.go_version }} - uses: actions/setup-go@v5 + uses: actions/setup-go@v6.5.0 with: go-version: ${{ matrix.go_version }} diff --git a/.github/workflows/help-comment-issue.yml b/.github/workflows/help-comment-issue.yml index ce8f12b3b..b7f9b5afc 100644 --- a/.github/workflows/help-comment-issue.yml +++ b/.github/workflows/help-comment-issue.yml @@ -26,7 +26,7 @@ jobs: issues: write steps: - name: Add comment - uses: peter-evans/create-or-update-comment@v4 + uses: peter-evans/create-or-update-comment@v5.0.0 with: issue-number: ${{ github.event.issue.number }} token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/merge-from-milestone.yml b/.github/workflows/merge-from-milestone.yml index a0ec2ac16..23dcf6d16 100644 --- a/.github/workflows/merge-from-milestone.yml +++ b/.github/workflows/merge-from-milestone.yml @@ -40,7 +40,7 @@ jobs: touch ${{ env.TEMP_DIR }}/created_pr_number.txt - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: fetch-depth: 0 token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 4cd3316dd..db4c1976b 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -14,7 +14,6 @@ on: default: "v3.8.3" env: - GO_VERSION: "1.22" IMAGE_NAME: "openim-server" # IMAGE_NAME: ${{ github.event.repository.name }} DOCKER_BUILDKIT: 1 @@ -25,22 +24,22 @@ jobs: if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }} steps: - name: Checkout main repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: path: main-repo - name: Set up QEMU - uses: docker/setup-qemu-action@v3.3.0 + uses: docker/setup-qemu-action@v4.1.0 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4.1.0 with: driver-opts: network=host - name: Extract metadata for Docker id: meta - uses: docker/metadata-action@v5.6.0 + uses: docker/metadata-action@v6.1.0 with: images: | ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} @@ -80,7 +79,7 @@ jobs: docker image ls | grep openim - name: Checkout compose repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: repository: "openimsdk/openim-docker" path: "compose-repo" @@ -134,20 +133,20 @@ jobs: # fi - name: Log in to Docker Hub - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Aliyun Container Registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v4.2.0 with: registry: registry.cn-hangzhou.aliyuncs.com username: ${{ secrets.ALIREGISTRY_USERNAME }} diff --git a/.github/workflows/remove-unused-labels.yml b/.github/workflows/remove-unused-labels.yml index ab80b1f96..dd75c0cdf 100644 --- a/.github/workflows/remove-unused-labels.yml +++ b/.github/workflows/remove-unused-labels.yml @@ -11,11 +11,11 @@ jobs: contents: read steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Fetch All Issues and PRs id: fetch_issues_prs - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -38,7 +38,7 @@ jobs: - name: Fetch All Labels id: fetch_labels - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -52,7 +52,7 @@ jobs: result-encoding: string - name: Remove Unused Labels - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/reopen-issue.yml b/.github/workflows/reopen-issue.yml index 32f838ba4..345f09c87 100644 --- a/.github/workflows/reopen-issue.yml +++ b/.github/workflows/reopen-issue.yml @@ -12,11 +12,11 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 - name: Fetch Closed Issues with lifecycle/stale Label id: fetch_issues - uses: actions/github-script@v7 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -40,7 +40,7 @@ jobs: echo "Issue numbers: ${{ steps.fetch_issues.outputs.result }}" - name: Reopen Issues - uses: actions/github-script@v7 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -59,7 +59,7 @@ jobs: } - name: Remove lifecycle/stale Label - uses: actions/github-script@v7 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/update-version-file-on-release.yml b/.github/workflows/update-version-file-on-release.yml index 039ff3d4b..4cad8f55d 100644 --- a/.github/workflows/update-version-file-on-release.yml +++ b/.github/workflows/update-version-file-on-release.yml @@ -12,7 +12,7 @@ jobs: steps: # Step 1: Checkout the original repository's code - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7.0.0 with: fetch-depth: 0 # submodules: "recursive" @@ -73,7 +73,7 @@ jobs: # Step 7: Find and Publish Draft Release - name: Find and Publish Draft Release - uses: actions/github-script@v7 + uses: actions/github-script@v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/user-first-interaction.yml b/.github/workflows/user-first-interaction.yml index 4271702a6..97533a151 100644 --- a/.github/workflows/user-first-interaction.yml +++ b/.github/workflows/user-first-interaction.yml @@ -11,11 +11,11 @@ jobs: check_for_first_interaction: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/first-interaction@v1.3.0 + - uses: actions/checkout@v7.0.0 + - uses: actions/first-interaction@v3.1.0 with: - repo-token: ${{ secrets.BOT_TOKEN }} - pr-message: | + repo_token: ${{ secrets.BOT_TOKEN }} + pr_message: | Hello! Thank you for your contribution. If you are fixing a bug, please reference the issue number in the description. @@ -26,7 +26,7 @@ jobs: Please leave your information in the [✨ discussions](https://github.com/orgs/OpenIMSDK/discussions/426), we expect anyone to join OpenIM developer community. - issue-message: | + issue_message: | Hello! Thank you for filing an issue. If this is a bug report, please include relevant logs to help us debug the problem. diff --git a/Dockerfile b/Dockerfile index 30af8f7ee..c1fceefb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.25-alpine AS builder +FROM golang:alpine AS builder ARG RELEASE=false ARG COMPRESS=false diff --git a/build/build.sh b/build/build.sh index 354cd3945..e61b228a3 100755 --- a/build/build.sh +++ b/build/build.sh @@ -24,19 +24,13 @@ fi cd "$BASE_DIR/.." || exit 1 split_values() { - printf '%s\n' "$1" | tr ', ' '\n\n' | while IFS= read -r value; do - [[ -n "$value" ]] && printf '%s\n' "$value" - done -} - -print_command() { - printf '%q ' "$@" - printf '\n' + echo "$1" | grep -o '[^, ]\+' } run_or_print() { if [[ "$DRY_RUN" == "true" ]]; then - print_command "$@" + printf '%q ' "$@" + printf '\n' else "$@" fi @@ -44,7 +38,9 @@ run_or_print() { build_local() { echo -e "${CYAN}Building all services...${NO_COLOR}" - RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build + while IFS= read -r service; do + RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build "$service" + done < <(docker compose -f "$COMPOSE_FILE" config --services) echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}" while IFS= read -r built_image; do diff --git a/build/images/openim-server/Dockerfile b/build/images/openim-server/Dockerfile index e821260a6..6adecf484 100644 --- a/build/images/openim-server/Dockerfile +++ b/build/images/openim-server/Dockerfile @@ -1,8 +1,4 @@ -FROM golang:1.25-alpine AS builder - -ARG CMD_PATH -ARG BINARY_NAME -ARG RELEASE=false +FROM golang:alpine AS builder ENV SERVER_DIR=/openim-server WORKDIR $SERVER_DIR @@ -10,6 +6,10 @@ WORKDIR $SERVER_DIR COPY . . RUN go mod tidy +ARG CMD_PATH +ARG BINARY_NAME +ARG RELEASE=false + RUN if [ "$RELEASE" = "true" ]; then \ go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \ else \ diff --git a/build/images/openim-server/docker-compose.build.override.yml b/build/images/openim-server/docker-compose.build.override.yml deleted file mode 100644 index 7ef19f988..000000000 --- a/build/images/openim-server/docker-compose.build.override.yml +++ /dev/null @@ -1,72 +0,0 @@ -services: - openim-api: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-crontask: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-msggateway: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-msgtransfer: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-push: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-auth: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-conversation: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-friend: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-group: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-msg: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-third: - build: - platforms: - - linux/amd64 - - linux/arm64 - - openim-rpc-user: - build: - platforms: - - linux/amd64 - - linux/arm64 diff --git a/tools/changelog/changelog.go b/tools/changelog/changelog.go index 75d914a27..b76dc6e1d 100644 --- a/tools/changelog/changelog.go +++ b/tools/changelog/changelog.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "errors" "fmt" "io" "net/http" @@ -35,6 +36,10 @@ type ReleaseData struct { Published string `json:"published_at"` } +type GitHubError struct { + Message string `json:"message"` +} + // Method to classify and format release notes. func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string { result := map[string][]string{ @@ -49,10 +54,7 @@ func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string { // Regular expression to extract PR number and URL (case insensitive) rePR := regexp.MustCompile(`(?i)in (https://github\.com/[^\s]+/pull/(\d+))`) - // Split the body into individual lines. - lines := strings.Split(body, "\n") - - for _, line := range lines { + for line := range strings.SplitSeq(body, "\n") { // Skip lines that contain "deps: Merge" if strings.Contains(strings.ToLower(line), "deps: merge #") { continue @@ -108,7 +110,17 @@ func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string { } // Method to generate the final changelog. -func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) string { +func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) (string, error) { + if tag == "" { + return "", errors.New("release tag is empty") + } + if len(date) < 10 { + return "", fmt.Errorf("release published_at is invalid: %q", date) + } + if htmlURL == "" { + return "", errors.New("release html_url is empty") + } + sections := g.classifyReleaseNotes(body) // Convert ISO 8601 date to simpler format (YYYY-MM-DD) @@ -140,7 +152,7 @@ func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) string { changelog += fmt.Sprintf("**Full Changelog**: %s\n", g.FullChangelog) } - return changelog + return changelog, nil } // Method to fetch release data from GitHub API. @@ -165,6 +177,13 @@ func (g *GitHubRepo) fetchReleaseData(version string) (*ReleaseData, error) { if err != nil { return nil, err } + if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { + var githubError GitHubError + if err := json.Unmarshal(body, &githubError); err == nil && githubError.Message != "" { + return nil, fmt.Errorf("github api returned %s: %s", resp.Status, githubError.Message) + } + return nil, fmt.Errorf("github api returned %s", resp.Status) + } var releaseData ReleaseData err = json.Unmarshal(body, &releaseData) @@ -188,11 +207,15 @@ func main() { // Fetch release data (either for latest or specific version) releaseData, err := repo.fetchReleaseData(version) if err != nil { - fmt.Println("Error fetching release data:", err) - return + fmt.Fprintln(os.Stderr, "Error fetching release data:", err) + os.Exit(1) } // Generate and print the formatted changelog - changelog := repo.generateChangelog(releaseData.TagName, releaseData.Published, releaseData.HtmlUrl, releaseData.Body) + changelog, err := repo.generateChangelog(releaseData.TagName, releaseData.Published, releaseData.HtmlUrl, releaseData.Body) + if err != nil { + fmt.Fprintln(os.Stderr, "Error generating changelog:", err) + os.Exit(1) + } fmt.Println(changelog) } From 10a577c3107ac19fd9e9aaed8c82887ba65e4bdb Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Fri, 3 Jul 2026 18:28:06 +0800 Subject: [PATCH 30/41] feat: Supports launching multiple monolithic instances, load-balanced by nginx, requiring only MongoDB and Redis at a minimum (#3759) * fix: performance issues with Kafka caused by encapsulating the MQ interface * fix: admin token in standalone mode * fix: full id version * fix: resolve deadlock in cache eviction and improve GetBatch implementation * refactor: replace LongConn with ClientConn interface and simplify message handling * refactor: replace LongConn with ClientConn interface and simplify message handling * fix: seq use $setOnInsert for min_seq in conversation update * feat: add error code for handled friend requests and improve error handling in friend operations * refactor(msg): update regex pattern for conversationID to include a trailing colon * refactor: streamline cache initialization and enhance queue engine configuration * refactor: streamline cache initialization and enhance queue engine configuration * feat: add RegisterIP to API config and implement Redis server registration * feat(redis): implement standalone gateway registration with Redis * chore: update openimsdk/tools dependency to v0.0.50-alpha.121 * fix: change timer to ticker for improved periodic execution * refactor: replace Kafka topic configuration with mqbuild constants for improved readability * feat(redis): implement Redis-based locking mechanism for cron tasks --- cmd/main.go | 154 +++++++++++++--- config/openim-api.yml | 2 + config/share.yml | 8 + go.mod | 2 +- go.sum | 4 +- internal/api/init.go | 15 +- internal/api/router.go | 54 +++++- internal/msggateway/init.go | 42 +---- internal/msgtransfer/init.go | 44 ++--- internal/push/push.go | 36 ++-- internal/rpc/auth/auth.go | 24 +-- internal/rpc/msg/server.go | 29 ++- internal/rpc/third/third.go | 27 +-- internal/tools/cron/cron_task.go | 34 ++-- .../cron/{dist_look.go => etcd_locker.go} | 7 +- internal/tools/cron/locker.go | 14 ++ internal/tools/cron/redis_locker.go | 68 +++++++ pkg/common/cmd/cron_task.go | 4 +- pkg/common/config/config.go | 11 +- pkg/common/config/load_config.go | 27 ++- pkg/common/config/mq.go | 41 +++++ pkg/common/config/selector.go | 43 +++++ pkg/common/discovery/discoveryregister.go | 7 +- pkg/common/storage/cache/mcache/minio.go | 50 ------ pkg/common/storage/cache/mcache/msg_cache.go | 132 -------------- pkg/common/storage/cache/mcache/online.go | 82 --------- .../storage/cache/mcache/seq_conversation.go | 79 --------- pkg/common/storage/cache/mcache/third.go | 98 ----------- pkg/common/storage/cache/mcache/token.go | 166 ------------------ pkg/common/storage/cache/mcache/tools.go | 63 ------- pkg/common/storage/cache/redis/online.go | 8 +- .../storage/cache/redis/seq_conversation.go | 7 +- .../storage/cache/redis/standalone_gateway.go | 54 ++++++ .../cache/redis/standalone_gateway_test.go | 52 ++++++ pkg/mqbuild/builder.go | 143 +++++++++++++-- 35 files changed, 703 insertions(+), 928 deletions(-) rename internal/tools/cron/{dist_look.go => etcd_locker.go} (97%) create mode 100644 internal/tools/cron/locker.go create mode 100644 internal/tools/cron/redis_locker.go create mode 100644 pkg/common/config/mq.go create mode 100644 pkg/common/config/selector.go delete mode 100644 pkg/common/storage/cache/mcache/minio.go delete mode 100644 pkg/common/storage/cache/mcache/msg_cache.go delete mode 100644 pkg/common/storage/cache/mcache/online.go delete mode 100644 pkg/common/storage/cache/mcache/seq_conversation.go delete mode 100644 pkg/common/storage/cache/mcache/third.go delete mode 100644 pkg/common/storage/cache/mcache/token.go delete mode 100644 pkg/common/storage/cache/mcache/tools.go create mode 100644 pkg/common/storage/cache/redis/standalone_gateway.go create mode 100644 pkg/common/storage/cache/redis/standalone_gateway_test.go diff --git a/cmd/main.go b/cmd/main.go index 7e19f1c98..7b0a7a42f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -3,6 +3,7 @@ package main import ( "bytes" "context" + "errors" "flag" "fmt" "net" @@ -12,12 +13,15 @@ import ( "path/filepath" "reflect" "runtime" + "strconv" "strings" "sync" "syscall" "time" - "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/internal/api" "github.com/openimsdk/open-im-server/v3/internal/msggateway" "github.com/openimsdk/open-im-server/v3/internal/msgtransfer" @@ -30,33 +34,40 @@ import ( "github.com/openimsdk/open-im-server/v3/internal/rpc/third" "github.com/openimsdk/open-im-server/v3/internal/rpc/user" "github.com/openimsdk/open-im-server/v3/internal/tools/cron" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics" + "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" + "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/version" "github.com/openimsdk/tools/discovery" - "github.com/openimsdk/tools/discovery/standalone" + "github.com/openimsdk/tools/discovery/inprocess" "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/system/program" "github.com/openimsdk/tools/utils/datautil" - "github.com/spf13/viper" - "google.golang.org/grpc" + "github.com/openimsdk/tools/utils/network" ) func init() { config.SetStandalone() prommetrics.RegistryAll() + inprocess.SetContextAdminFunc(authverify.IsAdmin) } func main() { - var configPath string + var ( + configPath string + index int + ) flag.StringVar(&configPath, "c", "", "config path") + flag.IntVar(&index, "i", 0, "start index") flag.Parse() if configPath == "" { _, _ = fmt.Fprintln(os.Stderr, "config path is empty") os.Exit(1) return } - cmd := newCmds(configPath) + cmd := newCmds(configPath, index) putCmd(cmd, false, auth.Start) putCmd(cmd, false, conversation.Start) putCmd(cmd, false, relation.Start) @@ -69,6 +80,7 @@ func main() { putCmd(cmd, true, msgtransfer.Start) putCmd(cmd, true, api.Start) putCmd(cmd, true, cron.Start) + putCmd(cmd, true, startRedisServerRegister) ctx := context.Background() if err := cmd.run(ctx); err != nil { _, _ = fmt.Fprintf(os.Stderr, "server exit %s", err) @@ -77,8 +89,8 @@ func main() { } } -func newCmds(confPath string) *cmds { - return &cmds{confPath: confPath} +func newCmds(confPath string, index int) *cmds { + return &cmds{confPath: confPath, index: index} } type cmdName struct { @@ -88,6 +100,7 @@ type cmdName struct { } type cmds struct { confPath string + index int cmds []cmdName config config.AllConfig conf map[string]reflect.Value @@ -116,6 +129,9 @@ func (x *cmds) initDiscovery() { func (x *cmds) initAllConfig() error { x.conf = make(map[string]reflect.Value) + if err := x.loadShareConfig(); err != nil { + return err + } vof := reflect.ValueOf(&x.config).Elem() num := vof.NumField() for i := 0; i < num; i++ { @@ -129,23 +145,17 @@ func (x *cmds) initAllConfig() error { } x.conf[x.getTypePath(field.Type())] = field val := field.Addr().Interface() - name := val.(interface{ GetConfigFileName() string }).GetConfigFileName() - confData, err := os.ReadFile(filepath.Join(x.confPath, name)) - if err != nil { - if os.IsNotExist(err) { - continue - } - return err + // Fields without a config file (e.g. Timer) are still registered above + // for parseConf distribution, but there is nothing to load for them. + fc, ok := val.(config.FileConfig) + if !ok { + continue } - v := viper.New() - v.SetConfigType("yaml") - if err := v.ReadConfig(bytes.NewReader(confData)); err != nil { - return err + name := fc.GetConfigFileName() + if name == config.ShareFileName || x.skipKafkaConfig(name) { + continue } - opt := func(conf *mapstructure.DecoderConfig) { - conf.TagName = config.StructTagName - } - if err := v.Unmarshal(val, opt); err != nil { + if err := x.loadFileConfig(name, val); err != nil { return err } } @@ -156,6 +166,31 @@ func (x *cmds) initAllConfig() error { return nil } +func (x *cmds) loadShareConfig() error { + return x.loadFileConfig(config.ShareFileName, &x.config.Share) +} + +func (x *cmds) skipKafkaConfig(name string) bool { + return name == config.KafkaConfigFileName && + config.NormalizeQueueEngine(x.config.Share.Queue.Engine) != config.QueueEngineKafka +} + +func (x *cmds) loadFileConfig(name string, val any) error { + confData, err := os.ReadFile(filepath.Join(x.confPath, name)) + if err != nil { + if os.IsNotExist(err) { + return nil + } + return err + } + v := viper.New() + v.SetConfigType(config.StructTagName) + if err := v.ReadConfig(bytes.NewReader(confData)); err != nil { + return err + } + return v.Unmarshal(val, config.ApplyDecoderConfig) +} + func (x *cmds) parseConf(conf any) error { vof := reflect.ValueOf(conf) for { @@ -178,6 +213,7 @@ func (x *cmds) parseConf(conf any) error { if !ok { switch field.Interface().(type) { case config.Index: + field.Set(reflect.ValueOf(config.Index(x.index))) case config.Path: field.SetString(x.confPath) case config.AllConfig: @@ -201,7 +237,7 @@ func (x *cmds) add(name string, block bool, fn func(ctx context.Context) error) func (x *cmds) initLog() error { conf := x.config.Log if err := log.InitLoggerFromConfig( - "openim-server", + "openim-service-log", program.GetProcessName(), "", "", conf.RemainLogLevel, @@ -339,7 +375,7 @@ func putCmd[C any](cmd *cmds, block bool, fn func(ctx context.Context, config *C if err := cmd.parseConf(&conf); err != nil { return err } - return fn(ctx, &conf, standalone.GetSvcDiscoveryRegistry(), standalone.GetServiceRegistrar()) + return fn(ctx, &conf, inprocess.GetSvcDiscoveryRegistry(), inprocess.GetServiceRegistrar()) }) } @@ -404,3 +440,71 @@ func (x *cmdManger) Running() []string { } return names } + +type serverConfig struct { + API config.API + Share config.Share + RedisConfig config.Redis + Index config.Index +} + +func startRedisServerRegister(ctx context.Context, cfg *serverConfig, client discovery.SvcDiscoveryRegistry, service grpc.ServiceRegistrar) error { + apiPort, err := datautil.GetElemByIndex(cfg.API.Api.Ports, int(cfg.Index)) + if err != nil { + return err + } + if apiPort <= 0 { + return errors.New("standalone api port is 0") + } + registerIP, err := network.GetRpcRegisterIP(cfg.API.Api.RegisterIP) + if err != nil { + return err + } + const validTime = time.Second * 10 + dbb := dbbuild.NewBuilder(nil, &cfg.RedisConfig) + rdb, err := dbb.Redis(ctx) + if err != nil { + return err + } + gateway := redis.NewStandaloneGatewayRedis(rdb, validTime) + selfAddr := net.JoinHostPort(registerIP, strconv.Itoa(apiPort)) + inprocess.SetLocalTarget(selfAddr) + inprocess.SetBroadcastAddress(cfg.Share.Secret, func(ctx context.Context) ([]string, error) { + address, err := gateway.GetGatewayAddrs(ctx) + if err != nil { + return nil, err + } + notSelf := make([]string, 0, len(address)) + for _, addr := range address { + if addr != selfAddr { + notSelf = append(notSelf, addr) + } + } + return notSelf, nil + }) + register := func() { + ctx, cancel := context.WithTimeout(ctx, validTime/2) + defer cancel() + if err := gateway.RegisterGateway(ctx, selfAddr); err != nil { + log.ZWarn(ctx, "gateway register failed", err, "address", selfAddr) + } + } + timer := time.NewTicker(validTime / 2) + defer func() { + timer.Stop() + ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), time.Second) + defer cancel() + if err := gateway.UnregisterGateway(ctx, selfAddr); err != nil { + log.ZWarn(ctx, "gateway unregister failed", err, "address", selfAddr) + } + }() + register() + for { + select { + case <-timer.C: + register() + case <-ctx.Done(): + return context.Cause(ctx) + } + } +} diff --git a/config/openim-api.yml b/config/openim-api.yml index 89be50123..a879fcb1e 100644 --- a/config/openim-api.yml +++ b/config/openim-api.yml @@ -3,6 +3,8 @@ api: listenIP: 0.0.0.0 # Listening ports; if multiple are configured, multiple instances will be launched, must be consistent with the number of prometheus.ports ports: [ 10002 ] + # Fallback for IP resolution issues in multi-instance standalone mode. + # registerIP: # API compression level; 0: default compression, 1: best compression, 2: best speed, -1: no compression compressionLevel: 0 diff --git a/config/share.yml b/config/share.yml index a42bdcdd7..df0b55be2 100644 --- a/config/share.yml +++ b/config/share.yml @@ -9,6 +9,14 @@ imAdminUser: # Each entry here corresponds by index to the matching entry in the userIDs list above. nicknames: [superAdmin] +# queue: choose message queue engine +# Supported values: +# - kafka (default) +# - redis +# - memory (standalone only; microservices cannot use memory) +queue: kafka + + # 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time multiLogin: policy: 1 diff --git a/go.mod b/go.mod index f00a6ee40..8a8dae98f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/openimsdk/protocol v0.0.73-alpha.19 - github.com/openimsdk/tools v0.0.50-alpha.117 + github.com/openimsdk/tools v0.0.50-alpha.121 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.11.1 diff --git a/go.sum b/go.sum index 0da371b9f..5d0c9e012 100644 --- a/go.sum +++ b/go.sum @@ -363,8 +363,8 @@ github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1Y github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg= github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s= github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= -github.com/openimsdk/tools v0.0.50-alpha.117 h1:ACfijEVCeBcttT7OOkNGOOOvq14pJtb9szNIMHLm6Vc= -github.com/openimsdk/tools v0.0.50-alpha.117/go.mod h1:I0WESSa7ghPIo9BL+ETlH/qEIbO6+KZioM1jwNuDwz0= +github.com/openimsdk/tools v0.0.50-alpha.121 h1:TXKKgtkeMeqIs0vpolbW8rIEngE9xlESq+0NV+FoLH0= +github.com/openimsdk/tools v0.0.50-alpha.121/go.mod h1:I0WESSa7ghPIo9BL+ETlH/qEIbO6+KZioM1jwNuDwz0= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= diff --git a/internal/api/init.go b/internal/api/init.go index f3548e29a..77011d0ad 100644 --- a/internal/api/init.go +++ b/internal/api/init.go @@ -23,13 +23,14 @@ import ( "strconv" "time" + "google.golang.org/grpc" + conf "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/network" "github.com/openimsdk/tools/utils/runtimeenv" - "google.golang.org/grpc" ) type Config struct { @@ -77,18 +78,6 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg apiCancel(err) }() - //if config.Discovery.Enable == conf.ETCD { - // cm := disetcd.NewConfigManager(client.(*etcd.SvcDiscoveryRegistryImpl).GetClient(), config.GetConfigNames()) - // cm.Watch(ctx) - //} - //sigs := make(chan os.Signal, 1) - //signal.Notify(sigs, syscall.SIGTERM) - //select { - //case val := <-sigs: - // log.ZDebug(ctx, "recv exit", "signal", val.String()) - // cancel(fmt.Errorf("signal %s", val.String())) - //case <-ctx.Done(): - //} <-apiCtx.Done() exitCause := context.Cause(apiCtx) log.ZWarn(ctx, "api server exit", exitCause) diff --git a/internal/api/router.go b/internal/api/router.go index 81787f9a9..c5f93c6c0 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -9,6 +9,8 @@ import ( "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/go-playground/validator/v10" + clientv3 "go.etcd.io/etcd/client/v3" + "github.com/openimsdk/open-im-server/v3/internal/api/jssdk" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" @@ -23,13 +25,15 @@ import ( "github.com/openimsdk/protocol/relation" "github.com/openimsdk/protocol/third" "github.com/openimsdk/protocol/user" + "github.com/openimsdk/tools/a2r" "github.com/openimsdk/tools/apiresp" "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/discovery/etcd" + "github.com/openimsdk/tools/discovery/inprocess" "github.com/openimsdk/tools/log" + "github.com/openimsdk/tools/mcontext" "github.com/openimsdk/tools/mw" "github.com/openimsdk/tools/mw/api" - clientv3 "go.etcd.io/etcd/client/v3" ) const ( @@ -341,9 +345,55 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, cf { r.POST("/restart", cm.CheckAdmin, cm.Restart) } + + if config.Standalone() { + a := internalApi{secret: cfg.Share.Secret, client: client} + r.POST(inprocess.BroadcastPath, a.RpcInvoke) + } return r, nil } +type internalApi struct { + secret string + client discovery.SvcDiscoveryRegistry +} + +func (x *internalApi) RpcInvoke(c *gin.Context) { + req, err := a2r.ParseRequestNotCheck[inprocess.InvokeRequest](c) + if err != nil { + apiresp.GinError(c, err) + return + } + // Request length is deliberately not validated: a proto request whose fields + // are all default values marshals to zero bytes. + if req.Service == "" || req.Method == "" || req.Secret == "" { + apiresp.GinError(c, servererrs.ErrArgs) + return + } + if req.Secret != x.secret { + apiresp.GinError(c, servererrs.ErrNoPermission.WrapMsg("secret not match")) + return + } + ctx := context.Context(c) + if req.OpUserID != "" { + ctx = mcontext.SetOpUserID(ctx, req.OpUserID) + } + if req.Admin { + ctx = authverify.WithTempAdmin(ctx) + } + cc, err := x.client.GetConn(ctx, req.Service) + if err != nil { + apiresp.GinError(c, err) + return + } + var resp []byte + if err := cc.Invoke(ctx, req.Method, req.Request, &resp); err != nil { + apiresp.GinError(c, err) + return + } + apiresp.GinSuccess(c, resp) +} + func GinParseToken(authClient *rpcli.AuthClient) gin.HandlerFunc { return func(c *gin.Context) { switch c.Request.Method { @@ -385,4 +435,6 @@ func setGinIsAdmin(imAdminUserID []string) gin.HandlerFunc { var Whitelist = []string{ "/auth/get_admin_token", "/auth/parse_token", + // cross-instance rpc invoke authenticates with share.secret instead of token + inprocess.BroadcastPath, } diff --git a/internal/msggateway/init.go b/internal/msggateway/init.go index 40a57b1da..59b33ad85 100644 --- a/internal/msggateway/init.go +++ b/internal/msggateway/init.go @@ -18,13 +18,14 @@ import ( "context" "time" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/rpccache" "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/runtimeenv" - "google.golang.org/grpc" "github.com/openimsdk/tools/log" ) @@ -76,42 +77,3 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis return hubServer.LongConnServer.Run(ctx) } - -// -//// Start run ws server. -//func Start(ctx context.Context, index int, conf *Config) error { -// log.CInfo(ctx, "MSG-GATEWAY server is initializing", "runtimeEnv", runtimeenv.RuntimeEnvironment(), -// "rpcPorts", conf.MsgGateway.RPC.Ports, -// "wsPort", conf.MsgGateway.LongConnSvr.Ports, "prometheusPorts", conf.MsgGateway.Prometheus.Ports) -// wsPort, err := datautil.GetElemByIndex(conf.MsgGateway.LongConnSvr.Ports, index) -// if err != nil { -// return err -// } -// -// rdb, err := redisutil.NewRedisClient(ctx, conf.RedisConfig.Build()) -// if err != nil { -// return err -// } -// longServer := NewWsServer( -// conf, -// WithPort(wsPort), -// WithMaxConnNum(int64(conf.MsgGateway.LongConnSvr.WebsocketMaxConnNum)), -// WithHandshakeTimeout(time.Duration(conf.MsgGateway.LongConnSvr.WebsocketTimeout)*time.Second), -// WithMessageMaxMsgLength(conf.MsgGateway.LongConnSvr.WebsocketMaxMsgLen), -// ) -// -// hubServer := NewServer(longServer, conf, func(srv *Server) error { -// var err error -// longServer.online, err = rpccache.NewOnlineCache(srv.userClient, nil, rdb, false, longServer.subscriberUserOnlineStatusChanges) -// return err -// }) -// -// go longServer.ChangeOnlineStatus(4) -// -// netDone := make(chan error) -// go func() { -// err = hubServer.Start(ctx, index, conf) -// netDone <- err -// }() -// return hubServer.LongConnServer.Run(netDone) -//} diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index 35026c79a..2b483fcd7 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -18,8 +18,6 @@ import ( "context" "fmt" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo" "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" @@ -28,10 +26,11 @@ import ( "github.com/openimsdk/tools/mq" "github.com/openimsdk/tools/utils/runtimeenv" + "google.golang.org/grpc" + conf "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller" "github.com/openimsdk/tools/log" - "google.golang.org/grpc" ) type MsgTransfer struct { @@ -59,8 +58,6 @@ type Config struct { } func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server grpc.ServiceRegistrar) error { - builder := mqbuild.NewBuilder(&config.KafkaConfig) - log.CInfo(ctx, "MSG-TRANSFER server is initializing", "runTimeEnv", runtimeenv.RuntimeEnvironment(), "prometheusPorts", config.MsgTransfer.Prometheus.Ports, "index", config.Index) dbb := dbbuild.NewBuilder(&config.MongodbConfig, &config.RedisConfig) @@ -72,25 +69,15 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - - //if config.Discovery.Enable == conf.ETCD { - // cm := disetcd.NewConfigManager(client.(*etcd.SvcDiscoveryRegistryImpl).GetClient(), []string{ - // config.MsgTransfer.GetConfigFileName(), - // config.RedisConfig.GetConfigFileName(), - // config.MongodbConfig.GetConfigFileName(), - // config.KafkaConfig.GetConfigFileName(), - // config.Share.GetConfigFileName(), - // config.WebhooksConfig.GetConfigFileName(), - // config.Discovery.GetConfigFileName(), - // conf.LogConfigFileName, - // }) - // cm.Watch(ctx) - //} - mongoProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToMongoTopic) + builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb) if err != nil { return err } - pushProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToPushTopic) + mongoProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToMongo) + if err != nil { + return err + } + pushProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToPush) if err != nil { return err } @@ -98,16 +85,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - var msgModel cache.MsgCache - if rdb == nil { - cm, err := mgo.NewCacheMgo(mgocli.GetDB()) - if err != nil { - return err - } - msgModel = mcache.NewMsgCache(cm, msgDocModel) - } else { - msgModel = redis.NewMsgCache(rdb, msgDocModel) - } + msgModel := redis.NewMsgCache(rdb, msgDocModel) seqConversation, err := mgo.NewSeqConversationMongo(mgocli.GetDB()) if err != nil { return err @@ -122,11 +100,11 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - historyConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToRedisTopic) + historyConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToRedis) if err != nil { return err } - historyMongoConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToMongoTopic) + historyMongoConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToMongo) if err != nil { return err } diff --git a/internal/push/push.go b/internal/push/push.go index bf95b6acc..d68708422 100644 --- a/internal/push/push.go +++ b/internal/push/push.go @@ -2,25 +2,24 @@ package push import ( "context" - "github.com/openimsdk/tools/mq" "math/rand" "strconv" + "github.com/openimsdk/tools/mq" + + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/internal/push/offlinepush" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo" "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/mqbuild" pbpush "github.com/openimsdk/protocol/push" "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/mcontext" - "google.golang.org/grpc" ) type pushServer struct { @@ -57,37 +56,26 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - var cacheModel cache.ThirdCache - if rdb == nil { - mdb, err := dbb.Mongo(ctx) - if err != nil { - return err - } - mc, err := mgo.NewCacheMgo(mdb.GetDB()) - if err != nil { - return err - } - cacheModel = mcache.NewThirdCache(mc) - } else { - cacheModel = redis.NewThirdCache(rdb) - } + cacheModel := redis.NewThirdCache(rdb) offlinePusher, err := offlinepush.NewOfflinePusher(&config.RpcConfig, cacheModel, string(config.FcmConfigPath)) if err != nil { return err } - builder := mqbuild.NewBuilder(&config.KafkaConfig) - - offlinePushProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToOfflinePushTopic) + builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb) + if err != nil { + return err + } + offlinePushProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToOfflinePush) if err != nil { return err } database := controller.NewPushDatabase(cacheModel, offlinePushProducer) - pushConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToPushTopic) + pushConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToPush) if err != nil { return err } - offlinePushConsumer, err := builder.GetTopicConsumer(ctx, config.KafkaConfig.ToOfflinePushTopic) + offlinePushConsumer, err := builder.GetTopicConsumer(ctx, mqbuild.TopicToOfflinePush) if err != nil { return err } diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index a78a714ca..c6f64deff 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -19,18 +19,18 @@ import ( "errors" "github.com/openimsdk/open-im-server/v3/pkg/common/convert" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo" "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/localcache" "github.com/openimsdk/open-im-server/v3/pkg/rpccache" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" + "github.com/redis/go-redis/v9" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" redis2 "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" "github.com/openimsdk/tools/utils/datautil" - "github.com/redis/go-redis/v9" + + "google.golang.org/grpc" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics" @@ -43,7 +43,6 @@ import ( "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/tokenverify" - "google.golang.org/grpc" ) type authServer struct { @@ -71,20 +70,7 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - var token cache.TokenModel - if rdb == nil { - mdb, err := dbb.Mongo(ctx) - if err != nil { - return err - } - mc, err := mgo.NewCacheMgo(mdb.GetDB()) - if err != nil { - return err - } - token = mcache.NewTokenCacheModel(mc, config.RpcConfig.TokenPolicy.Expire) - } else { - token = redis2.NewTokenCacheModel(rdb, &config.LocalCacheConfig, config.RpcConfig.TokenPolicy.Expire) - } + token := redis2.NewTokenCacheModel(rdb, &config.LocalCacheConfig, config.RpcConfig.TokenPolicy.Expire) userConn, err := client.GetConn(ctx, config.Discovery.RpcService.User) if err != nil { return err diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 48101cdd7..e7c589b8c 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -17,12 +17,11 @@ package msg import ( "context" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/mqbuild" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" - "google.golang.org/grpc" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" @@ -80,11 +79,6 @@ func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorF } func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryRegistry, server grpc.ServiceRegistrar) error { - builder := mqbuild.NewBuilder(&config.KafkaConfig) - redisProducer, err := builder.GetTopicProducer(ctx, config.KafkaConfig.ToRedisTopic) - if err != nil { - return err - } dbb := dbbuild.NewBuilder(&config.MongodbConfig, &config.RedisConfig) mgocli, err := dbb.Mongo(ctx) if err != nil { @@ -94,20 +88,19 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } + builder, err := mqbuild.NewBuilder(config.Share.Queue, &config.KafkaConfig, rdb) + if err != nil { + return err + } + redisProducer, err := builder.GetTopicProducer(ctx, mqbuild.TopicToRedis) + if err != nil { + return err + } msgDocModel, err := mgo.NewMsgMongo(mgocli.GetDB()) if err != nil { return err } - var msgModel cache.MsgCache - if rdb == nil { - cm, err := mgo.NewCacheMgo(mgocli.GetDB()) - if err != nil { - return err - } - msgModel = mcache.NewMsgCache(cm, msgDocModel) - } else { - msgModel = redis.NewMsgCache(rdb, msgDocModel) - } + msgModel := redis.NewMsgCache(rdb, msgDocModel) seqConversation, err := mgo.NewSeqConversationMongo(mgocli.GetDB()) if err != nil { return err diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go index cea6a8522..90a16012d 100644 --- a/internal/rpc/third/third.go +++ b/internal/rpc/third/third.go @@ -20,8 +20,6 @@ import ( "time" "github.com/openimsdk/open-im-server/v3/pkg/authverify" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" "github.com/openimsdk/tools/s3/disable" @@ -33,6 +31,8 @@ import ( "github.com/openimsdk/tools/s3/aws" "github.com/openimsdk/tools/s3/kodo" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller" "github.com/openimsdk/protocol/third" "github.com/openimsdk/tools/discovery" @@ -40,7 +40,6 @@ import ( "github.com/openimsdk/tools/s3/cos" "github.com/openimsdk/tools/s3/minio" "github.com/openimsdk/tools/s3/oss" - "google.golang.org/grpc" ) type thirdServer struct { @@ -83,30 +82,12 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg if err != nil { return err } - var thirdCache cache.ThirdCache - if rdb == nil { - tc, err := mgo.NewCacheMgo(mgocli.GetDB()) - if err != nil { - return err - } - thirdCache = mcache.NewThirdCache(tc) - } else { - thirdCache = redis.NewThirdCache(rdb) - } + thirdCache := redis.NewThirdCache(rdb) // Select the oss method according to the profile policy var o s3.Interface switch enable := config.RpcConfig.Object.Enable; enable { case "minio": - var minioCache minio.Cache - if rdb == nil { - mc, err := mgo.NewCacheMgo(mgocli.GetDB()) - if err != nil { - return err - } - minioCache = mcache.NewMinioCache(mc) - } else { - minioCache = redis.NewMinioCache(rdb) - } + minioCache := redis.NewMinioCache(rdb) o, err = minio.NewMinio(ctx, minioCache, *config.MinioConfig.Build()) case "cos": o, err = cos.NewCos(*config.RpcConfig.Object.Cos.Build()) diff --git a/internal/tools/cron/cron_task.go b/internal/tools/cron/cron_task.go index 2c8655d4a..e4644435b 100644 --- a/internal/tools/cron/cron_task.go +++ b/internal/tools/cron/cron_task.go @@ -3,8 +3,12 @@ package cron import ( "context" + "github.com/robfig/cron/v3" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" disetcd "github.com/openimsdk/open-im-server/v3/pkg/common/discovery/etcd" + "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" pbconversation "github.com/openimsdk/protocol/conversation" "github.com/openimsdk/protocol/msg" "github.com/openimsdk/protocol/third" @@ -14,14 +18,13 @@ import ( "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/mcontext" "github.com/openimsdk/tools/utils/runtimeenv" - "github.com/robfig/cron/v3" - "google.golang.org/grpc" ) type Config struct { - CronTask config.CronTask - Share config.Share - Discovery config.Discovery + CronTask config.CronTask + Share config.Share + Discovery config.Discovery + RedisConfig config.Redis } func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegistry, service grpc.ServiceRegistrar) error { @@ -60,10 +63,13 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis if err != nil { return err } - } - - if locker == nil { - locker = emptyLocker{} + } else { + builder := dbbuild.NewBuilder(nil, &conf.RedisConfig) + rdb, err := builder.Redis(ctx) + if err != nil { + return err + } + locker = NewRedisLocker(rdb) } srv := &cronServer{ @@ -95,16 +101,6 @@ func Start(ctx context.Context, conf *Config, client discovery.SvcDiscoveryRegis return nil } -type Locker interface { - ExecuteWithLock(ctx context.Context, taskName string, task func()) -} - -type emptyLocker struct{} - -func (emptyLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) { - task() -} - type cronServer struct { ctx context.Context config *Config diff --git a/internal/tools/cron/dist_look.go b/internal/tools/cron/etcd_locker.go similarity index 97% rename from internal/tools/cron/dist_look.go rename to internal/tools/cron/etcd_locker.go index e46b9206c..959110fea 100644 --- a/internal/tools/cron/dist_look.go +++ b/internal/tools/cron/etcd_locker.go @@ -6,13 +6,10 @@ import ( "os" "time" - "github.com/openimsdk/tools/log" clientv3 "go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/client/v3/concurrency" -) -const ( - lockLeaseTTL = 300 + "github.com/openimsdk/tools/log" ) type EtcdLocker struct { @@ -35,7 +32,7 @@ func NewEtcdLocker(client *clientv3.Client) (*EtcdLocker, error) { } func (e *EtcdLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) { - session, err := concurrency.NewSession(e.client, concurrency.WithTTL(lockLeaseTTL)) + session, err := concurrency.NewSession(e.client, concurrency.WithTTL(int(lockLeaseTTL/time.Second))) if err != nil { log.ZWarn(ctx, "Failed to create etcd session", err, "taskName", taskName, diff --git a/internal/tools/cron/locker.go b/internal/tools/cron/locker.go new file mode 100644 index 000000000..4a1115486 --- /dev/null +++ b/internal/tools/cron/locker.go @@ -0,0 +1,14 @@ +package cron + +import ( + "context" + "time" +) + +const ( + lockLeaseTTL = time.Second * 300 +) + +type Locker interface { + ExecuteWithLock(ctx context.Context, taskName string, task func()) +} diff --git a/internal/tools/cron/redis_locker.go b/internal/tools/cron/redis_locker.go new file mode 100644 index 000000000..329e9cb77 --- /dev/null +++ b/internal/tools/cron/redis_locker.go @@ -0,0 +1,68 @@ +package cron + +import ( + "context" + "strings" + "time" + + "github.com/google/uuid" + "github.com/redis/go-redis/v9" + + "github.com/openimsdk/tools/log" +) + +func NewRedisLocker(client redis.UniversalClient) *RedisLocker { + return &RedisLocker{ + client: client, + script: redis.NewScript(strings.TrimSpace(` +if redis.call("get", KEYS[1]) == ARGV[1] then + return redis.call("del", KEYS[1]) +else + return 0 +end +`)), + } +} + +type RedisLocker struct { + client redis.UniversalClient + script *redis.Script +} + +func (e *RedisLocker) getKey(name string) string { + return "CRON_LOCKED:" + name +} + +func (e *RedisLocker) lock(ctx context.Context, name string, owner string) (bool, error) { + ctx, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() + return e.client.SetNX(ctx, e.getKey(name), owner, lockLeaseTTL).Result() +} + +func (e *RedisLocker) unlock(ctx context.Context, name string, owner string) error { + ctx, cancel := context.WithTimeout(ctx, time.Second) + defer cancel() + return e.script.Run(ctx, e.client, []string{e.getKey(name)}, owner).Err() +} + +func (e *RedisLocker) ExecuteWithLock(ctx context.Context, taskName string, task func()) { + owner := uuid.New().String() + ok, err := e.lock(ctx, taskName, owner) + if err != nil { + log.ZWarn(ctx, "cron lock get lock", err, "taskName", taskName) + return + } + log.ZDebug(ctx, "cron lock get lock", "taskName", taskName, "ok", ok, "owner", owner) + if !ok { + return + } + defer func() { + err := e.unlock(ctx, taskName, owner) + if err == nil { + log.ZDebug(ctx, "cron lock unlock", "taskName", taskName, "owner", owner) + } else { + log.ZWarn(ctx, "cron lock unlock", err, "taskName", taskName, "owner", owner) + } + }() + task() +} diff --git a/pkg/common/cmd/cron_task.go b/pkg/common/cmd/cron_task.go index c666bd021..041deea67 100644 --- a/pkg/common/cmd/cron_task.go +++ b/pkg/common/cmd/cron_task.go @@ -17,12 +17,13 @@ package cmd import ( "context" + "github.com/spf13/cobra" + "github.com/openimsdk/open-im-server/v3/internal/tools/cron" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc" "github.com/openimsdk/open-im-server/v3/version" "github.com/openimsdk/tools/system/program" - "github.com/spf13/cobra" ) type CronTaskCmd struct { @@ -39,6 +40,7 @@ func NewCronTaskCmd() *CronTaskCmd { config.OpenIMCronTaskCfgFileName: &cronTaskConfig.CronTask, config.ShareFileName: &cronTaskConfig.Share, config.DiscoveryConfigFilename: &cronTaskConfig.Discovery, + config.RedisConfigFileName: &cronTaskConfig.RedisConfig, } ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap)) ret.ctx = context.WithValue(context.Background(), "version", version.Version) diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 695684d15..8ec648359 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -28,6 +28,13 @@ import ( "github.com/openimsdk/tools/s3/oss" ) +// FileConfig is implemented by every config struct that is backed by a config +// file; GetConfigFileName reports that file's name (e.g. "redis.yml"). It is the +// single marker used to decide whether a struct field is loaded from a file. +type FileConfig interface { + GetConfigFileName() string +} + const StructTagName = "yaml" type Path string @@ -135,6 +142,7 @@ type API struct { Api struct { ListenIP string `yaml:"listenIP"` Ports []int `yaml:"ports"` + RegisterIP string `yaml:"registerIP"` CompressionLevel int `yaml:"compressionLevel"` } `yaml:"api"` Prometheus struct { @@ -418,7 +426,8 @@ type AfterConfig struct { } type Share struct { - Secret string `yaml:"secret"` + Secret string `yaml:"secret"` + Queue EngineSelector `yaml:"queue"` IMAdminUser struct { UserIDs []string `yaml:"userIDs"` Nicknames []string `yaml:"nicknames"` diff --git a/pkg/common/config/load_config.go b/pkg/common/config/load_config.go index 142b704e1..de493ceeb 100644 --- a/pkg/common/config/load_config.go +++ b/pkg/common/config/load_config.go @@ -3,12 +3,14 @@ package config import ( "os" "path/filepath" + "reflect" "strings" "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" + "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/utils/runtimeenv" - "github.com/spf13/viper" ) func Load(configDirectory string, configFileName string, envPrefix string, config any) error { @@ -35,10 +37,27 @@ func loadConfig(path string, envPrefix string, config any) error { return errs.WrapMsg(err, "failed to read config file", "path", path, "envPrefix", envPrefix) } - if err := v.Unmarshal(config, func(config *mapstructure.DecoderConfig) { - config.TagName = StructTagName - }); err != nil { + if err := v.Unmarshal(config, ApplyDecoderConfig); err != nil { return errs.WrapMsg(err, "failed to unmarshal config", "path", path, "envPrefix", envPrefix) } return nil } + +func ApplyDecoderConfig(config *mapstructure.DecoderConfig) { + config.TagName = StructTagName + config.DecodeHook = mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToSliceHookFunc(","), + stringToEngineSelectorHookFunc(), + ) +} + +func stringToEngineSelectorHookFunc() mapstructure.DecodeHookFuncType { + engineSelectorType := reflect.TypeOf(EngineSelector{}) + return func(from reflect.Type, to reflect.Type, data any) (any, error) { + if to != engineSelectorType || from.Kind() != reflect.String { + return data, nil + } + return EngineSelector{Engine: data.(string)}, nil + } +} diff --git a/pkg/common/config/mq.go b/pkg/common/config/mq.go new file mode 100644 index 000000000..76fdb26e6 --- /dev/null +++ b/pkg/common/config/mq.go @@ -0,0 +1,41 @@ +package config + +import ( + "strings" + + "github.com/openimsdk/tools/errs" +) + +const ( + QueueEngineKafka = "kafka" + QueueEngineRedis = "redis" + QueueEngineMemory = "memory" +) + +func NormalizeQueueEngine(engine string) string { + switch strings.ToLower(strings.TrimSpace(engine)) { + case "", "kafka": + return QueueEngineKafka + case "redis": + return QueueEngineRedis + case "memory": + return QueueEngineMemory + default: + return strings.ToLower(strings.TrimSpace(engine)) + } +} + +func ValidateQueueEngine(engine string, standalone bool) (string, error) { + normalized := NormalizeQueueEngine(engine) + switch normalized { + case QueueEngineKafka, QueueEngineRedis: + return normalized, nil + case QueueEngineMemory: + if standalone { + return normalized, nil + } + return "", errs.ErrArgs.WrapMsg("unsupported queue engine for microservice deployment", "engine", engine) + default: + return "", errs.ErrArgs.WrapMsg("unsupported queue engine", "engine", engine) + } +} diff --git a/pkg/common/config/selector.go b/pkg/common/config/selector.go new file mode 100644 index 000000000..8aeeeaaa3 --- /dev/null +++ b/pkg/common/config/selector.go @@ -0,0 +1,43 @@ +package config + +import "encoding/json" + +type EngineSelector struct { + Engine string `yaml:"engine" mapstructure:"engine" json:"engine"` +} + +func (e EngineSelector) String() string { + return e.Engine +} + +func (e *EngineSelector) UnmarshalYAML(unmarshal func(any) error) error { + var engine string + if err := unmarshal(&engine); err == nil { + e.Engine = engine + return nil + } + var cfg struct { + Engine string `yaml:"engine"` + } + if err := unmarshal(&cfg); err != nil { + return err + } + e.Engine = cfg.Engine + return nil +} + +func (e *EngineSelector) UnmarshalJSON(data []byte) error { + var engine string + if err := json.Unmarshal(data, &engine); err == nil { + e.Engine = engine + return nil + } + var cfg struct { + Engine string `json:"engine"` + } + if err := json.Unmarshal(data, &cfg); err != nil { + return err + } + e.Engine = cfg.Engine + return nil +} diff --git a/pkg/common/discovery/discoveryregister.go b/pkg/common/discovery/discoveryregister.go index 87333fcac..29ed5929f 100644 --- a/pkg/common/discovery/discoveryregister.go +++ b/pkg/common/discovery/discoveryregister.go @@ -17,11 +17,12 @@ package discovery import ( "time" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/tools/discovery" - "github.com/openimsdk/tools/discovery/standalone" + "github.com/openimsdk/tools/discovery/inprocess" "github.com/openimsdk/tools/utils/runtimeenv" - "google.golang.org/grpc" "github.com/openimsdk/tools/discovery/kubernetes" @@ -32,7 +33,7 @@ import ( // NewDiscoveryRegister creates a new service discovery and registry client based on the provided environment type. func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (discovery.SvcDiscoveryRegistry, error) { if config.Standalone() { - return standalone.GetSvcDiscoveryRegistry(), nil + return inprocess.GetSvcDiscoveryRegistry(), nil } if runtimeenv.RuntimeEnvironment() == config.KUBERNETES { return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, nil, diff --git a/pkg/common/storage/cache/mcache/minio.go b/pkg/common/storage/cache/mcache/minio.go deleted file mode 100644 index f07203cc2..000000000 --- a/pkg/common/storage/cache/mcache/minio.go +++ /dev/null @@ -1,50 +0,0 @@ -package mcache - -import ( - "context" - "time" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" - "github.com/openimsdk/tools/s3/minio" -) - -func NewMinioCache(cache database.Cache) minio.Cache { - return &minioCache{ - cache: cache, - expireTime: time.Hour * 24 * 7, - } -} - -type minioCache struct { - cache database.Cache - expireTime time.Duration -} - -func (g *minioCache) getObjectImageInfoKey(key string) string { - return cachekey.GetObjectImageInfoKey(key) -} - -func (g *minioCache) getMinioImageThumbnailKey(key string, format string, width int, height int) string { - return cachekey.GetMinioImageThumbnailKey(key, format, width, height) -} - -func (g *minioCache) DelObjectImageInfoKey(ctx context.Context, keys ...string) error { - ks := make([]string, 0, len(keys)) - for _, key := range keys { - ks = append(ks, g.getObjectImageInfoKey(key)) - } - return g.cache.Del(ctx, ks) -} - -func (g *minioCache) DelImageThumbnailKey(ctx context.Context, key string, format string, width int, height int) error { - return g.cache.Del(ctx, []string{g.getMinioImageThumbnailKey(key, format, width, height)}) -} - -func (g *minioCache) GetImageObjectKeyInfo(ctx context.Context, key string, fn func(ctx context.Context) (*minio.ImageInfo, error)) (*minio.ImageInfo, error) { - return getCache[*minio.ImageInfo](ctx, g.cache, g.getObjectImageInfoKey(key), g.expireTime, fn) -} - -func (g *minioCache) GetThumbnailKey(ctx context.Context, key string, format string, width int, height int, minioCache func(ctx context.Context) (string, error)) (string, error) { - return getCache[string](ctx, g.cache, g.getMinioImageThumbnailKey(key, format, width, height), g.expireTime, minioCache) -} diff --git a/pkg/common/storage/cache/mcache/msg_cache.go b/pkg/common/storage/cache/mcache/msg_cache.go deleted file mode 100644 index 6fd5f80a1..000000000 --- a/pkg/common/storage/cache/mcache/msg_cache.go +++ /dev/null @@ -1,132 +0,0 @@ -package mcache - -import ( - "context" - "strconv" - "sync" - "time" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" - "github.com/openimsdk/open-im-server/v3/pkg/localcache" - "github.com/openimsdk/open-im-server/v3/pkg/localcache/lru" - "github.com/openimsdk/tools/errs" - "github.com/openimsdk/tools/utils/datautil" - "github.com/redis/go-redis/v9" -) - -var ( - memMsgCache lru.LRU[string, *model.MsgInfoModel] - initMemMsgCache sync.Once -) - -func NewMsgCache(cache database.Cache, msgDocDatabase database.Msg) cache.MsgCache { - initMemMsgCache.Do(func() { - memMsgCache = lru.NewLazyLRU[string, *model.MsgInfoModel](1024*8, time.Hour, time.Second*10, localcache.EmptyTarget{}, nil) - }) - return &msgCache{ - cache: cache, - msgDocDatabase: msgDocDatabase, - memMsgCache: memMsgCache, - } -} - -type msgCache struct { - cache database.Cache - msgDocDatabase database.Msg - memMsgCache lru.LRU[string, *model.MsgInfoModel] -} - -func (x *msgCache) getSendMsgKey(id string) string { - return cachekey.GetSendMsgKey(id) -} - -func (x *msgCache) SetSendMsgStatus(ctx context.Context, id string, status int32) error { - return x.cache.Set(ctx, x.getSendMsgKey(id), strconv.Itoa(int(status)), time.Hour*24) -} - -func (x *msgCache) GetSendMsgStatus(ctx context.Context, id string) (int32, error) { - key := x.getSendMsgKey(id) - res, err := x.cache.Get(ctx, []string{key}) - if err != nil { - return 0, err - } - val, ok := res[key] - if !ok { - return 0, errs.Wrap(redis.Nil) - } - status, err := strconv.Atoi(val) - if err != nil { - return 0, errs.WrapMsg(err, "GetSendMsgStatus strconv.Atoi error", "val", val) - } - return int32(status), nil -} - -func (x *msgCache) getMsgCacheKey(conversationID string, seq int64) string { - return cachekey.GetMsgCacheKey(conversationID, seq) - -} - -func (x *msgCache) GetMessageBySeqs(ctx context.Context, conversationID string, seqs []int64) ([]*model.MsgInfoModel, error) { - if len(seqs) == 0 { - return nil, nil - } - keys := make([]string, 0, len(seqs)) - keySeq := make(map[string]int64, len(seqs)) - for _, seq := range seqs { - key := x.getMsgCacheKey(conversationID, seq) - keys = append(keys, key) - keySeq[key] = seq - } - res, err := x.memMsgCache.GetBatch(keys, func(keys []string) (map[string]*model.MsgInfoModel, error) { - findSeqs := make([]int64, 0, len(keys)) - for _, key := range keys { - seq, ok := keySeq[key] - if !ok { - continue - } - findSeqs = append(findSeqs, seq) - } - res, err := x.msgDocDatabase.FindSeqs(ctx, conversationID, seqs) - if err != nil { - return nil, err - } - kv := make(map[string]*model.MsgInfoModel) - for i := range res { - msg := res[i] - if msg == nil || msg.Msg == nil || msg.Msg.Seq <= 0 { - continue - } - key := x.getMsgCacheKey(conversationID, msg.Msg.Seq) - kv[key] = msg - } - return kv, nil - }) - if err != nil { - return nil, err - } - return datautil.Values(res), nil -} - -func (x msgCache) DelMessageBySeqs(ctx context.Context, conversationID string, seqs []int64) error { - if len(seqs) == 0 { - return nil - } - for _, seq := range seqs { - x.memMsgCache.Del(x.getMsgCacheKey(conversationID, seq)) - } - return nil -} - -func (x *msgCache) SetMessageBySeqs(ctx context.Context, conversationID string, msgs []*model.MsgInfoModel) error { - for i := range msgs { - msg := msgs[i] - if msg == nil || msg.Msg == nil || msg.Msg.Seq <= 0 { - continue - } - x.memMsgCache.Set(x.getMsgCacheKey(conversationID, msg.Msg.Seq), msg) - } - return nil -} diff --git a/pkg/common/storage/cache/mcache/online.go b/pkg/common/storage/cache/mcache/online.go deleted file mode 100644 index f018da03e..000000000 --- a/pkg/common/storage/cache/mcache/online.go +++ /dev/null @@ -1,82 +0,0 @@ -package mcache - -import ( - "context" - "sync" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" -) - -var ( - globalOnlineCache cache.OnlineCache - globalOnlineOnce sync.Once -) - -func NewOnlineCache() cache.OnlineCache { - globalOnlineOnce.Do(func() { - globalOnlineCache = &onlineCache{ - user: make(map[string]map[int32]struct{}), - } - }) - return globalOnlineCache -} - -type onlineCache struct { - lock sync.RWMutex - user map[string]map[int32]struct{} -} - -func (x *onlineCache) GetOnline(ctx context.Context, userID string) ([]int32, error) { - x.lock.RLock() - defer x.lock.RUnlock() - pSet, ok := x.user[userID] - if !ok { - return nil, nil - } - res := make([]int32, 0, len(pSet)) - for k := range pSet { - res = append(res, k) - } - return res, nil -} - -func (x *onlineCache) SetUserOnline(ctx context.Context, userID string, online, offline []int32) error { - x.lock.Lock() - defer x.lock.Unlock() - pSet, ok := x.user[userID] - if ok { - for _, p := range offline { - delete(pSet, p) - } - } - if len(online) > 0 { - if !ok { - pSet = make(map[int32]struct{}) - x.user[userID] = pSet - } - for _, p := range online { - pSet[p] = struct{}{} - } - } - if len(pSet) == 0 { - delete(x.user, userID) - } - return nil -} - -func (x *onlineCache) GetAllOnlineUsers(ctx context.Context, cursor uint64) (map[string][]int32, uint64, error) { - if cursor != 0 { - return nil, 0, nil - } - x.lock.RLock() - defer x.lock.RUnlock() - res := make(map[string][]int32) - for k, v := range x.user { - pSet := make([]int32, 0, len(v)) - for p := range v { - pSet = append(pSet, p) - } - res[k] = pSet - } - return res, 0, nil -} diff --git a/pkg/common/storage/cache/mcache/seq_conversation.go b/pkg/common/storage/cache/mcache/seq_conversation.go deleted file mode 100644 index 879b03535..000000000 --- a/pkg/common/storage/cache/mcache/seq_conversation.go +++ /dev/null @@ -1,79 +0,0 @@ -package mcache - -import ( - "context" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" -) - -func NewSeqConversationCache(sc database.SeqConversation) cache.SeqConversationCache { - return &seqConversationCache{ - sc: sc, - } -} - -type seqConversationCache struct { - sc database.SeqConversation -} - -func (x *seqConversationCache) Malloc(ctx context.Context, conversationID string, size int64) (int64, error) { - return x.sc.Malloc(ctx, conversationID, size) -} - -func (x *seqConversationCache) SetMinSeq(ctx context.Context, conversationID string, seq int64) error { - return x.sc.SetMinSeq(ctx, conversationID, seq) -} - -func (x *seqConversationCache) GetMinSeq(ctx context.Context, conversationID string) (int64, error) { - return x.sc.GetMinSeq(ctx, conversationID) -} - -func (x *seqConversationCache) GetMaxSeqs(ctx context.Context, conversationIDs []string) (map[string]int64, error) { - res := make(map[string]int64) - for _, conversationID := range conversationIDs { - seq, err := x.GetMaxSeq(ctx, conversationID) - if err != nil { - return nil, err - } - res[conversationID] = seq - } - return res, nil -} - -func (x *seqConversationCache) GetMaxSeqsWithTime(ctx context.Context, conversationIDs []string) (map[string]database.SeqTime, error) { - res := make(map[string]database.SeqTime) - for _, conversationID := range conversationIDs { - seq, err := x.GetMaxSeq(ctx, conversationID) - if err != nil { - return nil, err - } - res[conversationID] = database.SeqTime{Seq: seq} - } - return res, nil -} - -func (x *seqConversationCache) GetMaxSeq(ctx context.Context, conversationID string) (int64, error) { - return x.sc.GetMaxSeq(ctx, conversationID) -} - -func (x *seqConversationCache) GetMaxSeqWithTime(ctx context.Context, conversationID string) (database.SeqTime, error) { - seq, err := x.GetMinSeq(ctx, conversationID) - if err != nil { - return database.SeqTime{}, err - } - return database.SeqTime{Seq: seq}, nil -} - -func (x *seqConversationCache) SetMinSeqs(ctx context.Context, seqs map[string]int64) error { - for conversationID, seq := range seqs { - if err := x.sc.SetMinSeq(ctx, conversationID, seq); err != nil { - return err - } - } - return nil -} - -func (x *seqConversationCache) GetCacheMaxSeqWithTime(ctx context.Context, conversationIDs []string) (map[string]database.SeqTime, error) { - return x.GetMaxSeqsWithTime(ctx, conversationIDs) -} diff --git a/pkg/common/storage/cache/mcache/third.go b/pkg/common/storage/cache/mcache/third.go deleted file mode 100644 index 6918ae784..000000000 --- a/pkg/common/storage/cache/mcache/third.go +++ /dev/null @@ -1,98 +0,0 @@ -package mcache - -import ( - "context" - "strconv" - "time" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" - "github.com/openimsdk/tools/errs" - "github.com/redis/go-redis/v9" -) - -func NewThirdCache(cache database.Cache) cache.ThirdCache { - return &thirdCache{ - cache: cache, - } -} - -type thirdCache struct { - cache database.Cache -} - -func (c *thirdCache) getGetuiTokenKey() string { - return cachekey.GetGetuiTokenKey() -} - -func (c *thirdCache) getGetuiTaskIDKey() string { - return cachekey.GetGetuiTaskIDKey() -} - -func (c *thirdCache) getUserBadgeUnreadCountSumKey(userID string) string { - return cachekey.GetUserBadgeUnreadCountSumKey(userID) -} - -func (c *thirdCache) getFcmAccountTokenKey(account string, platformID int) string { - return cachekey.GetFcmAccountTokenKey(account, platformID) -} - -func (c *thirdCache) get(ctx context.Context, key string) (string, error) { - res, err := c.cache.Get(ctx, []string{key}) - if err != nil { - return "", err - } - if val, ok := res[key]; ok { - return val, nil - } - return "", errs.Wrap(redis.Nil) -} - -func (c *thirdCache) SetFcmToken(ctx context.Context, account string, platformID int, fcmToken string, expireTime int64) (err error) { - return errs.Wrap(c.cache.Set(ctx, c.getFcmAccountTokenKey(account, platformID), fcmToken, time.Duration(expireTime)*time.Second)) -} - -func (c *thirdCache) GetFcmToken(ctx context.Context, account string, platformID int) (string, error) { - return c.get(ctx, c.getFcmAccountTokenKey(account, platformID)) -} - -func (c *thirdCache) DelFcmToken(ctx context.Context, account string, platformID int) error { - return c.cache.Del(ctx, []string{c.getFcmAccountTokenKey(account, platformID)}) -} - -func (c *thirdCache) IncrUserBadgeUnreadCountSum(ctx context.Context, userID string) (int, error) { - return c.cache.Incr(ctx, c.getUserBadgeUnreadCountSumKey(userID), 1) -} - -func (c *thirdCache) SetUserBadgeUnreadCountSum(ctx context.Context, userID string, value int) error { - return c.cache.Set(ctx, c.getUserBadgeUnreadCountSumKey(userID), strconv.Itoa(value), 0) -} - -func (c *thirdCache) GetUserBadgeUnreadCountSum(ctx context.Context, userID string) (int, error) { - str, err := c.get(ctx, c.getUserBadgeUnreadCountSumKey(userID)) - if err != nil { - return 0, err - } - val, err := strconv.Atoi(str) - if err != nil { - return 0, errs.WrapMsg(err, "strconv.Atoi", "str", str) - } - return val, nil -} - -func (c *thirdCache) SetGetuiToken(ctx context.Context, token string, expireTime int64) error { - return c.cache.Set(ctx, c.getGetuiTokenKey(), token, time.Duration(expireTime)*time.Second) -} - -func (c *thirdCache) GetGetuiToken(ctx context.Context) (string, error) { - return c.get(ctx, c.getGetuiTokenKey()) -} - -func (c *thirdCache) SetGetuiTaskID(ctx context.Context, taskID string, expireTime int64) error { - return c.cache.Set(ctx, c.getGetuiTaskIDKey(), taskID, time.Duration(expireTime)*time.Second) -} - -func (c *thirdCache) GetGetuiTaskID(ctx context.Context) (string, error) { - return c.get(ctx, c.getGetuiTaskIDKey()) -} diff --git a/pkg/common/storage/cache/mcache/token.go b/pkg/common/storage/cache/mcache/token.go deleted file mode 100644 index 98b9cc066..000000000 --- a/pkg/common/storage/cache/mcache/token.go +++ /dev/null @@ -1,166 +0,0 @@ -package mcache - -import ( - "context" - "fmt" - "strconv" - "strings" - "time" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" - "github.com/openimsdk/tools/errs" - "github.com/openimsdk/tools/log" -) - -func NewTokenCacheModel(cache database.Cache, accessExpire int64) cache.TokenModel { - c := &tokenCache{cache: cache} - c.accessExpire = c.getExpireTime(accessExpire) - return c -} - -type tokenCache struct { - cache database.Cache - accessExpire time.Duration -} - -func (x *tokenCache) getTokenKey(userID string, platformID int, token string) string { - return cachekey.GetTokenKey(userID, platformID) + ":" + token -} - -func (x *tokenCache) SetTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error { - return x.cache.Set(ctx, x.getTokenKey(userID, platformID, token), strconv.Itoa(flag), x.accessExpire) -} - -// SetTokenFlagEx set token and flag with expire time -func (x *tokenCache) SetTokenFlagEx(ctx context.Context, userID string, platformID int, token string, flag int) error { - return x.SetTokenFlag(ctx, userID, platformID, token, flag) -} - -func (x *tokenCache) GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error) { - prefix := x.getTokenKey(userID, platformID, "") - m, err := x.cache.Prefix(ctx, prefix) - if err != nil { - return nil, errs.Wrap(err) - } - mm := make(map[string]int) - for k, v := range m { - state, err := strconv.Atoi(v) - if err != nil { - log.ZError(ctx, "token value is not int", err, "value", v, "userID", userID, "platformID", platformID) - continue - } - mm[strings.TrimPrefix(k, prefix)] = state - } - return mm, nil -} - -func (x *tokenCache) HasTemporaryToken(ctx context.Context, userID string, platformID int, token string) error { - key := cachekey.GetTemporaryTokenKey(userID, platformID, token) - if _, err := x.cache.Get(ctx, []string{key}); err != nil { - return err - } - return nil -} - -func (x *tokenCache) GetAllTokensWithoutError(ctx context.Context, userID string) (map[int]map[string]int, error) { - prefix := cachekey.UidPidToken + userID + ":" - tokens, err := x.cache.Prefix(ctx, prefix) - if err != nil { - return nil, err - } - res := make(map[int]map[string]int) - for key, flagStr := range tokens { - flag, err := strconv.Atoi(flagStr) - if err != nil { - log.ZError(ctx, "token value is not int", err, "key", key, "value", flagStr, "userID", userID) - continue - } - arr := strings.SplitN(strings.TrimPrefix(key, prefix), ":", 2) - if len(arr) != 2 { - log.ZError(ctx, "token value is not int", err, "key", key, "value", flagStr, "userID", userID) - continue - } - platformID, err := strconv.Atoi(arr[0]) - if err != nil { - log.ZError(ctx, "token value is not int", err, "key", key, "value", flagStr, "userID", userID) - continue - } - token := arr[1] - if token == "" { - log.ZError(ctx, "token value is not int", err, "key", key, "value", flagStr, "userID", userID) - continue - } - tk, ok := res[platformID] - if !ok { - tk = make(map[string]int) - res[platformID] = tk - } - tk[token] = flag - } - return res, nil -} - -func (x *tokenCache) SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error { - for token, flag := range m { - err := x.SetTokenFlag(ctx, userID, platformID, token, flag) - if err != nil { - return err - } - } - return nil -} - -func (x *tokenCache) BatchSetTokenMapByUidPid(ctx context.Context, tokens map[string]map[string]any) error { - for prefix, tokenFlag := range tokens { - for token, flag := range tokenFlag { - flagStr := fmt.Sprintf("%v", flag) - if err := x.cache.Set(ctx, prefix+":"+token, flagStr, x.accessExpire); err != nil { - return err - } - } - } - return nil -} - -func (x *tokenCache) DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error { - keys := make([]string, 0, len(fields)) - for _, token := range fields { - keys = append(keys, x.getTokenKey(userID, platformID, token)) - } - return x.cache.Del(ctx, keys) -} - -func (x *tokenCache) getExpireTime(t int64) time.Duration { - return time.Hour * 24 * time.Duration(t) -} - -func (x *tokenCache) DeleteTokenByTokenMap(ctx context.Context, userID string, tokens map[int][]string) error { - keys := make([]string, 0, len(tokens)) - for platformID, ts := range tokens { - for _, t := range ts { - keys = append(keys, x.getTokenKey(userID, platformID, t)) - } - } - return x.cache.Del(ctx, keys) -} - -func (x *tokenCache) DeleteAndSetTemporary(ctx context.Context, userID string, platformID int, fields []string) error { - keys := make([]string, 0, len(fields)) - for _, f := range fields { - keys = append(keys, x.getTokenKey(userID, platformID, f)) - } - if err := x.cache.Del(ctx, keys); err != nil { - return err - } - - for _, f := range fields { - k := cachekey.GetTemporaryTokenKey(userID, platformID, f) - if err := x.cache.Set(ctx, k, "", time.Minute*5); err != nil { - return errs.Wrap(err) - } - } - - return nil -} diff --git a/pkg/common/storage/cache/mcache/tools.go b/pkg/common/storage/cache/mcache/tools.go deleted file mode 100644 index f3c4265cd..000000000 --- a/pkg/common/storage/cache/mcache/tools.go +++ /dev/null @@ -1,63 +0,0 @@ -package mcache - -import ( - "context" - "encoding/json" - "time" - - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" - "github.com/openimsdk/tools/log" -) - -func getCache[V any](ctx context.Context, cache database.Cache, key string, expireTime time.Duration, fn func(ctx context.Context) (V, error)) (V, error) { - getDB := func() (V, bool, error) { - res, err := cache.Get(ctx, []string{key}) - if err != nil { - var val V - return val, false, err - } - var val V - if str, ok := res[key]; ok { - if json.Unmarshal([]byte(str), &val) != nil { - return val, false, err - } - return val, true, nil - } - return val, false, nil - } - dbVal, ok, err := getDB() - if err != nil { - return dbVal, err - } - if ok { - return dbVal, nil - } - lockValue, err := cache.Lock(ctx, key, time.Minute) - if err != nil { - return dbVal, err - } - defer func() { - if err := cache.Unlock(ctx, key, lockValue); err != nil { - log.ZError(ctx, "unlock cache key", err, "key", key, "value", lockValue) - } - }() - dbVal, ok, err = getDB() - if err != nil { - return dbVal, err - } - if ok { - return dbVal, nil - } - val, err := fn(ctx) - if err != nil { - return val, err - } - data, err := json.Marshal(val) - if err != nil { - return val, err - } - if err := cache.Set(ctx, key, string(data), expireTime); err != nil { - return val, err - } - return val, nil -} diff --git a/pkg/common/storage/cache/redis/online.go b/pkg/common/storage/cache/redis/online.go index d09c44e9a..fe5d7ecb9 100644 --- a/pkg/common/storage/cache/redis/online.go +++ b/pkg/common/storage/cache/redis/online.go @@ -7,20 +7,16 @@ import ( "strings" "time" - "github.com/openimsdk/open-im-server/v3/pkg/common/config" + "github.com/redis/go-redis/v9" + "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" "github.com/openimsdk/protocol/constant" "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" - "github.com/redis/go-redis/v9" ) func NewUserOnline(rdb redis.UniversalClient) cache.OnlineCache { - if rdb == nil || config.Standalone() { - return mcache.NewOnlineCache() - } return &userOnline{ rdb: rdb, expire: cachekey.OnlineExpire, diff --git a/pkg/common/storage/cache/redis/seq_conversation.go b/pkg/common/storage/cache/redis/seq_conversation.go index 604826598..524f07372 100644 --- a/pkg/common/storage/cache/redis/seq_conversation.go +++ b/pkg/common/storage/cache/redis/seq_conversation.go @@ -7,20 +7,17 @@ import ( "strconv" "time" + "github.com/redis/go-redis/v9" + "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/cachekey" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/mcache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" - "github.com/redis/go-redis/v9" ) func NewSeqConversationCacheRedis(rdb redis.UniversalClient, mgo database.SeqConversation) cache.SeqConversationCache { - if rdb == nil { - return mcache.NewSeqConversationCache(mgo) - } return &seqConversationCacheRedis{ mgo: mgo, lockTime: time.Second * 3, diff --git a/pkg/common/storage/cache/redis/standalone_gateway.go b/pkg/common/storage/cache/redis/standalone_gateway.go new file mode 100644 index 000000000..bb46fb476 --- /dev/null +++ b/pkg/common/storage/cache/redis/standalone_gateway.go @@ -0,0 +1,54 @@ +package redis + +import ( + "context" + "strconv" + "time" + + "github.com/redis/go-redis/v9" + + "github.com/openimsdk/tools/errs" +) + +const standaloneGatewayHashKey = "STANDALONE_GATEWAY_REGISTRY" + +type StandaloneGatewayRedis struct { + rdb redis.UniversalClient + validTime time.Duration +} + +func NewStandaloneGatewayRedis(rdb redis.UniversalClient, validTime time.Duration) *StandaloneGatewayRedis { + return &StandaloneGatewayRedis{rdb: rdb, validTime: validTime} +} + +func (s *StandaloneGatewayRedis) RegisterGateway(ctx context.Context, addr string) error { + pipe := s.rdb.Pipeline() + pipe.HSet(ctx, standaloneGatewayHashKey, addr, strconv.FormatInt(time.Now().UnixMilli(), 10)) + pipe.Expire(ctx, standaloneGatewayHashKey, s.validTime*2) + _, err := pipe.Exec(ctx) + return errs.Wrap(err) +} + +func (s *StandaloneGatewayRedis) UnregisterGateway(ctx context.Context, addr string) error { + return errs.Wrap(s.rdb.HDel(ctx, standaloneGatewayHashKey, addr).Err()) +} + +func (s *StandaloneGatewayRedis) GetGatewayAddrs(ctx context.Context) ([]string, error) { + gateways, err := s.rdb.HGetAll(ctx, standaloneGatewayHashKey).Result() + if err != nil { + return nil, errs.Wrap(err) + } + + now := time.Now() + addrs := make([]string, 0, len(gateways)) + for addr, registeredAt := range gateways { + registeredAtMs, err := strconv.ParseInt(registeredAt, 10, 64) + if err != nil { + return nil, errs.WrapMsg(err, "redis gateway register time is not int64", "addr", addr, "value", registeredAt) + } + if now.Sub(time.UnixMilli(registeredAtMs)) <= s.validTime { + addrs = append(addrs, addr) + } + } + return addrs, nil +} diff --git a/pkg/common/storage/cache/redis/standalone_gateway_test.go b/pkg/common/storage/cache/redis/standalone_gateway_test.go new file mode 100644 index 000000000..3b88df104 --- /dev/null +++ b/pkg/common/storage/cache/redis/standalone_gateway_test.go @@ -0,0 +1,52 @@ +package redis + +import ( + "context" + "strconv" + "testing" + "time" + + "github.com/go-redis/redismock/v9" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestStandaloneGatewayRedisRegisterGateway(t *testing.T) { + rdb, mock := redismock.NewClientMock() + cache := NewStandaloneGatewayRedis(rdb, time.Second*10) + + mock.Regexp().ExpectHSet(standaloneGatewayHashKey, "127.0.0.1:10001", `^[0-9]+$`).SetVal(1) + mock.ExpectExpire(standaloneGatewayHashKey, time.Second*20).SetVal(true) + + err := cache.RegisterGateway(context.Background(), "127.0.0.1:10001") + require.NoError(t, err) + assert.NoError(t, mock.ExpectationsWereMet()) +} + +func TestStandaloneGatewayRedisUnregisterGateway(t *testing.T) { + rdb, mock := redismock.NewClientMock() + cache := NewStandaloneGatewayRedis(rdb, time.Second) + + mock.ExpectHDel(standaloneGatewayHashKey, "127.0.0.1:10001").SetVal(1) + + err := cache.UnregisterGateway(context.Background(), "127.0.0.1:10001") + require.NoError(t, err) + assert.NoError(t, mock.ExpectationsWereMet()) +} + +func TestStandaloneGatewayRedisGetGatewayAddrs(t *testing.T) { + rdb, mock := redismock.NewClientMock() + cache := NewStandaloneGatewayRedis(rdb, time.Second*10) + + now := time.Now() + mock.ExpectHGetAll(standaloneGatewayHashKey).SetVal(map[string]string{ + "127.0.0.1:10001": strconv.FormatInt(now.Add(-time.Second).UnixMilli(), 10), + "127.0.0.1:10002": strconv.FormatInt(now.Add(-time.Second*20).UnixMilli(), 10), + "127.0.0.1:10003": strconv.FormatInt(now.Add(time.Second).UnixMilli(), 10), + }) + + addrs, err := cache.GetGatewayAddrs(context.Background()) + require.NoError(t, err) + assert.ElementsMatch(t, []string{"127.0.0.1:10001", "127.0.0.1:10003"}, addrs) + assert.NoError(t, mock.ExpectationsWereMet()) +} diff --git a/pkg/mqbuild/builder.go b/pkg/mqbuild/builder.go index 938159372..c2f2d3b28 100644 --- a/pkg/mqbuild/builder.go +++ b/pkg/mqbuild/builder.go @@ -4,9 +4,12 @@ import ( "context" "fmt" + "github.com/redis/go-redis/v9" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/tools/mq" "github.com/openimsdk/tools/mq/kafka" + "github.com/openimsdk/tools/mq/redismq" "github.com/openimsdk/tools/mq/simmq" ) @@ -15,19 +18,120 @@ type Builder interface { GetTopicConsumer(ctx context.Context, topic string) (mq.Consumer, error) } -func NewBuilder(kafka *config.Kafka) Builder { - if config.Standalone() { - return standaloneBuilder{} +const ( + TopicToRedis = "toRedis" + TopicToMongo = "toMongo" + TopicToPush = "toPush" + TopicToOfflinePush = "toOfflinePush" +) + +const ( + GroupRedis = "redis" + GroupMongo = "mongo" + GroupPush = "push" + GroupOfflinePush = "offlinePush" +) + +func NewBuilder(queue config.EngineSelector, kafka *config.Kafka, redis redis.UniversalClient) (Builder, error) { + engine, err := config.ValidateQueueEngine(queue.Engine, config.Standalone()) + if err != nil { + return nil, err } + switch engine { + case config.QueueEngineKafka: + if kafka == nil { + return nil, fmt.Errorf("nil kafka config") + } + return newKafkaBuilder(kafka), nil + case config.QueueEngineRedis: + return newRedisBuilder(redis), nil + case config.QueueEngineMemory: + return standaloneBuilder{}, nil + default: + return nil, fmt.Errorf("unsupported queue engine %s", queue.Engine) + } +} + +func newKafkaBuilder(kafka *config.Kafka) Builder { + topics := MergeTopics(KafkaTopics(kafka)) return &kafkaBuilder{ - addr: kafka.Address, - config: kafka.Build(), - topicGroupID: map[string]string{ - kafka.ToRedisTopic: kafka.ToRedisGroupID, - kafka.ToMongoTopic: kafka.ToMongoGroupID, - kafka.ToPushTopic: kafka.ToPushGroupID, - kafka.ToOfflinePushTopic: kafka.ToOfflineGroupID, - }, + addr: kafka.Address, + config: kafka.Build(), + logicalTopic: LogicalTopicNames(topics), + topicGroupID: TopicGroupID(topics), + } +} + +func newRedisBuilder(redis redis.UniversalClient) Builder { + return redismq.NewBuilder(redis, TopicGroupID(DefaultTopics()), redismq.Config{StreamPrefix: "mq:"}) +} + +type QueueTopicsConfig struct { + ToRedis QueueTopicConfig + ToMongo QueueTopicConfig + ToPush QueueTopicConfig + ToOfflinePush QueueTopicConfig +} + +type QueueTopicConfig struct { + Topic string + GroupID string +} + +func DefaultTopics() QueueTopicsConfig { + return QueueTopicsConfig{ + ToRedis: QueueTopicConfig{Topic: TopicToRedis, GroupID: GroupRedis}, + ToMongo: QueueTopicConfig{Topic: TopicToMongo, GroupID: GroupMongo}, + ToPush: QueueTopicConfig{Topic: TopicToPush, GroupID: GroupPush}, + ToOfflinePush: QueueTopicConfig{Topic: TopicToOfflinePush, GroupID: GroupOfflinePush}, + } +} + +func KafkaTopics(kafka *config.Kafka) QueueTopicsConfig { + if kafka == nil { + return QueueTopicsConfig{} + } + return QueueTopicsConfig{ + ToRedis: QueueTopicConfig{Topic: kafka.ToRedisTopic, GroupID: kafka.ToRedisGroupID}, + ToMongo: QueueTopicConfig{Topic: kafka.ToMongoTopic, GroupID: kafka.ToMongoGroupID}, + ToPush: QueueTopicConfig{Topic: kafka.ToPushTopic, GroupID: kafka.ToPushGroupID}, + ToOfflinePush: QueueTopicConfig{Topic: kafka.ToOfflinePushTopic, GroupID: kafka.ToOfflineGroupID}, + } +} + +func MergeTopics(topics QueueTopicsConfig) QueueTopicsConfig { + defaults := DefaultTopics() + fillTopic(&topics.ToRedis, defaults.ToRedis) + fillTopic(&topics.ToMongo, defaults.ToMongo) + fillTopic(&topics.ToPush, defaults.ToPush) + fillTopic(&topics.ToOfflinePush, defaults.ToOfflinePush) + return topics +} + +func fillTopic(topic *QueueTopicConfig, defaultTopic QueueTopicConfig) { + if topic.Topic == "" { + topic.Topic = defaultTopic.Topic + } + if topic.GroupID == "" { + topic.GroupID = defaultTopic.GroupID + } +} + +func LogicalTopicNames(topics QueueTopicsConfig) map[string]string { + return map[string]string{ + TopicToRedis: topics.ToRedis.Topic, + TopicToMongo: topics.ToMongo.Topic, + TopicToPush: topics.ToPush.Topic, + TopicToOfflinePush: topics.ToOfflinePush.Topic, + } +} + +func TopicGroupID(topics QueueTopicsConfig) map[string]string { + return map[string]string{ + topics.ToRedis.Topic: topics.ToRedis.GroupID, + topics.ToMongo.Topic: topics.ToMongo.GroupID, + topics.ToPush.Topic: topics.ToPush.GroupID, + topics.ToOfflinePush.Topic: topics.ToOfflinePush.GroupID, } } @@ -44,17 +148,26 @@ func (standaloneBuilder) GetTopicConsumer(ctx context.Context, topic string) (mq type kafkaBuilder struct { addr []string config *kafka.Config + logicalTopic map[string]string topicGroupID map[string]string } func (x *kafkaBuilder) GetTopicProducer(ctx context.Context, topic string) (mq.Producer, error) { - return kafka.NewKafkaProducerV2(x.config, x.addr, topic) + realTopic, ok := x.logicalTopic[topic] + if !ok { + return nil, fmt.Errorf("topic %s not found", topic) + } + return kafka.NewKafkaProducerV2(x.config, x.addr, realTopic) } func (x *kafkaBuilder) GetTopicConsumer(ctx context.Context, topic string) (mq.Consumer, error) { - groupID, ok := x.topicGroupID[topic] + realTopic, ok := x.logicalTopic[topic] if !ok { - return nil, fmt.Errorf("topic %s groupID not found", topic) + return nil, fmt.Errorf("topic %s not found", topic) } - return kafka.NewMConsumerGroupV2(ctx, x.config, groupID, []string{topic}, true) + groupID, ok := x.topicGroupID[realTopic] + if !ok { + return nil, fmt.Errorf("topic %s groupID not found", realTopic) + } + return kafka.NewMConsumerGroupV2(ctx, x.config, groupID, []string{realTopic}, true) } From de0f1eec8a2dd4808dccff01d68685b13006686d Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Tue, 7 Jul 2026 11:27:14 +0800 Subject: [PATCH 31/41] ci: action matrix release (#3761) * ci: serialize release image workflows * feat(build): add single-service Docker build script * chore(ci): remove draft release publishing step # Conflicts: # .github/workflows/update-version-file-on-release.yml --- ...cker-build-and-release-services-images.yml | 54 ++++++++- .github/workflows/publish-docker-image.yml | 25 +++- .github/workflows/release.yml | 56 +++++++++ .../update-version-file-on-release.yml | 113 ++++++++++-------- build/build_single.sh | 105 ++++++++++++++++ 5 files changed, 293 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100755 build/build_single.sh diff --git a/.github/workflows/docker-build-and-release-services-images.yml b/.github/workflows/docker-build-and-release-services-images.yml index 941f83cfa..27b22be31 100644 --- a/.github/workflows/docker-build-and-release-services-images.yml +++ b/.github/workflows/docker-build-and-release-services-images.yml @@ -4,18 +4,52 @@ on: push: branches: - release-* - release: - types: [published] workflow_dispatch: inputs: tag: description: "Tag version to be used for Docker image" required: true default: "v3.8.3" + workflow_call: + inputs: + tag: + description: "Tag version to be used for Docker image" + required: true + type: string + checkout_sha: + description: "Commit SHA to checkout" + required: true + type: string + checkout_short_sha: + description: "Short commit SHA for image tags" + required: true + type: string jobs: - build-and-push: + services: runs-on: ubuntu-latest + outputs: + services: ${{ steps.services.outputs.services }} + steps: + - name: Checkout repository + uses: actions/checkout@v7.0.0 + with: + ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }} + + - name: Resolve service matrix + id: services + run: | + set -euo pipefail + services=$(docker compose -f build/images/openim-server/docker-compose.build.yml config --services | jq -R -s -c 'split("\n") | map(select(length > 0))') + echo "services=$services" >> "$GITHUB_OUTPUT" + + build-and-push: + needs: services + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + service: ${{ fromJson(needs.services.outputs.services) }} permissions: contents: read packages: write @@ -23,6 +57,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v7.0.0 + with: + ref: ${{ inputs.checkout_sha || inputs.tag || github.event.inputs.tag }} - name: Set up QEMU uses: docker/setup-qemu-action@v4.1.0 @@ -53,8 +89,9 @@ jobs: - name: Resolve Docker image tags id: tags env: - INPUT_TAG: ${{ github.event.inputs.tag }} + INPUT_TAG: ${{ inputs.tag || github.event.inputs.tag }} RELEASE_TAG: ${{ github.event.release.tag_name }} + CHECKOUT_SHORT_SHA: ${{ inputs.checkout_short_sha }} run: | set -euo pipefail @@ -84,13 +121,17 @@ jobs: add_tag_with_semver_alias "${INPUT_TAG:-}" add_tag_with_semver_alias "${RELEASE_TAG:-}" + if [[ "${GITHUB_EVENT_NAME:-}" == "release" && "${{ github.event.release.prerelease }}" != "true" ]]; then + add_tag "latest" + fi + if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then add_tag_with_semver_alias "${GITHUB_REF_NAME}" elif [[ "${GITHUB_REF_TYPE:-}" == "branch" ]]; then add_tag "${GITHUB_REF_NAME}" fi - add_tag "sha-${GITHUB_SHA::7}" + add_tag "sha-${CHECKOUT_SHORT_SHA:-${GITHUB_SHA::7}}" { echo "tags</dev/null; then + echo "target_branch must be an existing branch: ${TARGET_BRANCH}" + exit 1 + fi + git checkout -B "${TARGET_BRANCH}" "origin/${TARGET_BRANCH}" + - name: Safe submodule initialization run: | echo "Checking for submodules..." @@ -48,7 +92,6 @@ jobs: run: | if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then git tag -d ${{ env.TAG_VERSION }} - git push --delete origin ${{ env.TAG_VERSION }} fi # Step 4: Update version file @@ -62,58 +105,26 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + set -euo pipefail git add version/version - git commit -m "Update version to ${{ env.TAG_VERSION }}" + if git diff --cached --quiet; then + echo "version/version already matches ${TAG_VERSION}" + else + git commit -m "Update version to ${{ env.TAG_VERSION }}" + git push origin HEAD:${TARGET_BRANCH} + fi # Step 6: Update tag - name: Update tag run: | + set -euo pipefail git tag -fa ${{ env.TAG_VERSION }} -m "Update version to ${{ env.TAG_VERSION }}" - git push origin ${{ env.TAG_VERSION }} --force + git push origin refs/tags/${{ env.TAG_VERSION }}:refs/tags/${{ env.TAG_VERSION }} --force - # Step 7: Find and Publish Draft Release - - name: Find and Publish Draft Release - uses: actions/github-script@v9.0.0 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { owner, repo } = context.repo; - const tagName = process.env.TAG_VERSION; + - name: Resolve updated tag SHA + id: resolve-tag + run: | + updated_sha="$(git rev-parse "${TAG_VERSION}^{commit}")" + echo "updated_sha=$updated_sha" >> "$GITHUB_OUTPUT" + echo "updated_short_sha=${updated_sha:0:12}" >> "$GITHUB_OUTPUT" - try { - let release; - try { - const response = await github.rest.repos.getReleaseByTag({ - owner, - repo, - tag: tagName - }); - release = response.data; - } catch (tagError) { - core.info(`Release not found by tag, searching all releases...`); - const releases = await github.rest.repos.listReleases({ - owner, - repo, - per_page: 100 - }); - - release = releases.data.find(r => r.draft && r.tag_name === tagName); - if (!release) { - throw new Error(`No release found with tag ${tagName}`); - } - } - - await github.rest.repos.updateRelease({ - owner, - repo, - release_id: release.id, - draft: false, - prerelease: release.prerelease - }); - - const status = release.draft ? "was draft" : "was already published"; - core.info(`Release ${tagName} ensured to be published (${status}).`); - - } catch (error) { - core.warning(`Could not find or update release for tag ${tagName}: ${error.message}`); - } diff --git a/build/build_single.sh b/build/build_single.sh new file mode 100755 index 000000000..f5b1e8075 --- /dev/null +++ b/build/build_single.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CYAN='\033[0;36m' +GREEN='\033[0;32m' +RED='\033[0;31m' +NO_COLOR='\033[0m' + +BASE_DIR="$(cd "$(dirname "$0")" && pwd)" +COMPOSE_FILE="$BASE_DIR/images/openim-server/docker-compose.build.yml" +RELEASE="${RELEASE:-false}" +PUSH="${PUSH:-false}" +DRY_RUN="${DRY_RUN:-false}" +PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}" +IMAGE_TAGS="${IMAGE_TAGS:-}" +IMAGE_REGISTRIES="${IMAGE_REGISTRIES:-}" +SERVICE="${SERVICE:-}" + +if [[ ! -f "$COMPOSE_FILE" ]]; then + echo -e "${RED}docker-compose.build.yml not found: $COMPOSE_FILE${NO_COLOR}" + exit 1 +fi + +if [[ -z "$SERVICE" ]]; then + echo -e "${RED}SERVICE is required${NO_COLOR}" + exit 1 +fi + +cd "$BASE_DIR/.." || exit 1 + +split_values() { + echo "$1" | grep -o '[^, ]\+' +} + +run_or_print() { + if [[ "$DRY_RUN" == "true" ]]; then + printf '%q ' "$@" + printf '\n' + else + "$@" + fi +} + +if ! command -v jq >/dev/null 2>&1; then + echo -e "${RED}jq is required${NO_COLOR}" + exit 1 +fi + +if [[ -z "$IMAGE_TAGS" || -z "$IMAGE_REGISTRIES" ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES are required${NO_COLOR}" + exit 1 +fi + +image_tags=() +while IFS= read -r tag; do + image_tags+=("$tag") +done < <(split_values "$IMAGE_TAGS") + +image_registries=() +while IFS= read -r registry; do + image_registries+=("$registry") +done < <(split_values "$IMAGE_REGISTRIES") + +if [[ ${#image_tags[@]} -eq 0 || ${#image_registries[@]} -eq 0 ]]; then + echo -e "${RED}IMAGE_TAGS and IMAGE_REGISTRIES must contain at least one value${NO_COLOR}" + exit 1 +fi + +compose_config=$(docker compose -f "$COMPOSE_FILE" config --format json) + +context=$(jq -r --arg service "$SERVICE" '.services[$service].build.context // empty' <<< "$compose_config") +dockerfile=$(jq -r --arg service "$SERVICE" '.services[$service].build.dockerfile // empty' <<< "$compose_config") +cmd_path=$(jq -r --arg service "$SERVICE" '.services[$service].build.args.CMD_PATH // empty' <<< "$compose_config") +binary_name=$(jq -r --arg service "$SERVICE" '.services[$service].build.args.BINARY_NAME // empty' <<< "$compose_config") + +if [[ -z "$context" || -z "$dockerfile" || -z "$cmd_path" || -z "$binary_name" ]]; then + echo -e "${RED}Invalid build config for $SERVICE${NO_COLOR}" + exit 1 +fi + +if [[ ! -d "$cmd_path" && ! -f "$cmd_path/main.go" ]]; then + echo -e "${CYAN}Skipping $SERVICE because $cmd_path does not exist${NO_COLOR}" + exit 0 +fi + +tag_args=() +for registry in "${image_registries[@]}"; do + for tag in "${image_tags[@]}"; do + tag_args+=(--tag "$registry/$binary_name:$tag") + done +done + +echo -e "${CYAN}Building $binary_name for $PLATFORMS...${NO_COLOR}" +run_or_print docker buildx build \ + --platform "$PLATFORMS" \ + --file "$dockerfile" \ + --build-arg "CMD_PATH=$cmd_path" \ + --build-arg "BINARY_NAME=$binary_name" \ + --build-arg "RELEASE=$RELEASE" \ + "${tag_args[@]}" \ + --push \ + "$context" + +echo -e "${GREEN}Successfully pushed $binary_name${NO_COLOR}" From 2f7561bf49d622af7e47dd4d01fdad204fb2efcd Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Wed, 22 Jul 2026 15:46:44 +0800 Subject: [PATCH 32/41] refactor(core): select discovery backend from configured type (#3773) * refactor(core): select discovery backend from configured type * refactor(core): select discovery backend from configured type * refactor(core): select discovery backend from configured type * refactor(core): select discovery backend from configured type --- .gitignore | 5 +++- pkg/common/discovery/discoveryregister.go | 28 ++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 77cf855b7..1b5cf874d 100644 --- a/.gitignore +++ b/.gitignore @@ -387,4 +387,7 @@ Sessionx.vim # End of https://www.toptal.com/developers/gitignore/api/go,git,vim,tags,test,emacs,backup,jetbrains .idea -dist/ \ No newline at end of file +dist/ + +.omo +.sisyphus \ No newline at end of file diff --git a/pkg/common/discovery/discoveryregister.go b/pkg/common/discovery/discoveryregister.go index 29ed5929f..3e053775b 100644 --- a/pkg/common/discovery/discoveryregister.go +++ b/pkg/common/discovery/discoveryregister.go @@ -15,13 +15,14 @@ package discovery import ( + "strings" "time" "google.golang.org/grpc" "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/tools/discovery" - "github.com/openimsdk/tools/discovery/inprocess" + "github.com/openimsdk/tools/discovery/standalone" "github.com/openimsdk/tools/utils/runtimeenv" "github.com/openimsdk/tools/discovery/kubernetes" @@ -33,17 +34,28 @@ import ( // NewDiscoveryRegister creates a new service discovery and registry client based on the provided environment type. func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (discovery.SvcDiscoveryRegistry, error) { if config.Standalone() { - return inprocess.GetSvcDiscoveryRegistry(), nil + return standalone.GetSvcDiscoveryRegistry(), nil } - if runtimeenv.RuntimeEnvironment() == config.KUBERNETES { - return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, nil, + + runtimeEnvironment := runtimeenv.RuntimeEnvironment() + discoveryType := discovery.Enable + if discoveryType == "" && runtimeEnvironment == config.KUBERNETES { + discoveryType = config.KUBERNETES + } + if discoveryType == config.KUBERNETES && runtimeEnvironment != config.KUBERNETES { + return nil, errs.New("unsupported discovery type", "type", discoveryType).Wrap() + } + switch discoveryType { + case config.KUBERNETES: + for i := range watchNames { + watchNames[i] = strings.Split(watchNames[i], ":")[0] + } + return kubernetes.NewConnManager(discovery.Kubernetes.Namespace, watchNames, grpc.WithDefaultCallOptions( grpc.MaxCallSendMsgSize(1024*1024*20), ), + grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`), ) - } - - switch discovery.Enable { case config.ETCD: return etcd.NewSvcDiscoveryRegistry( discovery.Etcd.RootDirectory, @@ -53,6 +65,6 @@ func NewDiscoveryRegister(discovery *config.Discovery, watchNames []string) (dis etcd.WithMaxCallSendMsgSize(20*1024*1024), etcd.WithUsernameAndPassword(discovery.Etcd.Username, discovery.Etcd.Password)) default: - return nil, errs.New("unsupported discovery type", "type", discovery.Enable).Wrap() + return nil, errs.New("unsupported discovery type", "type", discoveryType).Wrap() } } From 193870b2f938278b27a2d8347bd7e4db5f8f9dfc Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Tue, 4 Aug 2026 15:19:40 +0800 Subject: [PATCH 33/41] fix(core): enforce admin access for queries (#3781) --- internal/rpc/group/group.go | 6 +++++- internal/rpc/user/user.go | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index cc51fdf18..46bd59867 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -23,9 +23,10 @@ import ( "strings" "time" - "github.com/openimsdk/tools/utils/stringutil" "google.golang.org/grpc" + "github.com/openimsdk/tools/utils/stringutil" + "github.com/openimsdk/open-im-server/v3/pkg/dbbuild" "github.com/openimsdk/open-im-server/v3/pkg/rpcli" @@ -1315,6 +1316,9 @@ func (g *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans } func (g *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) { + if err := authverify.CheckAdmin(ctx); err != nil { + return nil, err + } var ( group []*model.Group err error diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 91dfe736e..82a8212bb 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -22,6 +22,8 @@ import ( "sync" "time" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/internal/rpc/relation" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" @@ -46,7 +48,6 @@ import ( "github.com/openimsdk/tools/discovery" "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/utils/datautil" - "google.golang.org/grpc" ) const ( @@ -268,6 +269,9 @@ func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckR } func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPaginationUsersReq) (resp *pbuser.GetPaginationUsersResp, err error) { + if err = authverify.CheckAdmin(ctx); err != nil { + return nil, err + } if req.UserID == "" && req.NickName == "" { total, users, err := s.db.PageFindUser(ctx, constant.IMOrdinaryUser, constant.AppOrdinaryUsers, req.Pagination) if err != nil { @@ -353,6 +357,9 @@ func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Ge // GetAllUserID Get user account by page. func (s *userServer) GetAllUserID(ctx context.Context, req *pbuser.GetAllUserIDReq) (resp *pbuser.GetAllUserIDResp, err error) { + if err = authverify.CheckAdmin(ctx); err != nil { + return nil, err + } total, userIDs, err := s.db.GetAllUserID(ctx, req.Pagination) if err != nil { return nil, err From 676ad0f02e260dda7d7ac5648667efcdacc3e51b Mon Sep 17 00:00:00 2001 From: Leo225 Date: Tue, 4 Aug 2026 19:06:03 +0800 Subject: [PATCH 34/41] refactor(tests): simplify loop constructs in compressor tests and benchmarks (#3776) --- internal/msggateway/compressor_test.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/internal/msggateway/compressor_test.go b/internal/msggateway/compressor_test.go index 952bd4d95..e3af70ca4 100644 --- a/internal/msggateway/compressor_test.go +++ b/internal/msggateway/compressor_test.go @@ -32,7 +32,7 @@ func TestCompressDecompress(t *testing.T) { compressor := NewGzipCompressor() - for i := 0; i < 2000; i++ { + for range 2000 { src := mockRandom() // compress @@ -58,10 +58,8 @@ func TestCompressDecompressWithConcurrency(t *testing.T) { wg := sync.WaitGroup{} compressor := NewGzipCompressor() - for i := 0; i < 200; i++ { - wg.Add(1) - go func() { - defer wg.Done() + for range 200 { + wg.Go(func() { src := mockRandom() // compress @@ -80,8 +78,7 @@ func TestCompressDecompressWithConcurrency(t *testing.T) { // check assert.EqualValues(t, src, res) - - }() + }) } wg.Wait() } @@ -90,7 +87,7 @@ func BenchmarkCompress(b *testing.B) { src := mockRandom() compressor := NewGzipCompressor() - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := compressor.Compress(src) assert.Equal(b, nil, err) } @@ -100,7 +97,7 @@ func BenchmarkCompressWithSyncPool(b *testing.B) { src := mockRandom() compressor := NewGzipCompressor() - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := compressor.CompressWithPool(src) assert.Equal(b, nil, err) } @@ -114,7 +111,7 @@ func BenchmarkDecompress(b *testing.B) { assert.Equal(b, nil, err) - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := compressor.DeCompress(comdata) assert.Equal(b, nil, err) } @@ -127,7 +124,7 @@ func BenchmarkDecompressWithSyncPool(b *testing.B) { comdata, err := compressor.Compress(src) assert.Equal(b, nil, err) - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := compressor.DecompressWithPool(comdata) assert.Equal(b, nil, err) } From defc929ef85792708287ae601fd96b56064f5de1 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Wed, 26 Aug 2026 03:23:57 +0000 Subject: [PATCH 35/41] fix(core): filter invalid and outdated conversation messages (#3791) --- internal/api/jssdk/jssdk.go | 41 +++++++++++++++++----------- pkg/common/storage/controller/msg.go | 19 +++++++++++++ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/internal/api/jssdk/jssdk.go b/internal/api/jssdk/jssdk.go index 0d30b1ea0..e3f78c929 100644 --- a/internal/api/jssdk/jssdk.go +++ b/internal/api/jssdk/jssdk.go @@ -143,14 +143,16 @@ func (x *JSSdk) getActiveConversations(ctx context.Context, req *jssdk.GetActive if err != nil { return nil, err } - msgs, err := x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, datautil.Slice(sortList, func(c *msg.ActiveConversation) *msg.ConversationSeqs { - return &msg.ConversationSeqs{ - ConversationID: c.ConversationID, - Seqs: []int64{c.MaxSeq}, + maxSeqs := datautil.SliceToMapAny(sortList, func(c *msg.ActiveConversation) (string, int64) { + return c.ConversationID, c.MaxSeq + }) + conversationSeqs := x.filterConversationSeqs(conversations, maxSeqs) + var msgs map[string]*sdkws.PullMsgs + if len(conversationSeqs) > 0 { + msgs, err = x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, conversationSeqs) + if err != nil { + return nil, err } - })) - if err != nil { - return nil, err } x.checkMessagesAndGetLastMessage(ctx, req.OwnerUserID, msgs) conversationMap := datautil.SliceToMap(conversations, func(c *conversation.Conversation) string { @@ -208,15 +210,7 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation if err != nil { return nil, err } - conversationSeqs := make([]*msg.ConversationSeqs, 0, len(conversations)) - for _, c := range conversations { - if seq := maxSeqs[c.ConversationID]; seq > 0 { - conversationSeqs = append(conversationSeqs, &msg.ConversationSeqs{ - ConversationID: c.ConversationID, - Seqs: []int64{seq}, - }) - } - } + conversationSeqs := x.filterConversationSeqs(conversations, maxSeqs) var msgs map[string]*sdkws.PullMsgs if len(conversationSeqs) > 0 { msgs, err = x.msgClient.GetSeqMessage(ctx, req.OwnerUserID, conversationSeqs) @@ -253,6 +247,21 @@ func (x *JSSdk) getConversations(ctx context.Context, req *jssdk.GetConversation }, nil } +func (x *JSSdk) filterConversationSeqs(conversations []*conversation.Conversation, maxSeqs map[string]int64) []*msg.ConversationSeqs { + conversationSeqs := make([]*msg.ConversationSeqs, 0, len(conversations)) + for _, c := range conversations { + seq := maxSeqs[c.ConversationID] + if seq == 0 || (c.MinSeq > 0 && seq < c.MinSeq) { + continue + } + conversationSeqs = append(conversationSeqs, &msg.ConversationSeqs{ + ConversationID: c.ConversationID, + Seqs: []int64{seq}, + }) + } + return conversationSeqs +} + // This function checks whether the latest MaxSeq message is valid. // If not, it needs to fetch a valid message again. func (x *JSSdk) checkMessagesAndGetLastMessage(ctx context.Context, userID string, messages map[string]*sdkws.PullMsgs) { diff --git a/pkg/common/storage/controller/msg.go b/pkg/common/storage/controller/msg.go index f833008e8..6500dbd1e 100644 --- a/pkg/common/storage/controller/msg.go +++ b/pkg/common/storage/controller/msg.go @@ -835,6 +835,25 @@ func (db *commonMsgDatabase) GetLastMessage(ctx context.Context, conversationIDs } return nil, err } + if msg == nil || msg.Msg == nil { + continue + } + if userID != "" { + userMinSeq, err := db.seqUser.GetUserMinSeq(ctx, conversationID, userID) + if err != nil { + return nil, err + } + minSeq, err := db.seqConversation.GetMinSeq(ctx, conversationID) + if err != nil { + return nil, err + } + if userMinSeq > minSeq { + minSeq = userMinSeq + } + if msg.Msg.Seq < minSeq { + continue + } + } tmp := []*model.MsgInfoModel{msg} db.handlerDeleteAndRevoked(ctx, userID, tmp) db.handlerQuote(ctx, userID, conversationID, tmp) From 175a7bb0673eca18e9d1b10bff4f728da6b1b513 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Mon, 31 Aug 2026 03:40:46 +0000 Subject: [PATCH 36/41] fix(core): trigger after-join webhooks for invited members (#3796) --- internal/rpc/group/callback.go | 13 +++++++++++++ internal/rpc/group/group.go | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index 8ed4afe5a..0898da0f5 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -287,6 +287,19 @@ func (g *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.A g.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterJoinGroupResp{}, after) } +func afterJoinGroupRequests(members []*model.GroupMember, reqMessage string) []*group.JoinGroupReq { + requests := make([]*group.JoinGroupReq, 0, len(members)) + for _, member := range members { + requests = append(requests, &group.JoinGroupReq{ + GroupID: member.GroupID, + ReqMessage: reqMessage, + JoinSource: member.JoinSource, + InviterUserID: member.UserID, + }) + } + return requests +} + func (g *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupInfoReq) error { return webhook.WithCondition(ctx, before, func(ctx context.Context) error { cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{ diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 46bd59867..4c6ecc38b 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -478,6 +478,9 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite if err := g.setMemberJoinSeq(ctx, req.GroupID, req.InvitedUserIDs); err != nil { return nil, err } + for _, joinReq := range afterJoinGroupRequests(groupMembers, req.Reason) { + g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, joinReq) + } return &pbgroup.InviteUserToGroupResp{}, nil } @@ -914,6 +917,9 @@ func (g *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup if err := g.setMemberJoinSeq(ctx, req.GroupID, []string{req.FromUserID}); err != nil { return nil, err } + for _, joinReq := range afterJoinGroupRequests([]*model.GroupMember{member}, groupRequest.ReqMsg) { + g.webhookAfterJoinGroup(ctx, &g.config.WebhooksConfig.AfterJoinGroup, joinReq) + } } case constant.GroupResponseRefuse: g.notification.GroupApplicationRejectedNotification(ctx, req) From 3b9890bf13f124d5f266752d40e8c14e958d2044 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Sat, 10 Oct 2026 08:07:20 +0000 Subject: [PATCH 37/41] fix(core): update MinIO and etcd images and configure auth (#3811) * fix(core): update MinIO and etcd images and configure auth * fix(core): configure etcd and MinIO permissions --- .env | 4 +- docker-compose.yml | 127 ++++++++++++++++++++++----------------------- 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/.env b/.env index c12937405..d3fd8a6f4 100644 --- a/.env +++ b/.env @@ -1,8 +1,8 @@ MONGO_IMAGE=mongo:7.0 REDIS_IMAGE=redis:7.0.0 KAFKA_IMAGE=bitnamilegacy/kafka:3.5.1 -MINIO_IMAGE=minio/minio:RELEASE.2024-01-11T07-46-16Z -ETCD_IMAGE=bitnamilegacy/etcd:3.5.13 +MINIO_IMAGE=bitnamilegacy/minio:2024.1.13 +ETCD_IMAGE=bitnamilegacy/etcd:3.5.21 PROMETHEUS_IMAGE=prom/prometheus:v2.45.6 ALERTMANAGER_IMAGE=prom/alertmanager:v0.27.0 GRAFANA_IMAGE=grafana/grafana:11.0.1 diff --git a/docker-compose.yml b/docker-compose.yml index 92eadf237..2b5875d71 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,6 +74,7 @@ services: etcd: image: "${ETCD_IMAGE}" + user: root container_name: etcd ports: - "12379:2379" @@ -81,6 +82,8 @@ services: environment: - ETCD_NAME=s1 - ETCD_DATA_DIR=/etcd-data + # Authentication is managed below; no-auth requires a trusted, isolated network. + - ALLOW_NONE_AUTHENTICATION=yes - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 - ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379 - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 @@ -88,7 +91,6 @@ services: - ETCD_INITIAL_CLUSTER=s1=http://0.0.0.0:2380 - ETCD_INITIAL_CLUSTER_TOKEN=tkn - ETCD_INITIAL_CLUSTER_STATE=new - - ALLOW_NONE_AUTHENTICATION=no ## Optional: Enable etcd authentication by setting the following credentials # - ETCD_ROOT_USER=root @@ -97,74 +99,70 @@ services: # - ETCD_PASSWORD=openIM123 volumes: - "${DATA_DIR}/components/etcd:/etcd-data" - command: > - /bin/sh -c ' - etcd & - export ETCDCTL_API=3 - echo "Waiting for etcd to become healthy..." - until etcdctl --endpoints=http://127.0.0.1:2379 endpoint health &>/dev/null; do - echo "Waiting for ETCD to start..." + command: + - /bin/sh + - -c + - | + set -eu + fail() { echo "$$*" >&2; exit 1; } + auth=no + if [ -n "$${ETCD_ROOT_USER:-}$${ETCD_ROOT_PASSWORD:-}$${ETCD_USERNAME:-}$${ETCD_PASSWORD:-}" ]; then + [ -n "$${ETCD_ROOT_USER:-}" ] && [ -n "$${ETCD_ROOT_PASSWORD:-}" ] && [ -n "$${ETCD_USERNAME:-}" ] && [ -n "$${ETCD_PASSWORD:-}" ] || fail "Set all four authentication variables or leave all four empty." + [ "$$ETCD_ROOT_USER" = root ] && [ "$$ETCD_USERNAME" != root ] || fail "etcd requires ETCD_ROOT_USER=root and a separate application user." + auth=yes + fi + [ -d /etcd-data ] && [ -w /etcd-data ] && [ -x /etcd-data ] || fail "/etcd-data must be writable and searchable." + (unset ETCD_ROOT_USER ETCD_ROOT_PASSWORD ETCD_USERNAME ETCD_PASSWORD; ETCD_DATA_DIR=/etcd-data exec etcd) & + daemon=$$! + cleanup() { + trap - EXIT TERM INT + kill -"$${signal:-TERM}" "$$daemon" 2>/dev/null || : + wait "$$daemon" 2>/dev/null || : + } + trap cleanup EXIT + trap "signal=TERM; exit 143" TERM + trap "signal=INT; exit 130" INT + export ETCDCTL_API=3 ETCDCTL_ENDPOINTS=http://127.0.0.1:2379 + export ETCDCTL_DIAL_TIMEOUT=2s ETCDCTL_COMMAND_TIMEOUT=2s + unset ETCDCTL_USER ETCDCTL_PASSWORD + attempts=0 + until etcdctl endpoint status >/dev/null 2>&1; do + kill -0 "$$daemon" 2>/dev/null || { wait "$$daemon"; exit $$?; } + attempts=$$((attempts + 1)) + [ "$$attempts" -lt 30 ] || fail "etcd startup timed out." sleep 1 done - - echo "etcd is healthy." - - if [ -n "$${ETCD_ROOT_USER}" ] && [ -n "$${ETCD_ROOT_PASSWORD}" ] && [ -n "$${ETCD_USERNAME}" ] && [ -n "$${ETCD_PASSWORD}" ]; then - echo "Authentication credentials provided. Setting up authentication..." - - echo "Checking authentication status..." - if ! etcdctl --endpoints=http://127.0.0.1:2379 auth status | grep -q "Authentication Status: true"; then - echo "Authentication is disabled. Creating users and enabling..." - - # Create users and setup permissions - etcdctl --endpoints=http://127.0.0.1:2379 user add $${ETCD_ROOT_USER} --new-user-password=$${ETCD_ROOT_PASSWORD} || true - etcdctl --endpoints=http://127.0.0.1:2379 user add $${ETCD_USERNAME} --new-user-password=$${ETCD_PASSWORD} || true - - etcdctl --endpoints=http://127.0.0.1:2379 role add openim-role || true - etcdctl --endpoints=http://127.0.0.1:2379 role grant-permission openim-role --prefix=true readwrite / || true - etcdctl --endpoints=http://127.0.0.1:2379 role grant-permission openim-role --prefix=true readwrite "" || true - etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_USERNAME} openim-role || true - - etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_ROOT_USER} $${ETCD_USERNAME} root || true - - echo "Enabling authentication..." - etcdctl --endpoints=http://127.0.0.1:2379 auth enable - echo "Authentication enabled successfully" - else - echo "Authentication is already enabled. Checking OpenIM user..." - - # Check if openIM user exists and can perform operations - if ! etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} put /test/auth "auth-check" &>/dev/null; then - echo "OpenIM user test failed. Recreating user with root credentials..." - - # Try to create/update the openIM user using root credentials - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} user add $${ETCD_USERNAME} --new-user-password=$${ETCD_PASSWORD} --no-password-file || true - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role add openim-role || true - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role grant-permission openim-role --prefix=true readwrite / || true - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} role grant-permission openim-role --prefix=true readwrite "" || true - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_ROOT_USER}:$${ETCD_ROOT_PASSWORD} user grant-role $${ETCD_USERNAME} openim-role || true - etcdctl --endpoints=http://127.0.0.1:2379 user grant-role $${ETCD_ROOT_USER} $${ETCD_USERNAME} root || true - - echo "OpenIM user recreated with required permissions" + if [ "$$auth" = yes ]; then + export ETCDCTL_USER="$$ETCD_ROOT_USER" ETCDCTL_PASSWORD="$$ETCD_ROOT_PASSWORD" + fi + status=$$(etcdctl auth status) || fail "Cannot verify authentication; check configured credentials." + case "$$status" in + *"Authentication Status: false"*) + if [ "$$auth" = yes ]; then + users=$$(etcdctl user list) + [ -z "$$users" ] || fail "Existing users with disabled authentication require manual review." + printf "%s\n%s\n" "$$ETCD_ROOT_PASSWORD" "$$ETCD_ROOT_PASSWORD" | etcdctl user add root >/dev/null + printf "%s\n%s\n" "$$ETCD_PASSWORD" "$$ETCD_PASSWORD" | etcdctl user add "$$ETCD_USERNAME" >/dev/null + etcdctl role add openim-role + etcdctl role grant-permission openim-role --prefix readwrite "" + etcdctl user grant-role "$$ETCD_USERNAME" openim-role + etcdctl user grant-role root root + etcdctl auth enable else - echo "OpenIM user exists and has correct permissions" - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} del /test/auth &>/dev/null + echo "etcd authentication is explicitly disabled; restrict access to the published ports." fi + ;; + *"Authentication Status: true"*) + [ "$$auth" = yes ] || fail "Existing authentication requires configured credentials." + ;; + *) fail "Could not determine authentication status." ;; + esac + if [ "$$auth" = yes ]; then + etcdctl user get root >/dev/null + ETCDCTL_USER="$$ETCD_USERNAME" ETCDCTL_PASSWORD="$$ETCD_PASSWORD" etcdctl get /check_openim_component >/dev/null fi - echo "Testing authentication with OpenIM user..." - if etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} put /test/auth "auth-works"; then - echo "Authentication working properly" - etcdctl --endpoints=http://127.0.0.1:2379 --user=$${ETCD_USERNAME}:$${ETCD_PASSWORD} del /test/auth - else - echo "WARNING: Authentication test failed" - fi - else - echo "No authentication credentials provided. Running in no-auth mode." - echo "To enable authentication, set ETCD_ROOT_USER, ETCD_ROOT_PASSWORD, ETCD_USERNAME, and ETCD_PASSWORD environment variables." - fi - - tail -f /dev/null - ' + echo "etcd startup complete." + wait "$$daemon" restart: always networks: - openim @@ -241,6 +239,7 @@ services: minio: image: "${MINIO_IMAGE}" + user: root ports: - "10005:9000" - "19090:9090" From 7788c8672143e4f3d10f38a0c24058fc9520af1e Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Mon, 12 Oct 2026 08:40:45 +0000 Subject: [PATCH 38/41] fix(core): publish multi-architecture images to ACR (#3814) Add ACR-specific build and push steps to the Docker workflows while filtering ACR tags from the primary registry push. --- ...cker-build-and-release-services-images.yml | 13 +++++- .github/workflows/publish-docker-image.yml | 45 ++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-build-and-release-services-images.yml b/.github/workflows/docker-build-and-release-services-images.yml index 27b22be31..74ab8f0e8 100644 --- a/.github/workflows/docker-build-and-release-services-images.yml +++ b/.github/workflows/docker-build-and-release-services-images.yml @@ -149,6 +149,17 @@ jobs: IMAGE_REGISTRIES: | ${{ secrets.DOCKER_USERNAME }} ghcr.io/${{ github.repository_owner }} - registry.cn-hangzhou.aliyuncs.com/openimsdk + run: | + bash build/build_single.sh + + - name: Build and push Docker images to ACR + env: + BUILDX_NO_DEFAULT_ATTESTATIONS: '1' + RELEASE: "true" + PUSH: "true" + SERVICE: ${{ matrix.service }} + PLATFORMS: linux/amd64,linux/arm64 + IMAGE_TAGS: ${{ steps.tags.outputs.tags }} + IMAGE_REGISTRIES: registry.cn-hangzhou.aliyuncs.com/openimsdk run: | bash build/build_single.sh diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 8e2847d62..ca147f7eb 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -173,13 +173,46 @@ jobs: - name: Push multi-architecture images if: success() + env: + IMAGE_TAGS: ${{ steps.meta.outputs.tags }} run: | - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - $(echo "${{ steps.meta.outputs.tags }}" | sed 's/,/ --tag /g' | sed 's/^/--tag /') \ - --cache-from type=local,src=/tmp/docker-cache \ - --push \ - ./main-repo + set -euo pipefail + tag_args=() + while IFS= read -r tag; do + [[ -n "$tag" ]] || continue + [[ "${tag%%/*}" != *.aliyuncs.com ]] || continue + tag_args+=(--tag "$tag") + done < <(printf '%s\n' "$IMAGE_TAGS" | tr ',' '\n') + + if [[ ${#tag_args[@]} -gt 0 ]]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + "${tag_args[@]}" \ + --cache-from type=local,src=/tmp/docker-cache \ + --push ./main-repo + fi + + - name: Push multi-architecture images to ACR + if: success() + env: + BUILDX_NO_DEFAULT_ATTESTATIONS: '1' + IMAGE_TAGS: ${{ steps.meta.outputs.tags }} + run: | + set -euo pipefail + tag_args=() + while IFS= read -r tag; do + [[ -n "$tag" ]] || continue + [[ "${tag%%/*}" == *.aliyuncs.com ]] || continue + tag_args+=(--tag "$tag") + done < <(printf '%s\n' "$IMAGE_TAGS" | tr ',' '\n') + + if [[ ${#tag_args[@]} -gt 0 ]]; then + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + "${tag_args[@]}" \ + --cache-from type=local,src=/tmp/docker-cache \ + --push ./main-repo + fi - name: Verify multi-platform support run: | From a5b427a3d6c051697bd4c94d26ba48bf91811714 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Fri, 16 Oct 2026 08:34:22 +0000 Subject: [PATCH 39/41] fix(core): force to replace send time when malloc seq (#3817) * fix(core): force to replace send time when malloc seq # Conflicts: # pkg/common/storage/controller/msg_transfer.go # Conflicts: # pkg/common/storage/controller/msg_transfer.go * refactor(core): reorder message transfer imports --- pkg/common/storage/controller/msg_transfer.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/common/storage/controller/msg_transfer.go b/pkg/common/storage/controller/msg_transfer.go index 28392d66e..8a8d9e7d2 100644 --- a/pkg/common/storage/controller/msg_transfer.go +++ b/pkg/common/storage/controller/msg_transfer.go @@ -2,21 +2,22 @@ package controller import ( "context" + "time" - "github.com/openimsdk/open-im-server/v3/pkg/common/convert" - "github.com/openimsdk/protocol/constant" - "github.com/openimsdk/tools/mq" - "github.com/openimsdk/tools/utils/datautil" + "go.mongodb.org/mongo-driver/mongo" "google.golang.org/protobuf/proto" + "github.com/openimsdk/open-im-server/v3/pkg/common/convert" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" + "github.com/openimsdk/protocol/constant" pbmsg "github.com/openimsdk/protocol/msg" "github.com/openimsdk/protocol/sdkws" "github.com/openimsdk/tools/errs" "github.com/openimsdk/tools/log" - "go.mongodb.org/mongo-driver/mongo" + "github.com/openimsdk/tools/mq" + "github.com/openimsdk/tools/utils/datautil" ) type MsgTransferDatabase interface { @@ -206,6 +207,8 @@ func (db *msgTransferDatabase) BatchInsertChat2Cache(ctx context.Context, conver if lenList < 1 { return 0, false, nil, errs.New("no messages to insert", "minCount", 1).Wrap() } + //force to lead time as same + sendTime := time.Now().UnixMilli() currentMaxSeq, err := db.seqConversation.Malloc(ctx, conversationID, int64(len(msgs))) if err != nil { log.ZError(ctx, "storage.seq.Malloc", err) @@ -218,6 +221,7 @@ func (db *msgTransferDatabase) BatchInsertChat2Cache(ctx context.Context, conver for _, m := range msgs { currentMaxSeq++ m.Seq = currentMaxSeq + m.SendTime = sendTime userSeqMap[m.SendID] = m.Seq seqs = append(seqs, m.Seq) } From e3a08b844c2cea4ebcd40baf3f374bb2f659ad9b Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Mon, 26 Oct 2026 06:34:41 +0000 Subject: [PATCH 40/41] refactor(core): update Mage build and start task APIs (#3821) --- go.mod | 65 ++++---- go.sum | 143 ++++++++++-------- internal/push/onlinepusher.go | 79 +--------- magefile.go | 91 +++++------ magefile_unix.go | 21 --- magefile_windows.go | 8 - pkg/common/discovery/direct/directconn.go | 4 - pkg/common/discovery/kubernetes/kubernetes.go | 4 - start-config.yml | 4 +- 9 files changed, 158 insertions(+), 261 deletions(-) delete mode 100644 magefile_unix.go delete mode 100644 magefile_windows.go diff --git a/go.mod b/go.mod index 8a8dae98f..07ddc3d26 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openimsdk/open-im-server/v3 -go 1.25.0 +go 1.26.0 require ( firebase.google.com/go/v4 v4.14.1 @@ -13,14 +13,13 @@ require ( github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/openimsdk/protocol v0.0.73-alpha.19 - github.com/openimsdk/tools v0.0.50-alpha.121 - github.com/pkg/errors v0.9.1 // indirect + github.com/openimsdk/tools v0.0.50-alpha.126 github.com/prometheus/client_golang v1.18.0 - github.com/stretchr/testify v1.11.1 + github.com/stretchr/testify v1.12.1 go.mongodb.org/mongo-driver v1.14.0 google.golang.org/api v0.170.0 google.golang.org/grpc v1.79.3 - google.golang.org/protobuf v1.36.10 + google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 ) @@ -35,20 +34,23 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/kelindar/bitmap v1.5.2 github.com/likexian/gokit v0.25.13 - github.com/openimsdk/gomake v0.0.17 + github.com/openimsdk/gomake v0.0.19 github.com/redis/go-redis/v9 v9.4.0 github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/viper v1.18.2 go.etcd.io/etcd/client/v3 v3.5.13 go.uber.org/automaxprocs v1.5.3 - golang.org/x/sync v0.20.0 + golang.org/x/sync v0.24.0 k8s.io/api v0.31.2 k8s.io/apimachinery v0.31.2 k8s.io/client-go v0.31.2 ) require ( + atomicgo.dev/cursor v0.2.0 // indirect + atomicgo.dev/keyboard v0.2.10 // indirect + atomicgo.dev/schedule v0.1.0 // indirect cloud.google.com/go v0.112.1 // indirect cloud.google.com/go/compute/metadata v0.9.0 // indirect cloud.google.com/go/firestore v1.15.0 // indirect @@ -76,13 +78,15 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect github.com/aws/smithy-go v1.22.1 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect + github.com/bmatcuk/doublestar/v4 v4.10.3 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj v1.8.4 // indirect + github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect + github.com/containerd/console v1.0.5 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -91,7 +95,7 @@ require ( github.com/eapache/go-resiliency v1.6.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect - github.com/ebitengine/purego v0.10.0 // indirect + github.com/ebitengine/purego v0.11.2 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect @@ -105,8 +109,8 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-zookeeper/zk v1.0.3 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/go-zookeeper/zk v1.0.4 // indirect + github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect @@ -132,16 +136,19 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kelindar/simd v1.1.2 // indirect - github.com/klauspost/compress v1.17.7 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/klauspost/compress v1.20.3 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect + github.com/klauspost/pgzip v1.2.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/lestrrat-go/strftime v1.0.6 // indirect + github.com/lestrrat-go/strftime v1.2.0 // indirect + github.com/lithammer/fuzzysearch v1.1.8 // indirect github.com/lithammer/shortuuid v3.0.0+incompatible // indirect - github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 // indirect - github.com/magefile/mage v1.15.0 // indirect + github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect + github.com/magefile/mage v1.17.2 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-runewidth v0.0.31 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/minio-go/v7 v7.0.69 // indirect @@ -153,11 +160,11 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect + github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect + github.com/pterm/pterm v0.12.84 // indirect github.com/qiniu/go-sdk/v7 v7.18.2 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/xid v1.5.0 // indirect @@ -165,17 +172,17 @@ require ( github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sercand/kuberesolver/v6 v6.0.1 // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect - github.com/shirou/gopsutil/v4 v4.26.2 // indirect + github.com/shirou/gopsutil/v4 v4.26.9 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.5.2 // indirect + github.com/stretchr/objx v0.5.3 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect - github.com/tklauser/go-sysconf v0.3.16 // indirect - github.com/tklauser/numcpus v0.11.0 // indirect + github.com/tklauser/go-sysconf v0.4.0 // indirect + github.com/tklauser/numcpus v0.12.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect @@ -192,16 +199,16 @@ require ( go.opentelemetry.io/otel v1.39.0 // indirect go.opentelemetry.io/otel/metric v1.39.0 // indirect go.opentelemetry.io/otel/trace v1.39.0 // indirect - go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.11.0 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/arch v0.7.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/image v0.39.0 // indirect - golang.org/x/net v0.55.0 // indirect + golang.org/x/net v0.56.0 // indirect golang.org/x/oauth2 v0.34.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/term v0.43.0 // indirect - golang.org/x/text v0.37.0 // indirect + golang.org/x/sys v0.49.0 // indirect + golang.org/x/term v0.47.0 // indirect + golang.org/x/text v0.43.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine/v2 v2.0.2 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect @@ -224,7 +231,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/spf13/cobra v1.8.0 github.com/ugorji/go/codec v1.2.12 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.52.0 // indirect + go.uber.org/zap v1.28.0 // indirect + golang.org/x/crypto v0.53.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 5d0c9e012..363b2cd4e 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,11 @@ +atomicgo.dev/assert v0.0.2 h1:FiKeMiZSgRrZsPo9qn/7vmr7mCsh5SZyXY4YGYiYwrg= +atomicgo.dev/assert v0.0.2/go.mod h1:ut4NcI3QDdJtlmAxQULOmA13Gz6e2DWbSAS8RUOmNYQ= +atomicgo.dev/cursor v0.2.0 h1:H6XN5alUJ52FZZUkI7AlJbUc1aW38GWZalpYRPpoPOw= +atomicgo.dev/cursor v0.2.0/go.mod h1:Lr4ZJB3U7DfPPOkbH7/6TOtJ4vFGHlgj1nc+n900IpU= +atomicgo.dev/keyboard v0.2.10 h1:v7mvUKUZLHIggxULEIuWbT+WkkyQSgdbA201EziAhHU= +atomicgo.dev/keyboard v0.2.10/go.mod h1:ap/z5ilnhLqYq852m6kPeTq5Z6aESGWu5mzRpJlC6aI= +atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs= +atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= @@ -16,6 +24,8 @@ firebase.google.com/go/v4 v4.14.1/go.mod h1:fgk2XshgNDEKaioKco+AouiegSI9oTWVqRaB github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/sarama v1.43.0 h1:YFFDn8mMI2QL0wOrG0J2sFoVIAFl7hS9JQi2YZsXtJc= github.com/IBM/sarama v1.43.0/go.mod h1:zlE6HEbC/SMQ9mhEYaF7nNLYOUyrs0obySKCckWP9BM= +github.com/MarvinJWendt/testza v0.5.2 h1:53KDo64C1z/h/d/stCYCPY69bt/OSwjq5KpFNwi+zB4= +github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc4n3EjyIYvEY= github.com/MicahParks/keyfunc v1.9.0 h1:lhKd5xrFHLNOWrDc4Tyb/Q1AJ4LCzQ48GVJyVIID3+o= github.com/MicahParks/keyfunc v1.9.0/go.mod h1:IdnCilugA0O/99dW+/MkvlyrsX8+L8+x95xuVNtM5jw= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= @@ -57,12 +67,10 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLb github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg= github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs= -github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bmatcuk/doublestar/v4 v4.10.3 h1:1UIv1+fqH3++ViVkpnaPTB+Pi1UHycnPFAq14zgK+gI= +github.com/bmatcuk/doublestar/v4 v4.10.3/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= @@ -77,6 +85,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= +github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= @@ -84,6 +94,8 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5 h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w= github.com/cncf/xds/go v0.0.0-20251210132809-ee656c7534f5/go.mod h1:KdCmV+x/BuvyMxRnYBlmVaq4OLiKW6iRQfvC62cvdkI= +github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc= +github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -107,8 +119,8 @@ 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/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU= -github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/ebitengine/purego v0.11.2 h1:WWiTx8rD8zYdOwSj8O/NiNbsOvSAgJMTlyV1XlbUSeU= +github.com/ebitengine/purego v0.11.2/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -175,8 +187,8 @@ github.com/go-redis/redismock/v9 v9.2.0 h1:ZrMYQeKPECZPjOj5u9eyOjg8Nnb0BS9lkVIZ6 github.com/go-redis/redismock/v9 v9.2.0/go.mod h1:18KHfGDK4Y6c2R0H38EUGWAdc7ZQS9gfYxc94k7rWT0= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg= -github.com/go-zookeeper/zk v1.0.3/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= +github.com/go-zookeeper/zk v1.0.4 h1:DPzxraQx7OrPyXq2phlGlNSIyWEsAox0RJmjTseMV6I= +github.com/go-zookeeper/zk v1.0.4/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -187,8 +199,8 @@ github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXe github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -274,8 +286,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= -github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= +github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I= +github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -286,12 +298,14 @@ github.com/kelindar/simd v1.1.2 h1:KduKb+M9cMY2HIH8S/cdJyD+5n5EGgq+Aeeleos55To= github.com/kelindar/simd v1.1.2/go.mod h1:inq4DFudC7W8L5fhxoeZflLRNpWSs0GNx6MlWFvuvr0= 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.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= +github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/pgzip v1.2.7 h1:02QB3Ttao6zOWDnSsv3bIvjN24bX0eGjWniQ8vuBfkA= +github.com/klauspost/pgzip v1.2.7/go.mod h1:g7E6NrOKHOzah4QwK6Ue1tNCJs8IDiNOfjiXTr85U2E= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -309,16 +323,18 @@ github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2t github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= -github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= -github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= +github.com/lestrrat-go/strftime v1.2.0 h1:8fAUYOeaJKCuLzNvUWBAo8t6I6hkFfodDTndEzJIun0= +github.com/lestrrat-go/strftime v1.2.0/go.mod h1:GtsIA/7ddIGJjEdfadUafEb1sbutvlvpMdPCMglykYo= github.com/likexian/gokit v0.25.13 h1:p2Uw3+6fGG53CwdU2Dz0T6bOycdb2+bAFAa3ymwWVkM= github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4= +github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4= +github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4= github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w= github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w= -github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 h1:PTw+yKnXcOFCR6+8hHTyWBeQ/P4Nb7dd4/0ohEcWQuM= -github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= -github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= -github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= +github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 h1:eveIIGn4BGM3qknO74omf6HYr30/exH+eVUTuAgwjZ0= +github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= +github.com/magefile/mage v1.17.2 h1:fyXVu1eadI8Ap1HCCNgEhJ5McIWiYhLR8uol64ZZc40= +github.com/magefile/mage v1.17.2/go.mod h1:Yj51kqllmsgFpvvSzgrZPK9WtluG3kUhFaBUVLo4feA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -328,6 +344,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5IBgwo= +github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= @@ -359,12 +377,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= -github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1YH8= -github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg= +github.com/openimsdk/gomake v0.0.19 h1:uzplTl/xDUQ9m6BRk1qFgn/IF8fSXxKqFHp00K6wZf8= +github.com/openimsdk/gomake v0.0.19/go.mod h1:pWidqX7Q1455YlWjx9A5OJoirMYh4QIQY+jW7dUw2y8= github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s= github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= -github.com/openimsdk/tools v0.0.50-alpha.121 h1:TXKKgtkeMeqIs0vpolbW8rIEngE9xlESq+0NV+FoLH0= -github.com/openimsdk/tools v0.0.50-alpha.121/go.mod h1:I0WESSa7ghPIo9BL+ETlH/qEIbO6+KZioM1jwNuDwz0= +github.com/openimsdk/tools v0.0.50-alpha.126 h1:wJ3eIR4Y/ZKz1m+m4osV4K5w5aiHmmA9QqJVkp45nFk= +github.com/openimsdk/tools v0.0.50-alpha.126/go.mod h1:3d0x4v/6/0Gdr/8si5+cRJrVHDfr79E1IXQ3eQLxQ7k= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= @@ -375,10 +393,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= -github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0 h1:XA01Vk/wv9YikCi1V51yRzIHPMT5of9+cMpZoZvDn/M= +github.com/power-devops/perfstat v0.0.0-20260916203055-22a1a467d9f0/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= @@ -390,6 +406,8 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/pterm/pterm v0.12.84 h1:DA9943h1RfwlpcGWCIbD6f6nRTLCe09gK7w6GDXaIzE= +github.com/pterm/pterm v0.12.84/go.mod h1:LVerZ1tFVFZrTv7lRbLdbrrTLSLAB5oZY8z3IY/z+IQ= github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk= github.com/qiniu/go-sdk/v7 v7.18.2 h1:vk9eo5OO7aqgAOPF0Ytik/gt7CMKuNgzC/IPkhda6rk= github.com/qiniu/go-sdk/v7 v7.18.2/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYXOwye868w= @@ -413,12 +431,14 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sercand/kuberesolver/v6 v6.0.1 h1:XZUTA0gy/lgDYp/UhEwv7Js24F1j8NJ833QrWv0Xux4= github.com/sercand/kuberesolver/v6 v6.0.1/go.mod h1:C0tsTuRMONSY+Xf7pv7RMW1/JlewY1+wS8SZE+1lf1s= +github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw= +github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= -github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI= -github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= +github.com/shirou/gopsutil/v4 v4.26.9 h1:CaBo/hBFqvlJoLvAQEKdHdf5GD97/MN2ACfyv63+2Ig= +github.com/shirou/gopsutil/v4 v4.26.9/go.mod h1:nKH+8wX2zxr/mDbsR+AAy6Qd2z4ZOQ7wfQaEp+yrYmg= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= @@ -438,8 +458,9 @@ github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMV github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 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/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -449,18 +470,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0= github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4= github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE= -github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= -github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= -github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= -github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= +github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU= +github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI= +github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4= +github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= @@ -506,16 +527,16 @@ go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2W go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= +go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc= golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= @@ -526,8 +547,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= -golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= @@ -539,6 +560,7 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -555,8 +577,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= -golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= @@ -566,8 +588,9 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= +golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -583,14 +606,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= +golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= 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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= -golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= +golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM= +golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY= 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= @@ -599,8 +622,9 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -612,8 +636,9 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= -golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI= +golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -653,8 +678,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= 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= diff --git a/internal/push/onlinepusher.go b/internal/push/onlinepusher.go index b9d371c55..45b583a14 100644 --- a/internal/push/onlinepusher.go +++ b/internal/push/onlinepusher.go @@ -5,6 +5,8 @@ import ( "fmt" "sync" + "golang.org/x/sync/errgroup" + "github.com/openimsdk/protocol/msggateway" "github.com/openimsdk/protocol/sdkws" "github.com/openimsdk/tools/discovery" @@ -12,8 +14,6 @@ import ( "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/runtimeenv" - "golang.org/x/sync/errgroup" - "google.golang.org/grpc" conf "github.com/openimsdk/open-im-server/v3/pkg/common/config" ) @@ -137,78 +137,3 @@ func (d *DefaultAllNode) GetOnlinePushFailedUserIDs(_ context.Context, msg *sdkw return datautil.SliceSub(*pushToUserIDs, onlineSuccessUserIDs) } - -type K8sStaticConsistentHash struct { - disCov discovery.SvcDiscoveryRegistry - config *Config -} - -func NewK8sStaticConsistentHash(disCov discovery.SvcDiscoveryRegistry, config *Config) *K8sStaticConsistentHash { - return &K8sStaticConsistentHash{disCov: disCov, config: config} -} - -func (k *K8sStaticConsistentHash) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, - pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error) { - - var usersHost = make(map[string][]string) - for _, v := range pushToUserIDs { - tHost, err := k.disCov.GetUserIdHashGatewayHost(ctx, v) - if err != nil { - log.ZError(ctx, "get msg gateway hash error", err) - return nil, err - } - tUsers, tbl := usersHost[tHost] - if tbl { - tUsers = append(tUsers, v) - usersHost[tHost] = tUsers - } else { - usersHost[tHost] = []string{v} - } - } - log.ZDebug(ctx, "genUsers send hosts struct:", "usersHost", usersHost) - var usersConns = make(map[grpc.ClientConnInterface][]string) - for host, userIds := range usersHost { - tconn, _ := k.disCov.GetConn(ctx, host) - usersConns[tconn] = userIds - } - var ( - mu sync.Mutex - wg = errgroup.Group{} - maxWorkers = k.config.RpcConfig.MaxConcurrentWorkers - ) - if maxWorkers < 3 { - maxWorkers = 3 - } - wg.SetLimit(maxWorkers) - for conn, userIds := range usersConns { - tcon := conn - tuserIds := userIds - wg.Go(func() error { - input := &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: tuserIds} - msgClient := msggateway.NewMsgGatewayClient(tcon) - reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(ctx, input) - if err != nil { - return nil - } - log.ZDebug(ctx, "push result", "reply", reply) - if reply != nil && reply.SinglePushResult != nil { - mu.Lock() - wsResults = append(wsResults, reply.SinglePushResult...) - mu.Unlock() - } - return nil - }) - } - _ = wg.Wait() - return wsResults, nil -} -func (k *K8sStaticConsistentHash) GetOnlinePushFailedUserIDs(_ context.Context, _ *sdkws.MsgData, - wsResults []*msggateway.SingleMsgToUserResults, _ *[]string) []string { - var needOfflinePushUserIDs []string - for _, v := range wsResults { - if !v.OnlinePush { - needOfflinePushUserIDs = append(needOfflinePushUserIDs, v.UserID) - } - } - return needOfflinePushUserIDs -} diff --git a/magefile.go b/magefile.go index 9b34dfa60..22109006f 100644 --- a/magefile.go +++ b/magefile.go @@ -4,16 +4,14 @@ package main import ( - "flag" "fmt" - "os" "github.com/openimsdk/gomake/mageutil" "github.com/openimsdk/open-im-server/v3/version" "github.com/openimsdk/tools/utils/datautil" ) -var Default = Build +var Default = BuildAll var Aliases = map[string]any{ "buildcc": BuildWithCustomConfig, @@ -28,24 +26,21 @@ var ( customToolsDir = "tools" // tools source code directory, default is "tools" ) +func BuildAll() error { return Build(nil, nil) } + // Build support specifical binary build. // // Example: `mage build openim-api openim-rpc-user seq` -func Build() { - flag.Parse() - bin := flag.Args() - if len(bin) != 0 { - bin = bin[1:] - } - mageutil.WithSpinner("Building binaries...", func() { mageutil.Build(bin, nil, nil) }) +func Build(services, tools *string) (err error) { + defer mageutil.PrintErrPtr(&err) + + return mageutil.WithSpinnerR("Building binaries...", func() error { + return mageutil.Build(mageutil.ParseArgList(services), mageutil.ParseArgList(tools), nil, nil) + }) } -func BuildWithCustomConfig() { - flag.Parse() - bin := flag.Args() - if len(bin) != 0 { - bin = bin[1:] - } +func BuildWithCustomConfig(services, tools *string) (err error) { + defer mageutil.PrintErrPtr(&err) config := &mageutil.PathOptions{ RootDir: &customRootDir, @@ -54,43 +49,21 @@ func BuildWithCustomConfig() { ToolsDir: &customToolsDir, } - mageutil.WithSpinner("Building binaries with custom config...", func() { - mageutil.Build(bin, config, nil) + return mageutil.WithSpinnerR("Building binaries with custom config...", func() error { + return mageutil.Build(mageutil.ParseArgList(services), mageutil.ParseArgList(tools), config, nil) }) } -func Start() { - mageutil.InitForSSC() - err := setMaxOpenFiles() - if err != nil { - mageutil.PrintRed("setMaxOpenFiles failed " + err.Error()) - os.Exit(1) - } +func Start() (err error) { + defer mageutil.PrintErrPtr(&err) - flag.Parse() - bin := flag.Args() - if len(bin) != 0 { - bin = bin[1:] - } - - mageutil.WithSpinner("Starting...", func() { - mageutil.StartToolsAndServices(bin, nil) + return mageutil.WithSpinnerR("Starting...", func() error { + return mageutil.StartToolsAndServices(nil, nil, nil) }) } -func StartWithCustomConfig() { - mageutil.InitForSSC() - err := setMaxOpenFiles() - if err != nil { - mageutil.PrintRed("setMaxOpenFiles failed " + err.Error()) - os.Exit(1) - } - - flag.Parse() - bin := flag.Args() - if len(bin) != 0 { - bin = bin[1:] - } +func StartWithCustomConfig(services, tools *string) (err error) { + defer mageutil.PrintErrPtr(&err) config := &mageutil.PathOptions{ RootDir: &customRootDir, @@ -98,20 +71,24 @@ func StartWithCustomConfig() { ConfigDir: &customConfigDir, } - mageutil.WithSpinner("Starting with custom config...", func() { - mageutil.StartToolsAndServices(bin, config) + return mageutil.WithSpinnerR("Starting with custom config...", func() error { + return mageutil.StartToolsAndServices(mageutil.ParseArgList(tools), mageutil.ParseArgList(services), config) }) } -func Stop() { - mageutil.WithSpinner("Stopping...", mageutil.StopAndCheckBinaries) +func Stop() (err error) { + defer mageutil.PrintErrPtr(&err) + return mageutil.WithSpinnerR("Stopping...", mageutil.StopAndCheckServices) } -func Check() { - mageutil.WithSpinner("Checking binaries...", mageutil.CheckAndReportBinariesStatus) +func Check() (err error) { + defer mageutil.PrintErrPtr(&err) + return mageutil.WithSpinnerR("Checking binaries...", mageutil.CheckAndReportServicesStatus) } -func Export() { +func Export() (err error) { + defer mageutil.PrintErrPtr(&err) + mappingPaths, err := mageutil.GetDefaultExportMappingPaths([]string{ "cmd", "internal", @@ -120,15 +97,15 @@ func Export() { "tools", "**/*.go", "go.mod", + "go.sum", "go.work", }) if err != nil { - mageutil.PrintRed("GetDefaultExportMappingPaths failed " + err.Error()) - os.Exit(1) + return fmt.Errorf("GetDefaultExportMappingPaths failed: %v", err) } - mageutil.WithSpinner("Exporting...", func() { - mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{ + return mageutil.WithSpinnerR("Exporting...", func() error { + return mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{ ProjectName: datautil.ToPtr(fmt.Sprintf("open-im-server_%s", version.Version)), BuildOpt: &mageutil.BuildOptions{ Release: datautil.ToPtr(true), diff --git a/magefile_unix.go b/magefile_unix.go deleted file mode 100644 index 4bb0cc1a9..000000000 --- a/magefile_unix.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build mage && !windows -// +build mage,!windows - -package main - -import ( - "syscall" - - "github.com/openimsdk/gomake/mageutil" -) - -func setMaxOpenFiles() error { - var rLimit syscall.Rlimit - err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) - if err != nil { - return err - } - rLimit.Max = uint64(mageutil.MaxFileDescriptors) - rLimit.Cur = uint64(mageutil.MaxFileDescriptors) - return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) -} diff --git a/magefile_windows.go b/magefile_windows.go deleted file mode 100644 index 7441bfd9c..000000000 --- a/magefile_windows.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build mage -// +build mage - -package main - -func setMaxOpenFiles() error { - return nil -} diff --git a/pkg/common/discovery/direct/directconn.go b/pkg/common/discovery/direct/directconn.go index 1cbe56dd5..d3c580d66 100644 --- a/pkg/common/discovery/direct/directconn.go +++ b/pkg/common/discovery/direct/directconn.go @@ -53,10 +53,6 @@ package direct // return nil //} // -//func (cd *ConnDirect) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) { -// return "", nil -//} -// //func (cd *ConnDirect) Register(serviceName, host string, port int, opts ...grpc.DialOption) error { // return nil //} diff --git a/pkg/common/discovery/kubernetes/kubernetes.go b/pkg/common/discovery/kubernetes/kubernetes.go index 459f20e0b..0196e11b6 100644 --- a/pkg/common/discovery/kubernetes/kubernetes.go +++ b/pkg/common/discovery/kubernetes/kubernetes.go @@ -208,10 +208,6 @@ func (k *KubernetesConnManager) UnRegister() error { return nil } -func (k *KubernetesConnManager) GetUserIdHashGatewayHost(ctx context.Context, userId string) (string, error) { - return "", nil -} - func (k *KubernetesConnManager) getServicePort(serviceName string) (int32, error) { var svcPort int32 diff --git a/start-config.yml b/start-config.yml index da959044d..1c584c967 100644 --- a/start-config.yml +++ b/start-config.yml @@ -1,4 +1,4 @@ -serviceBinaries: +services: openim-api: 1 openim-crontask: 4 openim-rpc-user: 1 @@ -11,7 +11,7 @@ serviceBinaries: openim-rpc-friend: 1 openim-rpc-msg: 1 openim-rpc-third: 1 -toolBinaries: +tools: - check-free-memory - check-component - seq From 9502a1a15fe63f6342fb1e2d8068346a82f278d8 Mon Sep 17 00:00:00 2001 From: dsx137 <70027572+dsx137@users.noreply.github.com> Date: Fri, 30 Oct 2026 10:18:39 +0000 Subject: [PATCH 41/41] fix(core): enforce access checks on RPC endpoints (#3829) # Conflicts: # internal/rpc/conversation/conversation.go # internal/rpc/conversation/sync.go # internal/rpc/msg/delete.go # internal/rpc/msg/statistics.go # internal/rpc/msg/sync_msg.go # internal/rpc/third/third.go --- internal/rpc/msg/sync_msg.go | 3 +++ internal/rpc/third/third.go | 7 +++++-- internal/rpc/user/statistics.go | 4 ++++ internal/rpc/user/user.go | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/rpc/msg/sync_msg.go b/internal/rpc/msg/sync_msg.go index 259c7f85d..d41b54928 100644 --- a/internal/rpc/msg/sync_msg.go +++ b/internal/rpc/msg/sync_msg.go @@ -150,6 +150,9 @@ func (m *msgServer) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sd } func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq) (resp *msg.SearchMessageResp, err error) { + if err := authverify.CheckAdmin(ctx); err != nil { + return nil, err + } // var chatLogs []*sdkws.MsgData var chatLogs []*msg.SearchedMsgData var total int64 diff --git a/internal/rpc/third/third.go b/internal/rpc/third/third.go index 90a16012d..65d684a43 100644 --- a/internal/rpc/third/third.go +++ b/internal/rpc/third/third.go @@ -24,6 +24,8 @@ import ( "github.com/openimsdk/open-im-server/v3/pkg/rpcli" "github.com/openimsdk/tools/s3/disable" + "google.golang.org/grpc" + "github.com/openimsdk/open-im-server/v3/pkg/common/config" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo" @@ -31,8 +33,6 @@ import ( "github.com/openimsdk/tools/s3/aws" "github.com/openimsdk/tools/s3/kodo" - "google.golang.org/grpc" - "github.com/openimsdk/open-im-server/v3/pkg/common/storage/controller" "github.com/openimsdk/protocol/third" "github.com/openimsdk/tools/discovery" @@ -122,6 +122,9 @@ func Start(ctx context.Context, config *Config, client discovery.SvcDiscoveryReg } func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) { + if err := authverify.CheckAccess(ctx, req.Account); err != nil { + return nil, err + } err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime) if err != nil { return nil, err diff --git a/internal/rpc/user/statistics.go b/internal/rpc/user/statistics.go index 709c0146b..c2b3cf3f9 100644 --- a/internal/rpc/user/statistics.go +++ b/internal/rpc/user/statistics.go @@ -18,11 +18,15 @@ import ( "context" "time" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" pbuser "github.com/openimsdk/protocol/user" "github.com/openimsdk/tools/errs" ) func (s *userServer) UserRegisterCount(ctx context.Context, req *pbuser.UserRegisterCountReq) (*pbuser.UserRegisterCountResp, error) { + if err := authverify.CheckAdmin(ctx); err != nil { + return nil, err + } if req.Start > req.End { return nil, errs.ErrArgs.WrapMsg("start > end") } diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 82a8212bb..dce0f3c2e 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -227,6 +227,9 @@ func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUse return resp, nil } func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.SetGlobalRecvMessageOptReq) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) { + if err := authverify.CheckAccess(ctx, req.UserID); err != nil { + return nil, err + } resp = &pbuser.SetGlobalRecvMessageOptResp{} if _, err := s.db.FindWithError(ctx, []string{req.UserID}); err != nil { return nil, err @@ -719,6 +722,9 @@ func (s *userServer) NotificationUserInfoUpdate(ctx context.Context, userID stri } func (s *userServer) SortQuery(ctx context.Context, req *pbuser.SortQueryReq) (*pbuser.SortQueryResp, error) { + if err := authverify.CheckAdmin(ctx); err != nil { + return nil, err + } users, err := s.db.SortQuery(ctx, req.UserIDName, req.Asc) if err != nil { return nil, err