Skip to content

Commit

Permalink
fixed bug of the actor's Deliver method
Browse files Browse the repository at this point in the history
  • Loading branch information
dobyte committed Nov 1, 2024
1 parent 5aaa094 commit c46f345
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cluster/node/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,34 @@ func (a *Actor) Next(ctx Context) {
}

// Deliver 投递消息到当前Actor中进行处理
func (a *Actor) Deliver(uid int64, message *cluster.Message) {
func (a *Actor) Deliver(uid int64, message *cluster.Message) error {
buf, err := a.scheduler.node.proxy.PackBuffer(message.Data)
if err != nil {
return err
}

req := a.scheduler.node.reqPool.Get().(*request)
req.nid = a.scheduler.node.opts.id
req.uid = uid
req.message.Seq = message.Seq
req.message.Route = message.Route
req.message.Data = message.Data
req.message.Data = buf

a.Next(req)

return nil
}

// Push 推送消息到本地Node队列上进行处理
func (a *Actor) Push(uid int64, message *cluster.Message) {
a.scheduler.node.router.deliver("", a.scheduler.node.opts.id, a.PID(), 0, uid, message.Seq, message.Route, message.Data)
func (a *Actor) Push(uid int64, message *cluster.Message) error {
buf, err := a.scheduler.node.proxy.PackBuffer(message.Data)
if err != nil {
return err
}

a.scheduler.node.router.deliver("", a.scheduler.node.opts.id, a.PID(), 0, uid, message.Seq, message.Route, buf)

return nil
}

// Destroy 销毁Actor
Expand Down

0 comments on commit c46f345

Please sign in to comment.