forked from asynkron/protoactor-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (25 loc) · 764 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
package main
import (
"log"
console "github.com/AsynkronIT/goconsole"
"github.com/ChaokunChang/protoactor-go/actor"
"github.com/ChaokunChang/protoactor-go/examples/remotebenchmark/messages"
"github.com/ChaokunChang/protoactor-go/remote"
)
func main() {
remote.Start("127.0.0.1:8081", remote.WithAdvertisedAddress("localhost:8081"))
remotePid := actor.NewPID("127.0.0.1:8080", "remote")
rootContext := actor.EmptyRootContext
props := actor.
PropsFromFunc(func(context actor.Context) {
switch context.Message().(type) {
case *actor.Started:
message := &messages.Ping{}
context.Request(remotePid, message)
case *messages.Pong:
log.Println("Received pong from sender")
}
})
rootContext.Spawn(props)
console.ReadLine()
}