Skip to content

Commit

Permalink
Merge pull request #797 from forta-network/avoid-considering-heartbea…
Browse files Browse the repository at this point in the history
…tbot-in-increased-batch-counts

Write batches at slow rate if only heartbeat bot is present
  • Loading branch information
stevenlanders authored Aug 3, 2023
2 parents febbdb5 + d6a7bad commit 999ae53
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions services/publisher/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ func (pub *Publisher) publishNextBatch(batch *protocol.AlertBatch) (published bo
return true, nil
}

func (pub *Publisher) hasBots() bool {
pub.botConfigMu.RLock()
defer pub.botConfigMu.RUnlock()
for _, bc := range pub.botConfigs {
if bc.ID != config.HeartbeatBotID {
return true
}
}
return false
}

func (pub *Publisher) shouldSkipPublishing(batch *protocol.AlertBatch) (string, bool) {
if pub.cfg.PublisherConfig.AlwaysPublish {
return "", false
Expand All @@ -392,9 +403,8 @@ func (pub *Publisher) shouldSkipPublishing(batch *protocol.AlertBatch) (string,

localModeConfig := &pub.cfg.Config.LocalModeConfig
lastBatchSendAttempt := pub.lastBatchSendAttempt
pub.botConfigMu.RLock()
runsBots := len(pub.botConfigs) > 0
pub.botConfigMu.RUnlock()

runsBots := pub.hasBots()

switch {
case localModeConfig.Enable && localModeConfig.IncludeMetrics:
Expand Down

0 comments on commit 999ae53

Please sign in to comment.