package volumequeue

import "github.com/moby/swarmkit/v2/volumequeue"

Index

Types

type VolumeQueue

type VolumeQueue struct {
	sync.Mutex
	// contains filtered or unexported fields
}

VolumeQueue manages the exponential backoff of retrying volumes. it behaves somewhat like a priority queue. however, the key difference is that volumes which are ready to process or reprocess are read off of an unbuffered channel, meaning the order in which ready volumes are processed is at the mercy of the golang scheduler. in practice, this does not matter.

func NewVolumeQueue

func NewVolumeQueue() *VolumeQueue

NewVolumeQueue returns a new VolumeQueue with the default timerSource.

func (*VolumeQueue) Enqueue

func (vq *VolumeQueue) Enqueue(id string, attempt uint)

Enqueue adds an entry to the VolumeQueue with the specified retry attempt. if an entry for the specified id already exists, enqueue will remove it and create a new entry.

func (*VolumeQueue) Outstanding

func (vq *VolumeQueue) Outstanding() int

Outstanding returns the number of items outstanding in this queue

func (*VolumeQueue) Stop

func (vq *VolumeQueue) Stop()

Stop stops the volumeQueue and cancels all outstanding entries. stop may only be called once.

func (*VolumeQueue) Wait

func (vq *VolumeQueue) Wait() (string, uint)

Wait returns the ID and attempt number of the next Volume ready to process. If no volume is ready, wait blocks until one is ready. if the volumeQueue is stopped, wait returns "", 0

Source Files

doc.go queue.go

Version
v2.0.0-20250103191802-8c1959736554 (latest)
Published
Jan 3, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
4 days ago

Tools for package owners.