queue

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue interface {
	// Logger 设置logger
	Logger(logger log.Log)
	// ConsumeFixed 设置消费函数,函数必须为:funcType
	ConsumeFixed(f funcType) Queue
	// ConsumeFlexible 设置消费函数,推荐此方法, 参数可以为空,无返回值
	// 添加任务,函数格式必须为:
	//    taskfunc(param ...interface{})
	//    或自定义参数
	//    taskfunc(i int, s string, arr []int)
	ConsumeFlexible(f any) Queue
	// AddMsg 添加消息, 数据必须与注册的消费者参数一致
	AddMsg(param ...any) Queue
	// IsFinished 判断是否全部消费
	IsFinished() bool
	// Destruction 销毁队列
	Destruction()
	// WaitFinish 等待任务完成通知
	WaitFinish()
}

Queue 无序任务队列

func NewQueue

func NewQueue(ctx context.Context, concurrency, queueLen int) Queue

type SortedQueue

type SortedQueue interface {
	// Logger 设置logger
	Logger(logger log.Log)
	// ConsumeFixed 设置消费函数,函数必须为:funcType
	ConsumeFixed(f funcType) SortedQueue
	// ConsumeFlexible 设置消费函数,推荐此方法, 参数可以为空,无返回值
	// 添加任务,函数格式必须为:
	//    taskfunc(param ...interface{})
	//    或自定义参数
	//    taskfunc(i int, s string, arr []int)
	ConsumeFlexible(f any) SortedQueue
	// AddMsg 添加消息, 数据必须与注册的消费者参数一致
	AddMsg(param ...any) SortedQueue
	// IsFinished 判断是否全部消费
	IsFinished() bool
	// Destruction 销毁队列
	Destruction()
	// WaitFinish 等待任务完成通知
	WaitFinish()
}

SortedQueue 顺序任务队列,执行顺序与添加顺序一致

func NewSortedQueue

func NewSortedQueue(ctx context.Context, queueLen int) SortedQueue

Jump to

Keyboard shortcuts

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