handleSend 处理发送消息(异步)
(ctx *actor.Context, msg *SendMsg)
| 263 | |
| 264 | // handleSend 处理发送消息(异步) |
| 265 | func (a *AgentActor) handleSend(ctx *actor.Context, msg *SendMsg) { |
| 266 | execCtx, cancel := a.withCancellation(msg.Ctx) |
| 267 | defer cancel() |
| 268 | |
| 269 | go func() { |
| 270 | err := a.agent.Send(execCtx, msg.Text) |
| 271 | |
| 272 | if err != nil && !errors.Is(err, context.Canceled) { |
| 273 | a.recordError(err) |
| 274 | if ctx.Sender != nil { |
| 275 | ctx.Reply(&ErrorMsg{Error: err, Context: "send"}) |
| 276 | } |
| 277 | } |
| 278 | }() |
| 279 | } |
| 280 | |
| 281 | // handleChat 处理同步对话 |
| 282 | func (a *AgentActor) handleChat(ctx *actor.Context, msg *ChatMsg) { |
no test coverage detected