AgentActorGetStatus 获取 Agent 状态
(pid *actor.PID, timeout time.Duration)
| 572 | |
| 573 | // AgentActorGetStatus 获取 Agent 状态 |
| 574 | func AgentActorGetStatus(pid *actor.PID, timeout time.Duration) (*types.AgentStatus, error) { |
| 575 | replyCh := make(chan *types.AgentStatus, 1) |
| 576 | |
| 577 | pid.Tell(&GetStatusMsg{ |
| 578 | ReplyTo: replyCh, |
| 579 | }) |
| 580 | |
| 581 | select { |
| 582 | case status := <-replyCh: |
| 583 | return status, nil |
| 584 | case <-time.After(timeout): |
| 585 | return nil, fmt.Errorf("get status timed out after %v", timeout) |
| 586 | } |
| 587 | } |