queue

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	Object interface{}
	// Async can let workers handle this task concurrently, but
	// it will make this task unordered
	Async bool
}

type TaskQueue

type TaskQueue struct {
	Workers []Worker
	// contains filtered or unexported fields
}

func NewTaskQueue

func NewTaskQueue(size int) *TaskQueue

func (*TaskQueue) Add

func (q *TaskQueue) Add(t Task)

Add is the method to add task in queue, one task will be handled by all workers

func (*TaskQueue) AddWorker

func (q *TaskQueue) AddWorker(w Worker)

AddWorker is the method to add Worker

func (*TaskQueue) Do

func (q *TaskQueue) Do(ctx context.Context, task Task)

Do is the method to trigger workers handle the task immediately

func (*TaskQueue) Run

func (q *TaskQueue) Run()

Run is the method to start a goroutine to pull and handle tasks from queue

func (*TaskQueue) Stop

func (q *TaskQueue) Stop()

Stop is the method to stop the workers gracefully

type UniQueue

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

func NewUniQueue

func NewUniQueue() (uq *UniQueue)

func (*UniQueue) Chan

func (uq *UniQueue) Chan() <-chan interface{}

func (*UniQueue) Close

func (uq *UniQueue) Close()

func (*UniQueue) Get

func (uq *UniQueue) Get(ctx context.Context) interface{}

func (*UniQueue) Put

func (uq *UniQueue) Put(value interface{}) (e error)

type Worker

type Worker interface {
	Handle(ctx context.Context, obj interface{})
}

Jump to

Keyboard shortcuts

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