Documentation
¶
Index ¶
- type ExpireQueue
- func (q *ExpireQueue) AddGroup(interval time.Duration)
- func (q *ExpireQueue) AddGroupRepeat(n int, in time.Duration)
- func (q *ExpireQueue) AddHandler(handler ItemExpireHandler)
- func (q *ExpireQueue) Push(key string, item interface{})
- func (q *ExpireQueue) Remove(key string)
- func (q *ExpireQueue) Size() int
- type IDoubleKeyQueue
- type IDoubleKeyQueueItem
- type IKeyPriorityQueue
- type IKeyQueueItem
- type IPriorityQueue
- type IPriorityQueueItem
- type ItemExpireHandler
- type LinkedQueue
- type PriorityQueue
- func (q *PriorityQueue) Clear()
- func (q *PriorityQueue) Iter(f func(IPriorityQueueItem) bool)
- func (q *PriorityQueue) Peek() IPriorityQueueItem
- func (q *PriorityQueue) Pop() IPriorityQueueItem
- func (q *PriorityQueue) Push(v IPriorityQueueItem)
- func (q *PriorityQueue) Remove(i int)
- func (q *PriorityQueue) Size() int
- type PriorityType
- type Queue
- type SortedQueue
- func (q *SortedQueue) Find(Priority uint64) interface{}
- func (q *SortedQueue) FindOrInsert(value interface{}, Priority uint64) interface{}
- func (q *SortedQueue) Insert(value interface{}, Priority uint64)
- func (q *SortedQueue) Iter(fn func(v interface{}, priority uint64))
- func (q *SortedQueue) Peek() (interface{}, uint64)
- func (q *SortedQueue) Pop() interface{}
- func (q *SortedQueue) PopUntil(Priority uint64) interface{}
- func (q *SortedQueue) Size() int
- type TxExpiredType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpireQueue ¶
ExpireQueue provides sequential expirations by groups
func (*ExpireQueue) AddGroup ¶
func (q *ExpireQueue) AddGroup(interval time.Duration)
AddGroup adds and runs a expire gruop
func (*ExpireQueue) AddGroupRepeat ¶
func (q *ExpireQueue) AddGroupRepeat(n int, in time.Duration)
AddGroupRepeat adds and runs a expire gruop n times
func (*ExpireQueue) AddHandler ¶
func (q *ExpireQueue) AddHandler(handler ItemExpireHandler)
AddHandler adds a item expire handler
func (*ExpireQueue) Push ¶
func (q *ExpireQueue) Push(key string, item interface{})
Push adds a item to the expiration flow
func (*ExpireQueue) Remove ¶
func (q *ExpireQueue) Remove(key string)
Remove removes a item from the expiration flow
type IDoubleKeyQueue ¶
type IDoubleKeyQueue interface { Push(v IDoubleKeyQueueItem) Pop() IDoubleKeyQueueItem Peek() IDoubleKeyQueueItem DPeek() IKeyPriorityQueue Get(key interface{}) IDoubleKeyQueueItem DGet(key interface{}) IKeyPriorityQueue RemoveKey(key interface{}) List() []IDoubleKeyQueueItem Iter(f func(IDoubleKeyQueueItem) bool) Size() int Clear() }
func NewDoubleKeyPriorityQueue ¶
func NewDoubleKeyPriorityQueue(pt PriorityType) IDoubleKeyQueue
type IDoubleKeyQueueItem ¶
type IDoubleKeyQueueItem interface { IKeyQueueItem DKey() interface{} DPriority() uint64 }
type IKeyPriorityQueue ¶
type IKeyPriorityQueue interface { Push(v IKeyQueueItem) Pop() IKeyQueueItem Peek() IKeyQueueItem Get(key interface{}) IKeyQueueItem RemoveKey(key interface{}) Iter(f func(IKeyQueueItem) bool) Size() int Clear() }
func NewKeyPriorityQueue ¶
func NewKeyPriorityQueue(highest PriorityType) IKeyPriorityQueue
type IKeyQueueItem ¶
type IKeyQueueItem interface { Key() interface{} // contains filtered or unexported methods }
func NewKeyPriorityQueueItem ¶
func NewKeyPriorityQueueItem(i IKeyQueueItem) IKeyQueueItem
type IPriorityQueue ¶
type IPriorityQueue interface { Push(v IPriorityQueueItem) Pop() IPriorityQueueItem Peek() IPriorityQueueItem Iter(f func(IPriorityQueueItem) bool) Remove(index int) Size() int Clear() }
func NewPriorityQueue ¶
func NewPriorityQueue(pt PriorityType) IPriorityQueue
type IPriorityQueueItem ¶
type IPriorityQueueItem interface { Index() int // contains filtered or unexported methods }
func NewPriorityQueueItem ¶
func NewPriorityQueueItem(v iPriorityQueueItem) IPriorityQueueItem
type ItemExpireHandler ¶
type ItemExpireHandler interface { // OnItemExpired is called when the item is expired OnItemExpired(interval time.Duration, key string, item interface{}, IsLast bool) TxExpiredType }
ItemExpireHandler handles a group expire event
type LinkedQueue ¶
type LinkedQueue struct { sync.Mutex Head *linkedItem Tail *linkedItem // contains filtered or unexported fields }
LinkedQueue is designed to allow users to remove the item by the key
func (*LinkedQueue) Iter ¶
func (q *LinkedQueue) Iter(fn func(keyMap hash.Hash256, v interface{}))
Iter iterates queue items
func (*LinkedQueue) Pop ¶
func (q *LinkedQueue) Pop() interface{}
Pop returns a item at the top of the queue
func (*LinkedQueue) Push ¶
func (q *LinkedQueue) Push(Key hash.Hash256, item interface{}) bool
Push inserts the item with the key at the bottom of the queue
func (*LinkedQueue) Remove ¶
func (q *LinkedQueue) Remove(Key hash.Hash256) interface{}
Remove deletes a item by the key
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
A PriorityQueue implements heap.Interface and holds Items.
func (*PriorityQueue) Iter ¶
func (q *PriorityQueue) Iter(f func(IPriorityQueueItem) bool)
Iter iterates queue items
func (*PriorityQueue) Peek ¶
func (q *PriorityQueue) Peek() IPriorityQueueItem
func (*PriorityQueue) Pop ¶
func (q *PriorityQueue) Pop() IPriorityQueueItem
func (*PriorityQueue) Push ¶
func (q *PriorityQueue) Push(v IPriorityQueueItem)
type Queue ¶
Queue provides a basic queue ability with the peek method
type SortedQueue ¶
SortedQueue sorts items by the priority
func (*SortedQueue) Find ¶
func (q *SortedQueue) Find(Priority uint64) interface{}
Find fetch the target priority item without removing it
func (*SortedQueue) FindOrInsert ¶
func (q *SortedQueue) FindOrInsert(value interface{}, Priority uint64) interface{}
FindOrInsert finds the item of the priority if it exists or inserts the item by the priority
func (*SortedQueue) Insert ¶
func (q *SortedQueue) Insert(value interface{}, Priority uint64)
Insert inserts the item by the priority
func (*SortedQueue) Iter ¶
func (q *SortedQueue) Iter(fn func(v interface{}, priority uint64))
Iter iterates queue items
func (*SortedQueue) Peek ¶
func (q *SortedQueue) Peek() (interface{}, uint64)
Peek fetch the top item without removing it
func (*SortedQueue) Pop ¶
func (q *SortedQueue) Pop() interface{}
Pop returns a item at the top of the queue
func (*SortedQueue) PopUntil ¶
func (q *SortedQueue) PopUntil(Priority uint64) interface{}
PopUntil returns a item at the top of the queue
type TxExpiredType ¶
type TxExpiredType int
const ( Resend TxExpiredType = iota Expired Remain Error )
func (TxExpiredType) String ¶
func (m TxExpiredType) String() string