queue

package module
v0.0.0-...-1449df2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 2 Imported by: 1

README

pgk queue

This package contains a simple general queue for all data types.

The queue ensures processing with the FIFO principle.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	Process(q *Queue)
}

type Queue

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

func New

func New(consumer Consumer) *Queue

New creates a new Queue and returns *Queue.

func (*Queue) Add

func (q *Queue) Add(v interface{})

Add adds a new commit string as element to the Queue and initiate a threaded processing.

func (*Queue) Current

func (q *Queue) Current() interface{}

Current returns the current element

func (*Queue) Finish

func (q *Queue) Finish(success bool)

Finish finishes the current element processing of the queue and unlock the mutex.

func (*Queue) LastSuccessful

func (q *Queue) LastSuccessful() interface{}

LastSuccessful returns the last successful processed element

func (*Queue) Previous

func (q *Queue) Previous() interface{}

Previous returns the previous element

func (*Queue) StartNext

func (q *Queue) StartNext() interface{}

StartNext returns the next element in the queue and clean the queue by one. It also Locks a Mutex. Must be finalized with Finish() to unlock the mutex.

func (*Queue) Status

func (q *Queue) Status() Status

Status returns the status of the current processed element

type Status

type Status string
const (
	Init       Status = "Init"
	InProgress Status = "InProgress"
	Failed     Status = "Failed"
	Successful Status = "Successful"
)

Jump to

Keyboard shortcuts

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