MCPcopy Create free account
hub / github.com/astercloud/aster / SendWithSender

Method SendWithSender

pkg/actor/system.go:265–292  ·  view source on GitHub ↗

SendWithSender 发送消息(带发送者)

(target *PID, msg Message, sender *PID)

Source from the content-addressed store, hash-verified

263
264// SendWithSender 发送消息(带发送者)
265func (s *System) SendWithSender(target *PID, msg Message, sender *PID) {
266 if !s.isRunning.Load() {
267 return
268 }
269
270 env := envelope{
271 target: target,
272 sender: sender,
273 message: msg,
274 sentAt: time.Now(),
275 }
276
277 select {
278 case s.mailbox <- env:
279 atomic.AddInt64(&s.stats.TotalMessages, 1)
280 default:
281 // 邮箱满,发送到死信队列
282 select {
283 case s.deadLetters <- env:
284 atomic.AddInt64(&s.stats.DeadLetters, 1)
285 default:
286 actorLog.Warn(context.Background(), "both mailbox and dead letter queue full, message dropped", map[string]any{
287 "msg_kind": msg.Kind(),
288 "target_id": target.ID,
289 })
290 }
291 }
292}
293
294// Request 同步请求(等待响应)
295func (s *System) Request(target *PID, msg Message, timeout time.Duration) (Message, error) {

Callers 4

spawnWithPropsMethod · 0.95
SendMethod · 0.95
ReplyMethod · 0.80
ForwardMethod · 0.80

Calls 3

LoadMethod · 0.65
WarnMethod · 0.65
KindMethod · 0.65

Tested by

no test coverage detected