spark-server/.cursor/skills/spark-im-v3/send-path.md
zhr 8870c59e2d docs(cursor): 优化 spark-im-v3 skill 与 Agent 说明
新增 mysql.md(t_ 表名与 migrate 流程),补全 /v1/music·square 与 admin 路由说明;description 与 AGENTS/rules 对齐 make test→lint 与 deploy 门禁,减少与 verify-before-done 重复。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 11:09:15 +08:00

901 B

Send / sync examples

Persist then enqueue then ACK

msg.ID, err = idgen.NextMsgID()
if err != nil { return nil, err }
if err := repo.Create(ctx, msg); err != nil { return nil, err }
if err := convRepo.UpdateLastMsg(ctx, msg.ConversationID, msg.ID, now); err != nil { return nil, err }
if err := deliver.Push(ctx, &deliver.Job{MsgID: msg.ID, ExcludeDevice: req.DeviceID}); err != nil {
    return nil, err // no SEND_ACK
}
return &SendResponse{MsgID: msg.ID, ClientMsgID: req.ClientMsgID, ServerTimeMS: now}, nil

EventLoop submit

if frame.Command == protocol.CmdHeartbeat {
    return writeHeartbeat(c, frame)
}
_ = pool.Submit(ctx, func() { router.Dispatch(ctx, frame) })

Sync

SELECT * FROM t_messages
 WHERE conversation_id = ? AND id > ?
 ORDER BY id ASC LIMIT 200;

Inbox sync reads Redis ZSET by dialog_score, then mailbox events by mailbox_seq.