Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for agent initalization to start processing #721

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions services/scanner/agentpool/agent_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (ap *AgentPool) SendEvaluateTxRequest(req *protocol.EvaluateTxRequest) {
}
var metricsList []*protocol.AgentMetric
for _, agent := range agents {
if !agent.IsInitialized() || !agent.ShouldProcessBlock(req.Event.Block.BlockNumber) {
if !agent.IsReady() || !agent.ShouldProcessBlock(req.Event.Block.BlockNumber) {
continue
}
lg.WithFields(log.Fields{
Expand Down Expand Up @@ -212,7 +212,7 @@ func (ap *AgentPool) SendEvaluateBlockRequest(req *protocol.EvaluateBlockRequest

var metricsList []*protocol.AgentMetric
for _, agent := range agents {
if !agent.IsInitialized() || !agent.ShouldProcessBlock(req.Event.BlockNumber) {
if !agent.IsReady() || !agent.ShouldProcessBlock(req.Event.BlockNumber) {
continue
}

Expand Down Expand Up @@ -293,7 +293,7 @@ func (ap *AgentPool) SendEvaluateAlertRequest(req *protocol.EvaluateAlertRequest
continue
}

if !agent.IsInitialized() {
if !agent.IsReady() {
continue
}
target = agent
Expand Down
7 changes: 7 additions & 0 deletions services/scanner/agentpool/poolagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ func (agent *Agent) processTransactions() {
"evaluate": "transaction",
},
)
// wait for initialization to start processing
<-agent.Initialized()

for request := range agent.txRequests {
if exit := agent.processTransaction(lg, request); exit {
Expand Down Expand Up @@ -447,6 +449,8 @@ func (agent *Agent) processBlocks() {
"evaluate": "block",
},
)
// wait for initialization to start processing
<-agent.Initialized()

for request := range agent.blockRequests {
if exit := agent.processBlock(lg, request); exit {
Expand Down Expand Up @@ -528,6 +532,9 @@ func (agent *Agent) processCombinationAlerts() {
},
)

// wait for initialization to start processing
<-agent.Initialized()

for request := range agent.combinationRequests {
if exit := agent.processCombinationAlert(lg, request); exit {
return
Expand Down