Help us shape the future of Go! Take the 2026 Go Developer Survey

threshold

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ThresholdExecute

type ThresholdExecute[ITEM any] struct {
	// contains filtered or unexported fields
}

ThresholdExecute 阈值执行, 超过阈值就执行. 必须调用AsyncExecute才能执行. 默认 batchsize 128 periodic 100ms

func NewThresholdExecute

func NewThresholdExecute[ITEM any](itemDo func(i int, item ITEM)) *ThresholdExecute[ITEM]

func (*ThresholdExecute[ITEM]) AsyncExecute added in v0.1.0

func (exec *ThresholdExecute[ITEM]) AsyncExecute() *ThresholdExecute[ITEM]

AsyncExecute 返回自身. 方便与With设置连用

func (*ThresholdExecute[ITEM]) Collect

func (exec *ThresholdExecute[ITEM]) Collect(item ITEM)

Collect 收集数据

func (*ThresholdExecute[ITEM]) Stop

func (pe *ThresholdExecute[ITEM]) Stop()

Stop 停止执行

func (*ThresholdExecute[ITEM]) WithBatchSize added in v0.1.0

func (pe *ThresholdExecute[ITEM]) WithBatchSize(bsize int) *ThresholdExecute[ITEM]

func (*ThresholdExecute[ITEM]) WithBatchSizeHandler added in v0.1.0

func (pe *ThresholdExecute[ITEM]) WithBatchSizeHandler(itemSizeDo func(i int, item ITEM)) *ThresholdExecute[ITEM]

func (*ThresholdExecute[ITEM]) WithPeriodic added in v0.1.0

func (pe *ThresholdExecute[ITEM]) WithPeriodic(per time.Duration) *ThresholdExecute[ITEM]

func (*ThresholdExecute[ITEM]) WithPeriodicHandler added in v0.1.0

func (pe *ThresholdExecute[ITEM]) WithPeriodicHandler(itemPeriodicDo func(i int, item ITEM)) *ThresholdExecute[ITEM]

func (*ThresholdExecute[ITEM]) WithRecover added in v0.1.0

func (pe *ThresholdExecute[ITEM]) WithRecover(recoverDo func(ierr any)) *ThresholdExecute[ITEM]

Jump to

Keyboard shortcuts

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