queue

package
v0.21.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package queue provides a simple list mechanism with some helper functions to determine current counts based on resource type or state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IItem

type IItem interface {
	resource.Resource
	Print()
	List() ([]resource.Resource, error)
	GetProperty(key string) (string, error)
	Equals(resource.Resource) bool
	GetState() ItemState
}

type IQueue

type IQueue interface {
	Total() int
	Count(states ...ItemState) int
}

type Item

type Item struct {
	Resource resource.Resource
	State    ItemState
	Reason   string
	Type     string
	Owner    string // region/subscription
	Opts     interface{}
}

Item is used to represent a specific resource, and it's current ItemState in the Queue

func (*Item) Equals

func (i *Item) Equals(o resource.Resource) bool

Equals checks if the current Item is identical to the argument Item in the Queue.

func (*Item) GetProperty

func (i *Item) GetProperty(key string) (string, error)

GetProperty retrieves the string value of a property on the Item's Resource if it exists.

func (*Item) GetReason

func (i *Item) GetReason() string

GetReason returns the current Reason for the Item which is usually coupled with an error

func (*Item) GetState

func (i *Item) GetState() ItemState

GetState returns the current State of the Item

func (*Item) List

func (i *Item) List(ctx context.Context, opts interface{}) ([]resource.Resource, error)

List calls the List method for the lister for the Type that belongs to the Item which returns a list of resources or an error. This primarily is used for the HandleWait function.

func (*Item) Print

func (i *Item) Print()

Print displays the current status of an Item based on it's State

type ItemState

type ItemState int
const (
	ItemStateNew ItemState = iota
	ItemStateNewDependency
	ItemStateHold
	ItemStatePending
	ItemStatePendingDependency
	ItemStateWaiting
	ItemStateFailed
	ItemStateFiltered
	ItemStateFinished
)

type Queue

type Queue struct {
	Items []*Item
}

Queue provides a very simple interface for queuing Item for processing

func New added in v0.7.3

func New() *Queue

New creates a new Queue

func (Queue) Count

func (q Queue) Count(states ...ItemState) int

Count returns the total number of items in a specific ItemState from the Queue

func (Queue) CountByType

func (q Queue) CountByType(resourceType string, states ...ItemState) int

CountByType returns the total number of items that match a ResourceType and specific ItemState from the Queue

func (Queue) GetItems

func (q Queue) GetItems() []*Item

GetItems returns all the items currently in the Queue

func (Queue) Total

func (q Queue) Total() int

Total returns the total number of items in the Queue

Jump to

Keyboard shortcuts

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