Fetch the repository succeeded.
package main
import (
"fmt"
"time"
"github.com/AsynkronIT/goconsole"
"gitee.com/lwj8507/light-protoactor-go/actor"
)
type hello struct{ Who string }
type helloActor struct{}
func (state *helloActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case *actor.Started:
fmt.Println("Started, initialize actor here")
case *actor.Stopping:
fmt.Println("Stopping, actor is about shut down")
case *actor.Stopped:
fmt.Println("Stopped, actor and it's children are stopped")
case *actor.Restarting:
fmt.Println("Restarting, actor is about restart")
case *hello:
fmt.Printf("Hello %v\n", msg.Who)
}
}
func main() {
props := actor.FromInstance(&helloActor{})
a := actor.Spawn(props)
actor.Tell(a, &hello{Who: "Roger"})
//why wait?
//Stop is a system message and is not processed through the user message mailbox
//thus, it will be handled _before_ any user message
//we only do this to show the correct order of events in the console
time.Sleep(1 * time.Second)
actor.StopActor(a)
console.ReadLine()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。