collectorbatch

package
v0.0.0-...-7107d2d Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBlockDataOutOfLimit = errors.New("block data out of limit")

ErrBlockDataOutOfLimit is returned when the block data is out of limit

Functions

This section is empty.

Types

type BatchInfo

type BatchInfo struct {
	// Kind is a kind of batch limit
	Kind LimitKind
	// BlocksCount is a count of blocks in batch
	BlocksCount uint
	// Len is a length of batch
	Len uint
	// Size is a size of batch
	Size uint
	// Sources is a map with info about sources
	Sources map[string]*SrcInfo
}

BatchInfo is a struct with info about batch

type CBatch

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

CBatch is a struct with info about batch

func NewBatch

func NewBatch(
	ctx context.Context,
	chName string,
	limits Limits,
	calcBatchSize func(b *executordto.Batch) (uint, error),
) *CBatch

NewBatch creates a new batch

func (*CBatch) AddIfInLimit

func (b *CBatch) AddIfInLimit(chName string, d *collectordto.BlockData) (bool, error)

AddIfInLimit adds block data to batch if batch is not limited

func (*CBatch) Deadline

func (b *CBatch) Deadline() <-chan time.Time

Deadline returns deadline channel

func (*CBatch) GetBatchForExec

func (b *CBatch) GetBatchForExec() (*executordto.Batch, *BatchInfo)

GetBatchForExec returns batch for execution

type LimitKind

type LimitKind string

LimitKind is a type for batch limit kind

const (
	// NoneLimitKind is a kind of batch limit when batch is not limited
	NoneLimitKind LimitKind = "None"
	// BlocksCountLimitKind is a kind of batch limit when batch is limited by blocks count
	BlocksCountLimitKind LimitKind = "BlocksCountLimit"
	// TimeoutLimitKind is a kind of batch limit when batch is limited by timeout
	TimeoutLimitKind LimitKind = "TimeoutLimit"
	// LenLimitKind is a kind of batch limit when batch is limited by length
	LenLimitKind LimitKind = "LenLimit"
	// SizeLimitKind is a kind of batch limit when batch is limited by size
	SizeLimitKind LimitKind = "SizeLimit"
)

type Limits

type Limits struct {
	// BlocksCountLimit is a limit for blocks count in batch
	BlocksCountLimit uint
	// TimeoutLimit is a limit for batch execution time
	TimeoutLimit time.Duration
	// LenLimit is a limit for batch length
	LenLimit uint
	// SizeLimit is a limit for batch size
	SizeLimit uint
}

Limits is a struct with limits for batch

type SrcInfo

type SrcInfo struct {
	// LastBlockNum is a number of last block from source
	LastBlockNum uint64
	// ItemsCount is a count of items from source
	ItemsCount uint
}

SrcInfo is a struct with info about source

Jump to

Keyboard shortcuts

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