flushqueues

package
v0.0.0-...-bfa2730 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExclusiveQueues

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

func New

func New(queues int, metric prometheus.Gauge) *ExclusiveQueues

New creates a new set of flush queues with a prom gauge to track current depth

func (*ExclusiveQueues) Clear

func (f *ExclusiveQueues) Clear(op Op)

Clear unblocks the requested op. This should be called only after a flush has been successful

func (*ExclusiveQueues) Dequeue

func (f *ExclusiveQueues) Dequeue(q int) Op

Dequeue removes the next op from the requested queue. After dequeueing the calling process either needs to call ClearKey or Requeue

func (*ExclusiveQueues) Enqueue

func (f *ExclusiveQueues) Enqueue(op Op) error

Enqueue adds the op to the next queue and prevents any other items to be added with this key

func (*ExclusiveQueues) IsEmpty

func (f *ExclusiveQueues) IsEmpty() bool

func (*ExclusiveQueues) IsStopped

func (f *ExclusiveQueues) IsStopped() bool

func (*ExclusiveQueues) Requeue

func (f *ExclusiveQueues) Requeue(op Op) error

Requeue adds an op that is presumed to already be covered by activeKeys

func (*ExclusiveQueues) Stop

func (f *ExclusiveQueues) Stop()

Stop closes all queues

type Op

type Op interface {
	Key() string
	Priority() int64 // The larger the number the higher the priority.
}

Op is an operation on the priority queue.

type PriorityQueue

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

PriorityQueue is a priority queue.

func NewPriorityQueue

func NewPriorityQueue(lengthGauge prometheus.Gauge) *PriorityQueue

NewPriorityQueue makes a new priority queue.

func (*PriorityQueue) Close

func (pq *PriorityQueue) Close()

Close signals that the queue should be closed when it is empty. A closed queue will not accept new items.

func (*PriorityQueue) Dequeue

func (pq *PriorityQueue) Dequeue() Op

Dequeue will return the op with the highest priority; block if queue is empty; returns nil if queue is closed.

func (*PriorityQueue) DiscardAndClose

func (pq *PriorityQueue) DiscardAndClose()

DiscardAndClose closes the queue and removes all the items from it.

func (*PriorityQueue) Enqueue

func (pq *PriorityQueue) Enqueue(op Op) (bool, error)

Enqueue adds an operation to the queue in priority order. Returns true if added; false if the operation was already on the queue.

func (*PriorityQueue) Length

func (pq *PriorityQueue) Length() int

Length returns the length of the queue.

Jump to

Keyboard shortcuts

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