Skip to content

Commit

Permalink
simplify the event stream handling. remove special handling of deadle…
Browse files Browse the repository at this point in the history
…tters.
  • Loading branch information
perbu committed Dec 6, 2023
1 parent 7f1b362 commit 1c43960
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions actor/event_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package actor

import (
"context"
"fmt"
"log/slog"
)

Expand All @@ -25,25 +24,8 @@ func (e *EventStream) Receive(c *Context) {
switch msg := c.Message().(type) {
case EventSub:
e.subs[msg.pid] = true
fmt.Println("EventStream.Receive: EventSub")
case EventUnsub:
delete(e.subs, msg.pid)
fmt.Println("EventStream.Receive: EventUnsub")
case DeadLetterEvent:
// to avoid a loop, check that the message isn't a deadletter.
_, ok := msg.Message.(DeadLetterEvent)
if ok {
c.engine.BroadcastEvent(DeadLetterLoopEvent{})
break
}
if len(e.subs) == 0 {
slog.Warn("deadletter arrived, but no subscribers to event stream",
"sender", msg.Sender, "target", msg.Target, "msg", msg.Message)
break
}
for sub := range e.subs {
c.Forward(sub)
}
default:
// check if we should log the event, if so, log it with the relevant level, message and attributes
logMsg, ok := c.Message().(eventLog)
Expand Down

0 comments on commit 1c43960

Please sign in to comment.