queue

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists error = errors.New(`item already exists in the queue`)
View Source
var ErrItemNoID error = errors.New(`item must have ID`)
View Source
var ErrNotEnoughWorkers = errors.New("queue requires >= 1 workers")
View Source
var ErrNotFound error = errors.New(`item not found in the queue`)
View Source
var ErrQueueFull = errors.New("queue is full")

Functions

This section is empty.

Types

type Item

type Item struct {
	ID       string
	Dag      []*dag.Node[dag.IOSpec]
	CID      string
	Metadata ItemMetadata
}

Item is an item in the QueueRepository

type ItemMetadata

type ItemMetadata struct {
	CreatedAt time.Time
	StartedAt time.Time
	EndedAt   time.Time
}

type Queue

type Queue interface {
	Enqueue(func(context.Context)) error // Adds item to the queue
	Start()                              // Starts the processing of the queue
	Stop()                               // Stops the processing of the queue
}

Queue encapsulates the Enqueue method that will be called by a dispatcher

func NewGenericQueue

func NewGenericQueue(ctx context.Context, numWorkers int, maxQueueSize int) (Queue, error)

type QueueRepository

type QueueRepository interface {
	List(context.Context) ([]*Item, error)
	Get(context.Context, string) (*Item, error)
	Create(context.Context, Item) error
}

QueueRepository is a store of Queue items

func NewQueueRepository

func NewQueueRepository(queue Queue) QueueRepository

NewQueueRepository creates a repository that returns queue information

Jump to

Keyboard shortcuts

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