queue

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnlockedCondition

func IsUnlockedCondition() expression.ConditionBuilder

IsUnlockedCondition is a global property that represents the condition for getting the next unlocked queue item.

Types

type DDBQueueItem

type DDBQueueItem struct {
	ID       string
	Data     QueueItem
	Locked   bool
	LockTime int64
	// contains filtered or unexported fields
}

DDBQueueItem represents an item in a DynamoDB queue.

func NewDDBQueueItem

func NewDDBQueueItem(data QueueItem, q *DynamoDBQueue) *DDBQueueItem

NewDDBQueueItem creates a new DDBQueueItem instance with the specified ID and data.

func NewDDBQueueItemWithOptions

func NewDDBQueueItemWithOptions(item map[string]*dynamodb.AttributeValue, q *DynamoDBQueue) *DDBQueueItem

NewDDBQueueItem creates a new DDBQueueItem instance with the specified ID, data, locked status, lock time, DynamoDB service, and logger.

func (*DDBQueueItem) AV

func (item *DDBQueueItem) AV() map[string]*dynamodb.AttributeValue

AV returns the item as a map of DynamoDB attribute values.

func (*DDBQueueItem) Lock

func (item *DDBQueueItem) Lock() error

Lock locks the item in the queue.

func (*DDBQueueItem) Unlock

func (item *DDBQueueItem) Unlock() error

Unlock unlocks the item in the queue.

type DynamoDBQueue

type DynamoDBQueue struct {
	TableName string
	QueueName string
	// contains filtered or unexported fields
}

DynamoDBQueue represents a queue backed by a DynamoDB table.

func (*DynamoDBQueue) AddItem

func (q *DynamoDBQueue) AddItem(queueItem QueueItem) error

Push adds an item to the queue.

func (*DynamoDBQueue) Done

func (q *DynamoDBQueue) Done(item QueueItem) error

Done removes the specified item from DynamoDB.

func (*DynamoDBQueue) GenerateQueueItemID

func (q *DynamoDBQueue) GenerateQueueItemID() string

GenerateQueueItemID generates a new ID for a QueueItem.

func (*DynamoDBQueue) GetNextItem

func (q *DynamoDBQueue) GetNextItem() (QueueItem, error)

Pop locks and returns the next item from the queue.

type Queue

type Queue interface {
	// AddItem adds an item to the queue.
	AddItem(item QueueItem) error
	// GetNextItem returns the next item in the queue.
	GetNextItem() (QueueItem, error)
	// Done( QueueItem ) marks the item as done.
	Done(item QueueItem) error
}

func NewDynamoDBQueue

func NewDynamoDBQueue(tableName, queueName string, svc *dynamodb.DynamoDB) (Queue, error)

NewDynamoDBQueue creates a new DynamoDBQueue instance.

type QueueItem

type QueueItem struct {
	ID        string         `json:"id"`
	Data      map[string]any `json:"data"`
	CreatedAt int64          `json:"created_at"`
}

QueueItem represents an item in the DynamoDB queue.

func NewQueueItem

func NewQueueItem(id string, data map[string]any) QueueItem

NewQueueItem creates a new QueueItem with the given ID and data.

Jump to

Keyboard shortcuts

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