mfr

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusNone   = iota
	StatusQueued // waiting to get to the top
	StatusActive // being processed
	StatusDone   // done processing
)

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(l *zap.SugaredLogger)

Types

type Item

type Item struct {
	Value interface{}
	// contains filtered or unexported fields
}

Item is a queue storage unit.

func (*Item) Age

func (i *Item) Age() int

Age returns how many seconds have passed since the item was created.

func (*Item) Done

func (i *Item) Done()

Done marks the item as fully processed (it won't stop registering hits).

func (*Item) Hits

func (i *Item) Hits() uint

Hits returns the number of hits for the item.

func (*Item) Release

func (i *Item) Release()

Release returns the item back into the queue for future possibility to be `Pop`ped again (it won't stop registering hits).

type Position

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

type Queue

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

Queue stores a priority queue with Items with most Hits being at the top.

func NewQueue

func NewQueue() *Queue

NewQueue initializes an empty priority queue suitable for registering Hits right away.

func (*Queue) Done

func (q *Queue) Done(key string)

Done marks the queue item as fully processed.

func (*Queue) Get

func (q *Queue) Get(key string) (*Item, int)

Get retrieves item by key along with its processing status.

func (*Queue) Hit

func (q *Queue) Hit(key string, value interface{})

Hit puts Item stoStatusActive at `key` higher up in the queue, or inserts it to the bottom of the pile if the item is not present.

func (*Queue) Hits

func (q *Queue) Hits() uint

func (*Queue) MinPeek

func (q *Queue) MinPeek(minHits uint) *Item

MinPeek returns the top-most item of the queue if it has a required minimum of hits, without marking it as being processed.

func (*Queue) MinPop

func (q *Queue) MinPop(minHits uint) *Item

MinPop returns the top-most item of the queue if it has a required minimum of hits and marks it as being processed so consecutive calls will return subsequent items.

func (*Queue) Peek

func (q *Queue) Peek() *Item

Peek returns the top-most item of the queue without marking it as being processed.

func (*Queue) Pop

func (q *Queue) Pop() *Item

Pop returns the top-most item of the queue and marks it as being processed so consecutive calls will return subsequent items.

func (*Queue) Release

func (q *Queue) Release(key string)

Release returns the item back into the queue for future possibility to be `Pop`ped again.

func (*Queue) Size

func (q *Queue) Size() uint

Jump to

Keyboard shortcuts

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