1 Star 2 Fork 0

李文建/light-protoactor-go

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
main.go 1.03 KB
Copy Edit Raw Blame History
李文建 authored 2017-07-17 17:46 . 1.git.oschina.net替换成gitee.com
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()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lwj8507/light-protoactor-go.git
git@gitee.com:lwj8507/light-protoactor-go.git
lwj8507
light-protoactor-go
light-protoactor-go
013e33d7022f

Search