1 Star 2 Fork 0

李文建/light-protoactor-go

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
main.go 1.42 KB
Copy Edit Raw Blame History
李文建 authored 2017-07-17 17:46 +08:00 . 1.git.oschina.net替换成gitee.com
package main
import (
"log"
"time"
"gitee.com/lwj8507/light-protoactor-go/actor"
"gitee.com/lwj8507/light-protoactor-go/remote"
"github.com/AsynkronIT/goconsole"
)
type watch struct {
}
func main() {
timeout := 5 * time.Second
remote.Start("127.0.0.1:8081")
props := actor.FromFunc(func(ctx actor.Context) {
switch msg := ctx.Message().(type) {
//case *actor.Started:
// log.Println("Local actor started")
// remotePID, err := remote.SpawnNamed("127.0.0.1:8080", "myRemote", "remote", timeout)
// if err != nil {
// log.Print("Local failed to spawn remote actor")
// return
// }
// log.Println("Local spawned remote actor")
// ctx.Watch(remotePID)
// log.Println("Local is watching remote actor")
case *watch:
log.Println("Local actor started")
remotePID, err := remote.SpawnNamed("127.0.0.1:8080", "myRemote", "remote", timeout)
if err != nil {
log.Print("Local failed to spawn remote actor")
return
}
log.Println("Local spawned remote actor")
ctx.Watch(remotePID)
log.Println("Local is watching remote actor")
case *actor.Terminated:
log.Printf("Local got terminated message %+v", msg)
}
})
pid := actor.Spawn(props)
var input string
var err error
var sendMsg = &watch{}
loop:
for {
input, err = console.ReadLine()
if err != nil {
break loop
}
switch input {
case "exit", "quit", "bye":
break loop
default:
actor.Tell(pid, sendMsg)
}
}
}
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