Skip to content

Commit

Permalink
fix: fix nil logger
Browse files Browse the repository at this point in the history
  • Loading branch information
qazwsxedckll committed Mar 18, 2024
1 parent 607ffc8 commit 856e4c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions actor/throttler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewThrottle(maxEventsInPeriod int32, period time.Duration, throttledCallBac
func NewThrottleWithLogger(logger *slog.Logger, maxEventsInPeriod int32, period time.Duration, throttledCallBack func(*slog.Logger, int32)) ShouldThrottle {
currentEvents := int32(0)

startTimer := func(duration time.Duration, back func(*slog.Logger, int32)) {
startTimer := func(duration time.Duration) {
go func() {
// crete ticker to mimic sleep, we do not want to put the goroutine to sleep
// as it will schedule it out of the P making a syscall, we just want it to
Expand All @@ -77,7 +77,7 @@ func NewThrottleWithLogger(logger *slog.Logger, maxEventsInPeriod int32, period
return func() Valve {
tries := atomic.AddInt32(&currentEvents, 1)
if tries == 1 {
startTimer(period, throttledCallBack)
startTimer(period)
}

if tries == maxEventsInPeriod {
Expand Down
6 changes: 3 additions & 3 deletions cluster/pubsub_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ func (t *TopicActor) logDeliveryErrors(reports []*SubscriberDeliveryReport, logg
}

// unsubscribeUnreachablePidSubscribers deletes all subscribers that have a PID that is unreachable
func (t *TopicActor) unsubscribeUnreachablePidSubscribers(_ actor.Context, allInvalidDeliveryReports []*SubscriberDeliveryReport) {
func (t *TopicActor) unsubscribeUnreachablePidSubscribers(c actor.Context, allInvalidDeliveryReports []*SubscriberDeliveryReport) {
subscribers := make([]subscribeIdentityStruct, 0, len(allInvalidDeliveryReports))
for _, r := range allInvalidDeliveryReports {
if r.Subscriber.GetPid() != nil && r.Status == DeliveryStatus_SubscriberNoLongerReachable {
subscribers = append(subscribers, newSubscribeIdentityStruct(r.Subscriber))
}
}
t.removeSubscribers(subscribers, nil)
t.removeSubscribers(subscribers, c.Logger())
}

// onClusterTopologyChanged handles a ClusterTopology message
Expand Down Expand Up @@ -217,7 +217,7 @@ func (t *TopicActor) unsubscribeSubscribersOnMembersThatLeft(c actor.Context) {
}
}
}
t.removeSubscribers(subscribersThatLeft, nil)
t.removeSubscribers(subscribersThatLeft, c.Logger())
}

// removeSubscribers remove subscribers from the topic
Expand Down

0 comments on commit 856e4c8

Please sign in to comment.