Skip to content

Commit

Permalink
fixed address error and wrapped up big portion of the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
anthdm committed Dec 3, 2023
1 parent 0b9d879 commit 86d5063
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions actor/deadletter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package actor
import (
"bytes"
"fmt"
"github.com/anthdm/hollywood/log"
"github.com/stretchr/testify/assert"
"log/slog"
"os"
"sync"
"testing"
"time"

"github.com/anthdm/hollywood/log"
"github.com/stretchr/testify/assert"
)

// TestDeadLetterDefault tests the default deadletter handling.
Expand Down Expand Up @@ -49,6 +50,8 @@ func TestDeadLetterCustom(t *testing.T) {
e.Poison(a1).Wait() // poison the a1 actor
// should be in deadletter
fmt.Println("==== sending message via a1 to deadletter ====")
fmt.Println(e.Registry)
fmt.Println("ID=> ", dl.PID())
e.Send(a1, testMessage{"bar"})
time.Sleep(time.Millisecond) // a flush would be nice here :-)
resp, err := e.Request(dl.PID(), &customDeadLetterFetch{flush: true}, time.Millisecond*10).Result()
Expand Down
12 changes: 9 additions & 3 deletions actor/engine.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package actor

import (
"log/slog"
reflect "reflect"
"sync"
"time"

Expand Down Expand Up @@ -37,10 +39,10 @@ type Engine struct {
func NewEngine(opts ...func(*Engine)) *Engine {
e := &Engine{}
e.Registry = newRegistry(e) // need to init the registry in case we want a custom deadletter
e.address = LocalLookupAddr
for _, o := range opts {
o(e)
}
e.address = LocalLookupAddr
if e.remote != nil {
e.address = e.remote.Address()
}
Expand Down Expand Up @@ -157,8 +159,12 @@ func (e *Engine) send(pid *PID, msg any, sender *PID) {
return
}
if e.remote == nil {
e.logger.Errorw("failed sending messsage",
"err", "engine has no remote configured")
slog.Error("failed sending messsage",
"err", "engine has no remote configured",
"to", pid,
"type", reflect.TypeOf(msg),
"msg", msg,
)
return
}
e.remote.Send(pid, msg, sender)
Expand Down

0 comments on commit 86d5063

Please sign in to comment.