Skip to content

Commit

Permalink
fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
anthdm committed Jan 11, 2024
1 parent 4b54786 commit 4c07bc4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actor/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newTickReceiver(wg *sync.WaitGroup) Producer {
}

func TestSpawnWithContext(t *testing.T) {
e, _ := NewEngine(nil)
e, _ := NewEngine(NewEngineConfig())
type key struct {
key string
}
Expand Down
3 changes: 3 additions & 0 deletions examples/cluster/member_1/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"

"github.com/anthdm/hollywood/actor"
Expand All @@ -23,6 +24,8 @@ func main() {

eventPID := c.Engine().SpawnFunc(func(ctx *actor.Context) {
switch msg := ctx.Message().(type) {
case cluster.ActivationEvent:
fmt.Println("got activation event")
case cluster.MemberJoinEvent:
if msg.Member.ID == "B" {
config := cluster.NewActivationConfig().
Expand Down
19 changes: 16 additions & 3 deletions examples/cluster/member_2/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package main

import (
"fmt"
"log"
"reflect"

"github.com/anthdm/hollywood/actor"
"github.com/anthdm/hollywood/cluster"
"github.com/anthdm/hollywood/examples/cluster/shared"
)
Expand All @@ -13,11 +16,21 @@ func main() {
WithID("B").
WithListenAddr("127.0.0.1:3001").
WithRegion("us-west")
cluster, err := cluster.New(config)
c, err := cluster.New(config)
if err != nil {
log.Fatal(err)
}
cluster.RegisterKind("playerSession", shared.NewPlayer, nil)
cluster.Start()
eventPID := c.Engine().SpawnFunc(func(ctx *actor.Context) {
switch msg := ctx.Message().(type) {
case *cluster.Activation:
fmt.Println("got activation event", msg)
default:
fmt.Println("got", reflect.TypeOf(msg))
}
}, "event")

c.Engine().Subscribe(eventPID)
c.RegisterKind("playerSession", shared.NewPlayer, nil)
c.Start()
select {}
}

0 comments on commit 4c07bc4

Please sign in to comment.