executor

package
v0.39.0-cdp-engine-met... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateProgress

func CalculateProgress(start, end, current uint64) float64

CalculateProgress calculates the progress of the iteration, it returns a percentage of the progress. [0, 100]

func IterateExecuteAndCommitInBatch

func IterateExecuteAndCommitInBatch(

	ctx context.Context,
	log zerolog.Logger,
	metrics module.ExecutionMetrics,

	iter module.BlockIterator,

	executor IterationExecutor,

	db storage.DB,

	batchSize uint,

	sleepAfterEachBatchCommit time.Duration,
) error

IterateExecuteAndCommitInBatch iterates over blocks and execute tasks with data that was indexed by the block. the update to the storage database is done in batch, and the batch is committed when it's full. the iteration progress is saved after batch is committed, so that the iteration progress can be resumed after restart. it sleeps after each batch is committed in order to minimizing the impact on the system.

Types

type AggregatedExecutor

type AggregatedExecutor struct {
	// contains filtered or unexported fields
}

AggregatedExecutor allows to aggregate multiple IterationExecutor instances into one so that they can be executed in a single call within the same batch.

func NewAggregatedExecutor

func NewAggregatedExecutor(executors []IterationExecutor) *AggregatedExecutor

func (*AggregatedExecutor) ExecuteByBlockID

func (a *AggregatedExecutor) ExecuteByBlockID(blockID flow.Identifier, batch storage.ReaderBatchWriter) (exception error)

type IterationExecutor

type IterationExecutor interface {
	// ExecuteByBlockID executes the task for the block indexed by the blockID
	ExecuteByBlockID(blockID flow.Identifier, batch storage.ReaderBatchWriter) (exception error)
}

IterationExecutor allows the caller to customize the task to be executed for each block. for instance, the executor can prune data indexed by the block, or build another index for each iterated block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL