pipeline

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pkg/sync/pipeline

提供内存批量聚合工具

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFull = errors.New("channel full")

ErrFull channel full error

Functions

This section is empty.

Types

type Config

type Config struct {
	// MaxSize merge size
	MaxSize int
	// Interval merge interval
	Interval xtime.Duration
	// Buffer channel size
	Buffer int
	// Worker channel number
	Worker int
	// Name use for metrics
	Name string
}

Config Pipeline config

type Pipeline

type Pipeline struct {
	Do    func(c context.Context, index int, values map[string][]interface{})
	Split func(key string) int
	// contains filtered or unexported fields
}

Pipeline pipeline struct

func NewPipeline

func NewPipeline(config *Config) (res *Pipeline)

NewPipeline new pipline

func (*Pipeline) Add

func (p *Pipeline) Add(c context.Context, key string, value interface{}) (err error)

Add async add a value to channal, channel shard in split method

func (*Pipeline) Close

func (p *Pipeline) Close() (err error)

Close all goroutinue

func (*Pipeline) Start

func (p *Pipeline) Start()

Start start all mergeproc

func (*Pipeline) SyncAdd

func (p *Pipeline) SyncAdd(c context.Context, key string, value interface{}) (err error)

SyncAdd sync add a value to channal, channel shard in split method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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