queue

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendIDGetter

type BackendIDGetter interface {
	GetBackendID() int64
}

type EtcdGetter

type EtcdGetter struct {
	Client          *clientv3.Client
	BackendIDGetter BackendIDGetter
}

EtcdGetter provides access to the etcd client for creating a new queue.

func (EtcdGetter) GetQueue

func (e EtcdGetter) GetQueue(path ...string) types.Queue

GetQueue gets a new Queue.

type Item

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

Item is a Queue item.

func (*Item) Ack

func (i *Item) Ack(ctx context.Context) error

Ack acknowledges the Item has been received and processed, and deletes it from the in flight lane.

func (*Item) Key

func (i *Item) Key() string

Key returns the key of the Item.

func (*Item) Nack

func (i *Item) Nack(ctx context.Context) error

Nack returns the Item to the work queue and deletes it from the in-flight lane.

func (*Item) Value

func (i *Item) Value() string

Value returns the value of the Item.

type Memory

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

Memory is an implementation of types.Queue in memory, provided for testing purposes.

func (*Memory) Dequeue

func (m *Memory) Dequeue(context.Context) (types.QueueItem, error)

Dequeue ...

func (*Memory) Enqueue

func (m *Memory) Enqueue(_ context.Context, val string) error

Enqueue ...

type MemoryGetter

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

MemoryGetter is a types.QueueGetter.

func NewMemoryGetter

func NewMemoryGetter() *MemoryGetter

NewMemoryGetter creates a new MemoryGetter.

func (*MemoryGetter) GetQueue

func (m *MemoryGetter) GetQueue(path ...string) types.Queue

GetQueue gets a Memory queue.

type MemoryItem

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

MemoryItem is an item from MemoryQueue.

func (*MemoryItem) Ack

func (m *MemoryItem) Ack(context.Context) error

Ack ...

func (*MemoryItem) Nack

func (m *MemoryItem) Nack(context.Context) error

Nack ...

func (*MemoryItem) Value

func (m *MemoryItem) Value() string

Value ...

type Queue

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

Queue is a non-durable FIFO queue that is backed by etcd. When an item is received by a client, it is deleted from the work lane, and added to the in-flight lane. The item stays in the in-flight lane until it is Acked by the client, or returned to the work lane with Nack.

func New

func New(name string, client *clientv3.Client, backendIDGetter BackendIDGetter) *Queue

New returns an instance of Queue.

func (*Queue) Dequeue

func (q *Queue) Dequeue(ctx context.Context) (types.QueueItem, error)

Dequeue gets a value from the queue. It returns an error if the context is cancelled, the deadline exceeded, or if the client encounters an error.

func (*Queue) Enqueue

func (q *Queue) Enqueue(ctx context.Context, value string) error

Enqueue adds a new value to the queue. It returns an error if the context is canceled, the deadline exceeded, or if the client encounters an error.

Jump to

Keyboard shortcuts

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