-
-
Notifications
You must be signed in to change notification settings - Fork 515
/
main.go
38 lines (30 loc) · 864 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"log"
"time"
console "github.com/AsynkronIT/goconsole"
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/AsynkronIT/protoactor-go/examples/remotebenchmark/messages"
"github.com/AsynkronIT/protoactor-go/remote"
)
func main() {
remote.Start("127.0.0.1:8081")
rootContext := actor.EmptyRootContext
props := actor.
PropsFromFunc(func(context actor.Context) {
switch context.Message().(type) {
case *messages.Pong:
v := context.MessageHeader().Get("test_header")
log.Println("Receive pong message with header:" + v)
}
})
pid := rootContext.Spawn(props)
remotePid := actor.NewPID("127.0.0.1:8080", "remote")
rootContext.RequestFuture(remotePid, &messages.StartRemote{
Sender: pid,
}, 5*time.Second).
Wait()
message := &messages.Ping{}
rootContext.Send(remotePid, message)
console.ReadLine()
}