Documentation
¶
Overview ¶
* @Date: 2025-01-27 00:00:00 * @LastEditors: peng pgs1108pgs@gmail.com * @LastEditTime: 2025-01-27 00:00:00 * @FilePath: /thinking-map/server/internal/global/broker.go
* @Date: 2025-01-27 00:00:00 * @LastEditors: peng pgs1108pgs@gmail.com * @LastEditTime: 2025-01-27 00:00:00 * @FilePath: /thinking-map/server/internal/global/message_manager.go
* @Date: 2025-01-27 00:00:00 * @LastEditors: peng pgs1108pgs@gmail.com * @LastEditTime: 2025-01-27 00:00:00 * @FilePath: /thinking-map/server/internal/global/node_operator.go
* @Date: 2025-06-24 23:26:09 * @LastEditors: peng pgs1108pgs@gmail.com * @LastEditTime: 2025-06-24 23:26:15 * @FilePath: /thinking-map/server/internal/global/rag_record.go
* @Date: 2025-06-22 14:56:38 * @LastEditors: peng pgs1108pgs@gmail.com * @LastEditTime: 2025-06-22 15:09:02 * @FilePath: /thinking-map/server/internal/service/test_utils.go
Index ¶
- Variables
- func CleanupTestEnvironment(testConfig *TestConfig)
- func ConvertToSchemaMsg(list []*dto.MessageResponse) []*schema.Message
- func GetBroker() *sse.Broker
- func GetRAGRecordRepository() repository.RAGRecord
- func InitBroker(eventBus sse.EventBus, connManager sse.ConnectionManager, serverID string, ...)
- func InitMessageManager(messageRepo repository.Message, nodeRepo repository.ThinkingNode, ...)
- func InitNodeOperator(nodeRepo repository.ThinkingNode, mapRepo repository.ThinkingMap)
- func InitRAGRecordRepository(repo repository.RAGRecord)
- func InitTestDatabase(cfg *config.Config) (*gorm.DB, error)
- func InitTestRedis(cfg *config.Config) (*redis.Client, error)
- func LoadTestConfig() (*config.Config, error)
- type MessageManager
- func (s *MessageManager) ClearConversation(ctx context.Context, conversationID string) error
- func (s *MessageManager) CreateConversation(ctx context.Context, nodeID string) (string, error)
- func (s *MessageManager) CreateMessage(ctx context.Context, userID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
- func (s *MessageManager) CreateMessageInTx(ctx context.Context, tx *gorm.DB, userID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
- func (s *MessageManager) DeleteMessage(ctx context.Context, id string) error
- func (s *MessageManager) GetConversationMessages(ctx context.Context, conversationID string) ([]*dto.MessageResponse, error)
- func (s *MessageManager) GetMessageByConversationID(ctx context.Context, conversationID string) ([]*dto.MessageResponse, error)
- func (s *MessageManager) GetMessageByID(ctx context.Context, id string) (*dto.MessageResponse, error)
- func (s *MessageManager) GetMessageChain(ctx context.Context, messageID string, conversationID string) ([]*dto.MessageResponse, error)
- func (s *MessageManager) GetMessageStatus(ctx context.Context, messageID string) (dto.MessageStatus, error)
- func (s *MessageManager) GetNodeChildren(ctx context.Context, nodeID string) ([]*schema.Message, error)
- func (s *MessageManager) GetNodeMessages(ctx context.Context, nodeID string, conversationType string) ([]*dto.MessageResponse, error)
- func (s *MessageManager) LinkMessageToNode(ctx context.Context, nodeID string, messageID, conversationID string, ...) error
- func (s *MessageManager) LinkMessageToNodeInTx(ctx context.Context, tx *gorm.DB, nodeID string, ...) error
- func (s *MessageManager) MarkMessageAsDeleted(ctx context.Context, messageID string) error
- func (s *MessageManager) RestoreMessage(ctx context.Context, messageID string) error
- func (s *MessageManager) RollbackConversation(ctx context.Context, conversationID string, targetMessageID string) error
- func (s *MessageManager) SaveConclusionMessage(ctx context.Context, nodeID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
- func (s *MessageManager) SaveDecompositionMessage(ctx context.Context, nodeID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
- func (s *MessageManager) SaveStreamMessage(ctx *gin.Context, sr *schema.StreamReader[*schema.Message], ...)
- func (s *MessageManager) UpdateMessage(ctx context.Context, req dto.UpdateMessageRequest) (*dto.MessageResponse, error)
- func (s *MessageManager) UpdateNodeLastMessage(ctx context.Context, nodeID string, messageID, conversationID string, ...) error
- type NodeOperator
- func (s *NodeOperator) CreateNode(ctx context.Context, req dto.CreateNodeRequest) (*dto.NodeResponse, error)
- func (s *NodeOperator) DeleteNode(ctx context.Context, nodeID string) error
- func (s *NodeOperator) GetNodesByIDs(ctx context.Context, nodeIDs []string) ([]*model.ThinkingNode, error)
- func (s *NodeOperator) UpdateNode(ctx context.Context, nodeID string, req dto.UpdateNodeRequest) (*dto.NodeResponse, error)
- func (s *NodeOperator) UpdateNodeDependencies(ctx context.Context, nodeID string, dependencies []string) (*model.ThinkingNode, error)
- type TestConfig
Constants ¶
This section is empty.
Variables ¶
var ( // GlobalBroker 全局SSE broker实例 GlobalBroker *sse.Broker )
Functions ¶
func CleanupTestEnvironment ¶
func CleanupTestEnvironment(testConfig *TestConfig)
CleanupTestEnvironment 清理测试环境
func ConvertToSchemaMsg ¶
func ConvertToSchemaMsg(list []*dto.MessageResponse) []*schema.Message
func GetRAGRecordRepository ¶
func GetRAGRecordRepository() repository.RAGRecord
func InitBroker ¶
func InitBroker(eventBus sse.EventBus, connManager sse.ConnectionManager, serverID string, pingInterval, clientTimeout time.Duration)
InitBroker 初始化全局broker
func InitMessageManager ¶
func InitMessageManager(messageRepo repository.Message, nodeRepo repository.ThinkingNode, ragRecordRepo repository.RAGRecord, db *gorm.DB)
InitMessageManager 初始化全局消息管理器
func InitNodeOperator ¶
func InitNodeOperator(nodeRepo repository.ThinkingNode, mapRepo repository.ThinkingMap)
InitNodeOperator 初始化全局节点操作器
func InitRAGRecordRepository ¶
func InitRAGRecordRepository(repo repository.RAGRecord)
func InitTestDatabase ¶
InitTestDatabase 初始化测试数据库
func InitTestRedis ¶
InitTestRedis 初始化测试Redis
Types ¶
type MessageManager ¶
type MessageManager struct {
// contains filtered or unexported fields
}
MessageManager 消息管理器
var ( // GlobalMessageManager 全局消息管理器实例 GlobalMessageManager *MessageManager )
func (*MessageManager) ClearConversation ¶
func (s *MessageManager) ClearConversation(ctx context.Context, conversationID string) error
ClearConversation 清空会话
func (*MessageManager) CreateConversation ¶
CreateConversation 创建新会话
func (*MessageManager) CreateMessage ¶
func (s *MessageManager) CreateMessage(ctx context.Context, userID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
CreateMessage 创建消息
func (*MessageManager) CreateMessageInTx ¶
func (s *MessageManager) CreateMessageInTx(ctx context.Context, tx *gorm.DB, userID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
CreateMessageInTx 在事务中创建消息
func (*MessageManager) DeleteMessage ¶
func (s *MessageManager) DeleteMessage(ctx context.Context, id string) error
DeleteMessage 删除消息
func (*MessageManager) GetConversationMessages ¶
func (s *MessageManager) GetConversationMessages(ctx context.Context, conversationID string) ([]*dto.MessageResponse, error)
GetConversationMessages 获取会话中的所有消息
func (*MessageManager) GetMessageByConversationID ¶
func (s *MessageManager) GetMessageByConversationID(ctx context.Context, conversationID string) ([]*dto.MessageResponse, error)
func (*MessageManager) GetMessageByID ¶
func (s *MessageManager) GetMessageByID(ctx context.Context, id string) (*dto.MessageResponse, error)
GetMessageByID 根据ID获取消息
func (*MessageManager) GetMessageChain ¶
func (s *MessageManager) GetMessageChain(ctx context.Context, messageID string, conversationID string) ([]*dto.MessageResponse, error)
GetMessageChain 获取消息链(从根消息到指定消息的完整路径)
func (*MessageManager) GetMessageStatus ¶
func (s *MessageManager) GetMessageStatus(ctx context.Context, messageID string) (dto.MessageStatus, error)
GetMessageStatus 获取消息状态
func (*MessageManager) GetNodeChildren ¶
func (s *MessageManager) GetNodeChildren(ctx context.Context, nodeID string) ([]*schema.Message, error)
GetNodeChildren 获取节点的所有子节点信息,格式化为消息用于LLM上下文
func (*MessageManager) GetNodeMessages ¶
func (s *MessageManager) GetNodeMessages(ctx context.Context, nodeID string, conversationType string) ([]*dto.MessageResponse, error)
GetNodeMessages 获取节点相关的消息
func (*MessageManager) LinkMessageToNode ¶
func (s *MessageManager) LinkMessageToNode(ctx context.Context, nodeID string, messageID, conversationID string, conversationType string) error
LinkMessageToNode 将消息关联到节点
func (*MessageManager) LinkMessageToNodeInTx ¶
func (s *MessageManager) LinkMessageToNodeInTx(ctx context.Context, tx *gorm.DB, nodeID string, messageID, conversationID string, conversationType string) error
LinkMessageToNodeInTx 在事务中将消息关联到节点
func (*MessageManager) MarkMessageAsDeleted ¶
func (s *MessageManager) MarkMessageAsDeleted(ctx context.Context, messageID string) error
MarkMessageAsDeleted 标记消息为已删除
func (*MessageManager) RestoreMessage ¶
func (s *MessageManager) RestoreMessage(ctx context.Context, messageID string) error
RestoreMessage 恢复已删除的消息(如果支持软删除)
func (*MessageManager) RollbackConversation ¶
func (s *MessageManager) RollbackConversation(ctx context.Context, conversationID string, targetMessageID string) error
RollbackConversation 回退会话到指定消息
func (*MessageManager) SaveConclusionMessage ¶
func (s *MessageManager) SaveConclusionMessage(ctx context.Context, nodeID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
SaveConclusionMessage 保存结论消息(使用事务和行级锁解决并发问题)
func (*MessageManager) SaveDecompositionMessage ¶
func (s *MessageManager) SaveDecompositionMessage(ctx context.Context, nodeID string, req dto.CreateMessageRequest) (*dto.MessageResponse, error)
SaveDecompositionMessage 保存分解消息(使用事务和行级锁解决并发问题)
func (*MessageManager) SaveStreamMessage ¶
func (s *MessageManager) SaveStreamMessage(ctx *gin.Context, sr *schema.StreamReader[*schema.Message], ID, parentID string)
func (*MessageManager) UpdateMessage ¶
func (s *MessageManager) UpdateMessage(ctx context.Context, req dto.UpdateMessageRequest) (*dto.MessageResponse, error)
UpdateMessage 更新消息
func (*MessageManager) UpdateNodeLastMessage ¶
func (s *MessageManager) UpdateNodeLastMessage(ctx context.Context, nodeID string, messageID, conversationID string, conversationType string) error
UpdateNodeLastMessage 更新节点的最后消息ID
type NodeOperator ¶
type NodeOperator struct {
// contains filtered or unexported fields
}
NodeOperator 节点操作器
var ( // GlobalNodeOperator 全局节点操作器实例 GlobalNodeOperator *NodeOperator )
func (*NodeOperator) CreateNode ¶
func (s *NodeOperator) CreateNode(ctx context.Context, req dto.CreateNodeRequest) (*dto.NodeResponse, error)
CreateNode 创建节点
func (*NodeOperator) DeleteNode ¶
func (s *NodeOperator) DeleteNode(ctx context.Context, nodeID string) error
DeleteNode 删除节点
func (*NodeOperator) GetNodesByIDs ¶
func (s *NodeOperator) GetNodesByIDs(ctx context.Context, nodeIDs []string) ([]*model.ThinkingNode, error)
GetNodesByIDs 获取多个节点
func (*NodeOperator) UpdateNode ¶
func (s *NodeOperator) UpdateNode(ctx context.Context, nodeID string, req dto.UpdateNodeRequest) (*dto.NodeResponse, error)
UpdateNode 更新节点
func (*NodeOperator) UpdateNodeDependencies ¶
func (s *NodeOperator) UpdateNodeDependencies(ctx context.Context, nodeID string, dependencies []string) (*model.ThinkingNode, error)
UpdateNodeDependencies 更新节点依赖关系
type TestConfig ¶
TestConfig 测试配置结构体
func SetupTestEnvironment ¶
func SetupTestEnvironment() (*TestConfig, error)
SetupTestEnvironment 设置测试环境