mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
watchtower/wtdb: add a generic Queue interface
This commit is contained in:
parent
01e2f10797
commit
a946715b7e
1 changed files with 22 additions and 0 deletions
22
watchtower/wtdb/queue.go
Normal file
22
watchtower/wtdb/queue.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package wtdb
|
||||
|
||||
import "errors"
|
||||
|
||||
// ErrEmptyQueue is returned from Pop if there are no items left in the Queue.
|
||||
var ErrEmptyQueue = errors.New("queue is empty")
|
||||
|
||||
// Queue is an interface describing a FIFO queue for any generic type T.
|
||||
type Queue[T any] interface {
|
||||
// Len returns the number of tasks in the queue.
|
||||
Len() (uint64, error)
|
||||
|
||||
// Push pushes new T items to the tail of the queue.
|
||||
Push(items ...T) error
|
||||
|
||||
// PopUpTo attempts to pop up to n items from the head of the queue. If
|
||||
// no more items are in the queue then ErrEmptyQueue is returned.
|
||||
PopUpTo(n int) ([]T, error)
|
||||
|
||||
// PushHead pushes new T items to the head of the queue.
|
||||
PushHead(items ...T) error
|
||||
}
|
Loading…
Add table
Reference in a new issue