executor

package
v0.38.0-pr6970-add-ser... Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterateExecuteAndCommitInBatch

func IterateExecuteAndCommitInBatch(

	iter module.BlockIterator,

	executor IterationExecutor,

	db storage.DB,

	isBatchFull IsBatchFull,

	sleeper Sleeper,
) 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 IsBatchFull

type IsBatchFull func(iteratedCountInCurrentBatch int) bool

IsBatchFull decides the batch size for each commit. it takes the number of blocks iterated in the current batch, and returns whether the batch is full.

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.

type Sleeper

type Sleeper func()

Sleeper allows the caller to slow down the iteration after each batch is committed

Jump to

Keyboard shortcuts

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