queue

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// GoroutinePoolSize maximum number of running goroutine instances.
	GoPoolSize int `yaml:"goPoolSize" json:"goPoolSize"`
	// Size size of queue. If it exhausted Submit returns error.
	Size int `yaml:"size" json:"size"`
	// MaxIdleTime sets up the interval time of cleaning up goroutines, 0 means never cleanup.
	MaxIdleTime time.Duration `yaml:"maxIdleTime" json:"maxIdleTime"`
}

Config configuration for task queue.

func (*Config) Validate

func (c *Config) Validate() error

SetDefaults set zero values to defaults.

type Queue

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

Queue representation of task queue.

func New

func New(cfg Config) (*Queue, error)

New creates task queue which is processed by goroutines.

func (*Queue) Release

func (q *Queue) Release()

Release closes queue and release it.

func (*Queue) Submit

func (q *Queue) Submit(tasks ...func()) error

Submit appends and execute task by Queue.

func (*Queue) SubmitForOneWorker added in v2.2.4

func (q *Queue) SubmitForOneWorker(key interface{}, tasks ...func()) error

SubmitForOneWorker function adds tasks to the Queue by key. The tasks in the Queue are executed in the order they are submitted by the Goroutine.

Jump to

Keyboard shortcuts

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