Skip to content

Commit

Permalink
Disable aggregate updates with global config param (ava-labs#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasinco authored Nov 23, 2020
1 parent a115384 commit 85538e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cfg/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ package cfg
import "time"

// RequestTimeout is the maximum duration to allow an API request to execute
const RequestTimeout = 2 * time.Minute
const (
RequestTimeout = 2 * time.Minute
)
12 changes: 8 additions & 4 deletions services/indexes/avm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"reflect"
"time"

"github.com/ava-labs/ortelius/stream"

"github.com/ava-labs/avalanchego/ids"

"github.com/ava-labs/avalanchego/genesis"
Expand Down Expand Up @@ -136,10 +138,12 @@ func (w *Writer) Consume(ctx context.Context, i services.Consumable) error {
job.Complete(health.Success)
}()

// fire and forget..
// update the created_at on the state table if we have an earlier date in ctx.Time().
// which means we need to re-run aggregation calculations from this earlier date.
_, _ = models.UpdateAvmAssetAggregationLiveStateTimestamp(ctx, sess, time.Unix(i.Timestamp(), 0))
if stream.IndexerTaskEnabled {
// fire and forget..
// update the created_at on the state table if we have an earlier date in ctx.Time().
// which means we need to re-run aggregation calculations from this earlier date.
_, _ = models.UpdateAvmAssetAggregationLiveStateTimestamp(ctx, sess, time.Unix(i.Timestamp(), 0))
}

// Create db tx
var dbTx *dbr.Tx
Expand Down
4 changes: 3 additions & 1 deletion services/indexes/pvm/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"reflect"
"time"

"github.com/ava-labs/ortelius/stream"

"github.com/ava-labs/ortelius/services/db"

"github.com/ava-labs/avalanchego/genesis"
Expand Down Expand Up @@ -64,7 +66,7 @@ func (w *Writer) Consume(ctx context.Context, c services.Consumable) error {
job := w.conns.Stream().NewJob("index")
sess := w.conns.DB().NewSessionForEventReceiver(job)

if false {
if stream.IndexerTaskEnabled {
// fire and forget..
// update the created_at on the state table if we have an earlier date in ctx.Time().
// which means we need to re-run aggregation calculations from this earlier date.
Expand Down
9 changes: 6 additions & 3 deletions stream/indexer_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var (

// number of updaters
updatesCount = 4

IndexerTaskEnabled = false
)

type ProducerTasker struct {
Expand Down Expand Up @@ -479,11 +481,12 @@ func (t *ProducerTasker) replaceAvmAggregateCount(avmAggregatesCount models.AvmA
}

func (t *ProducerTasker) Start() {
if !IndexerTaskEnabled {
return
}
t.initMetrics()

if false {
go initRefreshAggregatesTick(t)
}
go initRefreshAggregatesTick(t)
}

func (t *ProducerTasker) initMetrics() {
Expand Down

0 comments on commit 85538e9

Please sign in to comment.