{"modulePath":"github.com/RedAFD/code-core","version":"v1.14.0-rc8","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\n## Variables\n\n```go\nvar ErrAlreadyInQueue = fmt.Errorf(\"already in queue\")\n```\nErrAlreadyInQueue is returned when trying to push data to the queue that is already in the queue\n\n## Functions\n\n```go\nfunc IsErrInvalidConfiguration(err error) bool\n```\nIsErrInvalidConfiguration checks if an error is an ErrInvalidConfiguration\n\n```go\nfunc RegisteredTypesAsString() []string\n```\nRegisteredTypesAsString provides the list of requested types of queues\n\n## Types\n\n```go\ntype ByteFIFO interface {\n\t// Len returns the length of the fifo\n\tLen() int64\n\t// PushFunc pushes data to the end of the fifo and calls the callback if it is added\n\tPushFunc(data []byte, fn func() error) error\n\t// Pop pops data from the start of the fifo\n\tPop() ([]byte, error)\n\t// Close this fifo\n\tClose() error\n}\n```\nByteFIFO defines a FIFO that takes a byte array\n\n```go\ntype ByteFIFOQueue struct {\n\t*WorkerPool\n\t// contains filtered or unexported fields\n}\n```\nByteFIFOQueue is a Queue formed from a ByteFIFO and WorkerPool\n\n```go\nfunc NewByteFIFOQueue(typ Type, byteFIFO ByteFIFO, handle HandlerFunc, cfg, exemplar interface{}) (*ByteFIFOQueue, error)\n```\nNewByteFIFOQueue creates a new ByteFIFOQueue\n\n```go\nfunc (q *ByteFIFOQueue) IsEmpty() bool\n```\nIsEmpty checks if the queue is empty\n\n```go\nfunc (q *ByteFIFOQueue) IsShutdown() \u003c-chan struct{}\n```\nIsShutdown returns a channel which is closed when this Queue is shutdown\n\n```go\nfunc (q *ByteFIFOQueue) IsTerminated() \u003c-chan struct{}\n```\nIsTerminated returns a channel which is closed when this Queue is terminated\n\n```go\nfunc (q *ByteFIFOQueue) Name() string\n```\nName returns the name of this queue\n\n```go\nfunc (q *ByteFIFOQueue) Push(data Data) error\n```\nPush pushes data to the fifo\n\n```go\nfunc (q *ByteFIFOQueue) PushFunc(data Data, fn func() error) error\n```\nPushFunc pushes data to the fifo\n\n```go\nfunc (q *ByteFIFOQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun runs the bytefifo queue\n\n```go\nfunc (q *ByteFIFOQueue) Shutdown()\n```\nShutdown processing from this queue\n\n```go\nfunc (q *ByteFIFOQueue) Terminate()\n```\nTerminate this queue and close the queue\n\n```go\ntype ByteFIFOQueueConfiguration struct {\n\tWorkerPoolConfiguration\n\tWorkers int\n\tName    string\n}\n```\nByteFIFOQueueConfiguration is the configuration for a ByteFIFOQueue\n\n```go\ntype ByteFIFOUniqueQueue struct {\n\tByteFIFOQueue\n}\n```\nByteFIFOUniqueQueue represents a UniqueQueue formed from a UniqueByteFifo\n\n```go\nfunc NewByteFIFOUniqueQueue(typ Type, byteFIFO UniqueByteFIFO, handle HandlerFunc, cfg, exemplar interface{}) (*ByteFIFOUniqueQueue, error)\n```\nNewByteFIFOUniqueQueue creates a new ByteFIFOUniqueQueue\n\n```go\nfunc (q *ByteFIFOUniqueQueue) Has(data Data) (bool, error)\n```\nHas checks if the provided data is in the queue\n\n```go\ntype ChannelQueue struct {\n\t*WorkerPool\n\t// contains filtered or unexported fields\n}\n```\nChannelQueue implements Queue\n\nA channel queue is not persistable and does not shutdown or terminate cleanly It is basically a very thin wrapper around a WorkerPool\n\n```go\nfunc (q *ChannelQueue) Name() string\n```\nName returns the name of this queue\n\n```go\nfunc (q *ChannelQueue) Push(data Data) error\n```\nPush will push data into the queue\n\n```go\nfunc (q *ChannelQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun starts to run the queue\n\n```go\ntype ChannelQueueConfiguration struct {\n\tWorkerPoolConfiguration\n\tWorkers int\n\tName    string\n}\n```\nChannelQueueConfiguration is the configuration for a ChannelQueue\n\n```go\ntype ChannelUniqueQueue struct {\n\t*WorkerPool\n\t// contains filtered or unexported fields\n}\n```\nChannelUniqueQueue implements UniqueQueue\n\nIt is basically a thin wrapper around a WorkerPool but keeps a store of what has been pushed within a table.\n\nPlease note that this Queue does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\n```go\nfunc (q *ChannelUniqueQueue) Has(data Data) (bool, error)\n```\nHas checks if the data is in the queue\n\n```go\nfunc (q *ChannelUniqueQueue) Name() string\n```\nName returns the name of this queue\n\n```go\nfunc (q *ChannelUniqueQueue) Push(data Data) error\n```\nPush will push data into the queue if the data is not already in the queue\n\n```go\nfunc (q *ChannelUniqueQueue) PushFunc(data Data, fn func() error) error\n```\nPushFunc will push data into the queue\n\n```go\nfunc (q *ChannelUniqueQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun starts to run the queue\n\n```go\ntype ChannelUniqueQueueConfiguration ChannelQueueConfiguration\n```\nChannelUniqueQueueConfiguration is the configuration for a ChannelUniqueQueue\n\n```go\ntype Data interface{}\n```\nData defines an type of queuable data\n\n```go\ntype DummyByteFIFO struct{}\n```\nDummyByteFIFO represents a dummy fifo\n\n```go\nfunc (*DummyByteFIFO) Close() error\n```\nClose returns nil\n\n```go\nfunc (*DummyByteFIFO) Len() int64\n```\nLen is always 0\n\n```go\nfunc (*DummyByteFIFO) Pop() ([]byte, error)\n```\nPop returns nil\n\n```go\nfunc (*DummyByteFIFO) PushFunc(data []byte, fn func() error) error\n```\nPushFunc returns nil\n\n```go\ntype DummyQueue struct {\n}\n```\nDummyQueue represents an empty queue\n\n```go\nfunc (*DummyQueue) Flush(time.Duration) error\n```\nFlush always returns nil\n\n```go\nfunc (*DummyQueue) FlushWithContext(context.Context) error\n```\nFlushWithContext always returns nil\n\n```go\nfunc (*DummyQueue) Has(Data) (bool, error)\n```\nHas always returns false as this queue never does anything\n\n```go\nfunc (*DummyQueue) IsEmpty() bool\n```\nIsEmpty asserts that the queue is empty\n\n```go\nfunc (*DummyQueue) Push(Data) error\n```\nPush fakes a push of data to the queue\n\n```go\nfunc (*DummyQueue) PushFunc(Data, func() error) error\n```\nPushFunc fakes a push of data to the queue with a function. The function is never run.\n\n```go\nfunc (*DummyQueue) Run(_, _ func(context.Context, func()))\n```\nRun does nothing\n\n```go\ntype DummyUniqueByteFIFO struct {\n\tDummyByteFIFO\n}\n```\nDummyUniqueByteFIFO represents a dummy unique fifo\n\n```go\nfunc (*DummyUniqueByteFIFO) Has([]byte) (bool, error)\n```\nHas always returns false\n\n```go\ntype ErrInvalidConfiguration struct {\n\t// contains filtered or unexported fields\n}\n```\nErrInvalidConfiguration is called when there is invalid configuration for a queue\n\n```go\nfunc (err ErrInvalidConfiguration) Error() string\n```\n\n```go\ntype Flushable interface {\n\t// Flush will add a flush worker to the pool - the worker should be autoregistered with the manager\n\tFlush(time.Duration) error\n\t// FlushWithContext is very similar to Flush\n\t// NB: The worker will not be registered with the manager.\n\tFlushWithContext(ctx context.Context) error\n\t// IsEmpty will return if the managed pool is empty and has no work\n\tIsEmpty() bool\n}\n```\nFlushable represents a pool or queue that is flushable\n\n```go\ntype HandlerFunc func(...Data)\n```\nHandlerFunc is a function that takes a variable amount of data and processes it\n\n```go\ntype Immediate struct {\n\t// contains filtered or unexported fields\n}\n```\nImmediate represents an direct execution queue\n\n```go\nfunc (*Immediate) Flush(time.Duration) error\n```\nFlush always returns nil\n\n```go\nfunc (*Immediate) FlushWithContext(context.Context) error\n```\nFlushWithContext always returns nil\n\n```go\nfunc (*Immediate) Has(Data) (bool, error)\n```\nHas always returns false as this queue never does anything\n\n```go\nfunc (*Immediate) IsEmpty() bool\n```\nIsEmpty asserts that the queue is empty\n\n```go\nfunc (q *Immediate) Push(data Data) error\n```\nPush fakes a push of data to the queue\n\n```go\nfunc (q *Immediate) PushFunc(data Data, f func() error) error\n```\nPushFunc fakes a push of data to the queue with a function. The function is never run.\n\n```go\nfunc (*Immediate) Run(_, _ func(context.Context, func()))\n```\nRun does nothing\n\n```go\ntype LevelQueue struct {\n\t*ByteFIFOQueue\n}\n```\nLevelQueue implements a disk library queue\n\n```go\ntype LevelQueueByteFIFO struct {\n\t// contains filtered or unexported fields\n}\n```\nLevelQueueByteFIFO represents a ByteFIFO formed from a LevelQueue\n\n```go\nfunc NewLevelQueueByteFIFO(connection, prefix string) (*LevelQueueByteFIFO, error)\n```\nNewLevelQueueByteFIFO creates a ByteFIFO formed from a LevelQueue\n\n```go\nfunc (fifo *LevelQueueByteFIFO) Close() error\n```\nClose this fifo\n\n```go\nfunc (fifo *LevelQueueByteFIFO) Len() int64\n```\nLen returns the length of the fifo\n\n```go\nfunc (fifo *LevelQueueByteFIFO) Pop() ([]byte, error)\n```\nPop pops data from the start of the fifo\n\n```go\nfunc (fifo *LevelQueueByteFIFO) PushFunc(data []byte, fn func() error) error\n```\nPushFunc will push data into the fifo\n\n```go\ntype LevelQueueConfiguration struct {\n\tByteFIFOQueueConfiguration\n\tDataDir          string\n\tConnectionString string\n\tQueueName        string\n}\n```\nLevelQueueConfiguration is the configuration for a LevelQueue\n\n```go\ntype LevelUniqueQueue struct {\n\t*ByteFIFOUniqueQueue\n}\n```\nLevelUniqueQueue implements a disk library queue\n\n```go\ntype LevelUniqueQueueByteFIFO struct {\n\t// contains filtered or unexported fields\n}\n```\nLevelUniqueQueueByteFIFO represents a ByteFIFO formed from a LevelUniqueQueue\n\n```go\nfunc NewLevelUniqueQueueByteFIFO(connection, prefix string) (*LevelUniqueQueueByteFIFO, error)\n```\nNewLevelUniqueQueueByteFIFO creates a new ByteFIFO formed from a LevelUniqueQueue\n\n```go\nfunc (fifo *LevelUniqueQueueByteFIFO) Close() error\n```\nClose this fifo\n\n```go\nfunc (fifo *LevelUniqueQueueByteFIFO) Has(data []byte) (bool, error)\n```\nHas returns whether the fifo contains this data\n\n```go\nfunc (fifo *LevelUniqueQueueByteFIFO) Len() int64\n```\nLen returns the length of the fifo\n\n```go\nfunc (fifo *LevelUniqueQueueByteFIFO) Pop() ([]byte, error)\n```\nPop pops data from the start of the fifo\n\n```go\nfunc (fifo *LevelUniqueQueueByteFIFO) PushFunc(data []byte, fn func() error) error\n```\nPushFunc pushes data to the end of the fifo and calls the callback if it is added\n\n```go\ntype LevelUniqueQueueConfiguration struct {\n\tByteFIFOQueueConfiguration\n\tDataDir          string\n\tConnectionString string\n\tQueueName        string\n}\n```\nLevelUniqueQueueConfiguration is the configuration for a LevelUniqueQueue\n\n```go\ntype ManagedPool interface {\n\t// AddWorkers adds a number of worker as group to the pool with the provided timeout. A CancelFunc is provided to cancel the group\n\tAddWorkers(number int, timeout time.Duration) context.CancelFunc\n\t// NumberOfWorkers returns the total number of workers in the pool\n\tNumberOfWorkers() int\n\t// MaxNumberOfWorkers returns the maximum number of workers the pool can dynamically grow to\n\tMaxNumberOfWorkers() int\n\t// SetMaxNumberOfWorkers sets the maximum number of workers the pool can dynamically grow to\n\tSetMaxNumberOfWorkers(int)\n\t// BoostTimeout returns the current timeout for worker groups created during a boost\n\tBoostTimeout() time.Duration\n\t// BlockTimeout returns the timeout the internal channel can block for before a boost would occur\n\tBlockTimeout() time.Duration\n\t// BoostWorkers sets the number of workers to be created during a boost\n\tBoostWorkers() int\n\t// SetPoolSettings sets the user updatable settings for the pool\n\tSetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration)\n}\n```\nManagedPool is a simple interface to get certain details from a worker pool\n\n```go\ntype ManagedQueue struct {\n\tQID           int64\n\tType          Type\n\tName          string\n\tConfiguration interface{}\n\tExemplarType  string\n\tManaged       interface{}\n\n\tPoolWorkers map[int64]*PoolWorkers\n\t// contains filtered or unexported fields\n}\n```\nManagedQueue represents a working queue with a Pool of workers.\n\nAlthough a ManagedQueue should really represent a Queue this does not necessarily have to be the case. This could be used to describe any queue.WorkerPool.\n\n```go\nfunc (q *ManagedQueue) AddWorkers(number int, timeout time.Duration) context.CancelFunc\n```\nAddWorkers adds workers to the queue if it has registered an add worker function\n\n```go\nfunc (q *ManagedQueue) BlockTimeout() time.Duration\n```\nBlockTimeout returns the timeout til the next boost\n\n```go\nfunc (q *ManagedQueue) BoostTimeout() time.Duration\n```\nBoostTimeout returns the timeout of the next boost\n\n```go\nfunc (q *ManagedQueue) BoostWorkers() int\n```\nBoostWorkers returns the number of workers for a boost\n\n```go\nfunc (q *ManagedQueue) CancelWorkers(pid int64)\n```\nCancelWorkers cancels pooled workers with pid\n\n```go\nfunc (q *ManagedQueue) Flush(timeout time.Duration) error\n```\nFlush flushes the queue with a timeout\n\n```go\nfunc (q *ManagedQueue) IsEmpty() bool\n```\nIsEmpty returns if the queue is empty\n\n```go\nfunc (q *ManagedQueue) MaxNumberOfWorkers() int\n```\nMaxNumberOfWorkers returns the maximum number of workers for the pool\n\n```go\nfunc (q *ManagedQueue) NumberOfWorkers() int\n```\nNumberOfWorkers returns the number of workers in the queue\n\n```go\nfunc (q *ManagedQueue) RegisterWorkers(number int, start time.Time, hasTimeout bool, timeout time.Time, cancel context.CancelFunc, isFlusher bool) int64\n```\nRegisterWorkers registers workers to this queue\n\n```go\nfunc (q *ManagedQueue) RemoveWorkers(pid int64)\n```\nRemoveWorkers deletes pooled workers with pid\n\n```go\nfunc (q *ManagedQueue) SetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration)\n```\nSetPoolSettings sets the setable boost values\n\n```go\nfunc (q *ManagedQueue) Workers() []*PoolWorkers\n```\nWorkers returns the poolworkers\n\n```go\ntype ManagedQueueList []*ManagedQueue\n```\nManagedQueueList implements the sort.Interface\n\n```go\nfunc (l ManagedQueueList) Len() int\n```\n\n```go\nfunc (l ManagedQueueList) Less(i, j int) bool\n```\n\n```go\nfunc (l ManagedQueueList) Swap(i, j int)\n```\n\n```go\ntype Manager struct {\n\tQueues map[int64]*ManagedQueue\n\t// contains filtered or unexported fields\n}\n```\nManager is a queue manager\n\n```go\nfunc GetManager() *Manager\n```\nGetManager returns a Manager and initializes one as singleton if there's none yet\n\n```go\nfunc (m *Manager) Add(managed interface{},\n\tt Type,\n\tconfiguration,\n\texemplar interface{}) int64\n```\nAdd adds a queue to this manager\n\n```go\nfunc (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error\n```\nFlushAll flushes all the flushable queues attached to this manager\n\n```go\nfunc (m *Manager) GetManagedQueue(qid int64) *ManagedQueue\n```\nGetManagedQueue by qid\n\n```go\nfunc (m *Manager) ManagedQueues() []*ManagedQueue\n```\nManagedQueues returns the managed queues\n\n```go\nfunc (m *Manager) Remove(qid int64)\n```\nRemove a queue from the Manager\n\n```go\ntype Mappable interface {\n\tMapTo(v interface{}) error\n}\n```\nMappable represents an interface that can MapTo another interface\n\n```go\ntype Named interface {\n\tName() string\n}\n```\nNamed represents a queue with a name\n\n```go\ntype NewQueueFunc func(handler HandlerFunc, config interface{}, exemplar interface{}) (Queue, error)\n```\nNewQueueFunc is a function that creates a queue\n\n```go\ntype PersistableChannelQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nPersistableChannelQueue wraps a channel queue and level queue together The disk level queue will be used to store data at shutdown and terminate - and will be restored on start up.\n\n```go\nfunc (q *PersistableChannelQueue) Flush(timeout time.Duration) error\n```\nFlush flushes the queue and blocks till the queue is empty\n\n```go\nfunc (q *PersistableChannelQueue) FlushWithContext(ctx context.Context) error\n```\nFlushWithContext flushes the queue and blocks till the queue is empty\n\n```go\nfunc (q *PersistableChannelQueue) IsEmpty() bool\n```\nIsEmpty checks if a queue is empty\n\n```go\nfunc (q *PersistableChannelQueue) Name() string\n```\nName returns the name of this queue\n\n```go\nfunc (q *PersistableChannelQueue) Push(data Data) error\n```\nPush will push the indexer data to queue\n\n```go\nfunc (q *PersistableChannelQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun starts to run the queue\n\n```go\nfunc (q *PersistableChannelQueue) Shutdown()\n```\nShutdown processing this queue\n\n```go\nfunc (q *PersistableChannelQueue) Terminate()\n```\nTerminate this queue and close the queue\n\n```go\ntype PersistableChannelQueueConfiguration struct {\n\tName         string\n\tDataDir      string\n\tBatchLength  int\n\tQueueLength  int\n\tTimeout      time.Duration\n\tMaxAttempts  int\n\tWorkers      int\n\tMaxWorkers   int\n\tBlockTimeout time.Duration\n\tBoostTimeout time.Duration\n\tBoostWorkers int\n}\n```\nPersistableChannelQueueConfiguration is the configuration for a PersistableChannelQueue\n\n```go\ntype PersistableChannelUniqueQueue struct {\n\t*ChannelUniqueQueue\n\t// contains filtered or unexported fields\n}\n```\nPersistableChannelUniqueQueue wraps a channel queue and level queue together\n\nPlease note that this Queue does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Flush(timeout time.Duration) error\n```\nFlush flushes the queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Has(data Data) (bool, error)\n```\nHas will test if the queue has the data\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Name() string\n```\nName returns the name of this queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Push(data Data) error\n```\nPush will push the indexer data to queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) PushFunc(data Data, fn func() error) error\n```\nPushFunc will push the indexer data to queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun starts to run the queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Shutdown()\n```\nShutdown processing this queue\n\n```go\nfunc (q *PersistableChannelUniqueQueue) Terminate()\n```\nTerminate this queue and close the queue\n\n```go\ntype PersistableChannelUniqueQueueConfiguration struct {\n\tName         string\n\tDataDir      string\n\tBatchLength  int\n\tQueueLength  int\n\tTimeout      time.Duration\n\tMaxAttempts  int\n\tWorkers      int\n\tMaxWorkers   int\n\tBlockTimeout time.Duration\n\tBoostTimeout time.Duration\n\tBoostWorkers int\n}\n```\nPersistableChannelUniqueQueueConfiguration is the configuration for a PersistableChannelUniqueQueue\n\n```go\ntype PoolWorkers struct {\n\tPID        int64\n\tWorkers    int\n\tStart      time.Time\n\tTimeout    time.Time\n\tHasTimeout bool\n\tCancel     context.CancelFunc\n\tIsFlusher  bool\n}\n```\nPoolWorkers represents a group of workers working on a queue\n\n```go\ntype PoolWorkersList []*PoolWorkers\n```\nPoolWorkersList implements the sort.Interface for PoolWorkers\n\n```go\nfunc (l PoolWorkersList) Len() int\n```\n\n```go\nfunc (l PoolWorkersList) Less(i, j int) bool\n```\n\n```go\nfunc (l PoolWorkersList) Swap(i, j int)\n```\n\n```go\ntype Queue interface {\n\tFlushable\n\tRun(atShutdown, atTerminate func(context.Context, func()))\n\tPush(Data) error\n}\n```\nQueue defines an interface of a queue-like item\n\nQueues will handle their own contents in the Run method\n\n```go\nfunc CreateQueue(name string, handle HandlerFunc, exemplar interface{}) Queue\n```\nCreateQueue for name with provided handler and exemplar\n\n```go\nfunc NewChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewChannelQueue creates a memory channel queue\n\n```go\nfunc NewChannelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewChannelUniqueQueue create a memory channel queue\n\n```go\nfunc NewDummyQueue(handler HandlerFunc, opts, exemplar interface{}) (Queue, error)\n```\nNewDummyQueue creates a new DummyQueue\n\n```go\nfunc NewImmediate(handler HandlerFunc, opts, exemplar interface{}) (Queue, error)\n```\nNewImmediate creates a new false queue to execute the function when push\n\n```go\nfunc NewLevelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewLevelQueue creates a ledis local queue\n\n```go\nfunc NewLevelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewLevelUniqueQueue creates a ledis local queue\n\nPlease note that this Queue does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\n```go\nfunc NewPersistableChannelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewPersistableChannelQueue creates a wrapped batched channel queue with persistable level queue backend when shutting down This differs from a wrapped queue in that the persistent queue is only used to persist at shutdown/terminate\n\n```go\nfunc NewPersistableChannelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewPersistableChannelUniqueQueue creates a wrapped batched channel queue with persistable level queue backend when shutting down This differs from a wrapped queue in that the persistent queue is only used to persist at shutdown/terminate\n\n```go\nfunc NewQueue(queueType Type, handlerFunc HandlerFunc, opts, exemplar interface{}) (Queue, error)\n```\nNewQueue takes a queue Type, HandlerFunc, some options and possibly an exemplar and returns a Queue or an error\n\n```go\nfunc NewRedisQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewRedisQueue creates single redis or cluster redis queue\n\n```go\nfunc NewRedisUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewRedisUniqueQueue creates single redis or cluster redis queue.\n\nPlease note that this Queue does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\n```go\nfunc NewWrappedQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewWrappedQueue will attempt to create a queue of the provided type, but if there is a problem creating this queue it will instead create a WrappedQueue with delayed startup of the queue instead and a channel which will be redirected to the queue\n\n```go\nfunc NewWrappedUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)\n```\nNewWrappedUniqueQueue will attempt to create a unique queue of the provided type, but if there is a problem creating this queue it will instead create a WrappedUniqueQueue with delayed startup of the queue instead and a channel which will be redirected to the queue\n\nPlease note that this Queue does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\n```go\ntype RedisByteFIFO struct {\n\t// contains filtered or unexported fields\n}\n```\nRedisByteFIFO represents a ByteFIFO formed from a redisClient\n\n```go\nfunc NewRedisByteFIFO(config RedisByteFIFOConfiguration) (*RedisByteFIFO, error)\n```\nNewRedisByteFIFO creates a ByteFIFO formed from a redisClient\n\n```go\nfunc (fifo *RedisByteFIFO) Close() error\n```\nClose this fifo\n\n```go\nfunc (fifo *RedisByteFIFO) Len() int64\n```\nLen returns the length of the fifo\n\n```go\nfunc (fifo *RedisByteFIFO) Pop() ([]byte, error)\n```\nPop pops data from the start of the fifo\n\n```go\nfunc (fifo *RedisByteFIFO) PushFunc(data []byte, fn func() error) error\n```\nPushFunc pushes data to the end of the fifo and calls the callback if it is added\n\n```go\ntype RedisByteFIFOConfiguration struct {\n\tConnectionString string\n\tQueueName        string\n}\n```\nRedisByteFIFOConfiguration is the configuration for the RedisByteFIFO\n\n```go\ntype RedisQueue struct {\n\t*ByteFIFOQueue\n}\n```\nRedisQueue redis queue\n\n```go\ntype RedisQueueConfiguration struct {\n\tByteFIFOQueueConfiguration\n\tRedisByteFIFOConfiguration\n}\n```\nRedisQueueConfiguration is the configuration for the redis queue\n\n```go\ntype RedisUniqueByteFIFO struct {\n\tRedisByteFIFO\n\t// contains filtered or unexported fields\n}\n```\nRedisUniqueByteFIFO represents a UniqueByteFIFO formed from a redisClient\n\n```go\nfunc NewRedisUniqueByteFIFO(config RedisUniqueByteFIFOConfiguration) (*RedisUniqueByteFIFO, error)\n```\nNewRedisUniqueByteFIFO creates a UniqueByteFIFO formed from a redisClient\n\n```go\nfunc (fifo *RedisUniqueByteFIFO) Has(data []byte) (bool, error)\n```\nHas returns whether the fifo contains this data\n\n```go\nfunc (fifo *RedisUniqueByteFIFO) Pop() ([]byte, error)\n```\nPop pops data from the start of the fifo\n\n```go\nfunc (fifo *RedisUniqueByteFIFO) PushFunc(data []byte, fn func() error) error\n```\nPushFunc pushes data to the end of the fifo and calls the callback if it is added\n\n```go\ntype RedisUniqueByteFIFOConfiguration struct {\n\tRedisByteFIFOConfiguration\n\tSetName string\n}\n```\nRedisUniqueByteFIFOConfiguration is the configuration for the RedisUniqueByteFIFO\n\n```go\ntype RedisUniqueQueue struct {\n\t*ByteFIFOUniqueQueue\n}\n```\nRedisUniqueQueue redis queue\n\n```go\ntype RedisUniqueQueueConfiguration struct {\n\tByteFIFOQueueConfiguration\n\tRedisUniqueByteFIFOConfiguration\n}\n```\nRedisUniqueQueueConfiguration is the configuration for the redis queue\n\n```go\ntype Shutdownable interface {\n\tShutdown()\n\tTerminate()\n}\n```\nShutdownable represents a queue that can be shutdown\n\n```go\ntype Type string\n```\nType is a type of Queue\n\n```go\nconst ChannelQueueType Type = \"channel\"\n```\nChannelQueueType is the type for channel queue\n\n```go\nconst ChannelUniqueQueueType Type = \"unique-channel\"\n```\nChannelUniqueQueueType is the type for channel queue\n\n```go\nconst DummyQueueType Type = \"dummy\"\n```\nDummyQueueType is the type for the dummy queue\n\n```go\nconst ImmediateType Type = \"immediate\"\n```\nImmediateType is the type to execute the function when push\n\n```go\nconst LevelQueueType Type = \"level\"\n```\nLevelQueueType is the type for level queue\n\n```go\nconst LevelUniqueQueueType Type = \"unique-level\"\n```\nLevelUniqueQueueType is the type for level queue\n\n```go\nconst PersistableChannelQueueType Type = \"persistable-channel\"\n```\nPersistableChannelQueueType is the type for persistable queue\n\n```go\nconst PersistableChannelUniqueQueueType Type = \"unique-persistable-channel\"\n```\nPersistableChannelUniqueQueueType is the type for persistable queue\n\n```go\nconst RedisQueueType Type = \"redis\"\n```\nRedisQueueType is the type for redis queue\n\n```go\nconst RedisUniqueQueueType Type = \"unique-redis\"\n```\nRedisUniqueQueueType is the type for redis queue\n\n```go\nconst WrappedQueueType Type = \"wrapped\"\n```\nWrappedQueueType is the type for a wrapped delayed starting queue\n\n```go\nconst WrappedUniqueQueueType Type = \"unique-wrapped\"\n```\nWrappedUniqueQueueType is the type for a wrapped delayed starting queue\n\n```go\nfunc RegisteredTypes() []Type\n```\nRegisteredTypes provides the list of requested types of queues\n\n```go\ntype UniqueByteFIFO interface {\n\tByteFIFO\n\t// Has returns whether the fifo contains this data\n\tHas(data []byte) (bool, error)\n}\n```\nUniqueByteFIFO defines a FIFO that Uniques its contents\n\n```go\ntype UniqueQueue interface {\n\tQueue\n\tPushFunc(Data, func() error) error\n\tHas(Data) (bool, error)\n}\n```\nUniqueQueue defines a queue which guarantees only one instance of same data is in the queue. Instances with same identity will be discarded if there is already one in the line.\n\nThis queue is particularly useful for preventing duplicated task of same purpose - please note that this does not guarantee that a particular task cannot be processed twice or more at the same time. Uniqueness is only guaranteed whilst the task is waiting in the queue.\n\nUsers of this queue should be careful to push only the identifier of the data\n\n```go\nfunc CreateUniqueQueue(name string, handle HandlerFunc, exemplar interface{}) UniqueQueue\n```\nCreateUniqueQueue for name with provided handler and exemplar\n\n```go\ntype WorkerPool struct {\n\t// contains filtered or unexported fields\n}\n```\nWorkerPool represent a dynamically growable worker pool for a provided handler function. They have an internal channel which they use to detect if there is a block and will grow and shrink in response to demand as per configuration.\n\n```go\nfunc NewWorkerPool(handle HandlerFunc, config WorkerPoolConfiguration) *WorkerPool\n```\nNewWorkerPool creates a new worker pool\n\n```go\nfunc (p *WorkerPool) AddWorkers(number int, timeout time.Duration) context.CancelFunc\n```\nAddWorkers adds workers to the pool - this allows the number of workers to go above the limit\n\n```go\nfunc (p *WorkerPool) BlockTimeout() time.Duration\n```\nBlockTimeout returns the timeout til the next boost\n\n```go\nfunc (p *WorkerPool) BoostTimeout() time.Duration\n```\nBoostTimeout returns the timeout of the next boost\n\n```go\nfunc (p *WorkerPool) BoostWorkers() int\n```\nBoostWorkers returns the number of workers for a boost\n\n```go\nfunc (p *WorkerPool) CleanUp(ctx context.Context)\n```\nCleanUp will drain the remaining contents of the channel This should be called after AddWorkers context is closed\n\n```go\nfunc (p *WorkerPool) Flush(timeout time.Duration) error\n```\nFlush flushes the channel with a timeout - the Flush worker will be registered as a flush worker with the manager\n\n```go\nfunc (p *WorkerPool) FlushWithContext(ctx context.Context) error\n```\nFlushWithContext is very similar to CleanUp but it will return as soon as the dataChan is empty NB: The worker will not be registered with the manager.\n\n```go\nfunc (p *WorkerPool) IsEmpty() bool\n```\nIsEmpty returns if true if the worker queue is empty\n\n```go\nfunc (p *WorkerPool) MaxNumberOfWorkers() int\n```\nMaxNumberOfWorkers returns the maximum number of workers automatically added to the pool\n\n```go\nfunc (p *WorkerPool) NumberOfWorkers() int\n```\nNumberOfWorkers returns the number of current workers in the pool\n\n```go\nfunc (p *WorkerPool) Push(data Data)\n```\nPush pushes the data to the internal channel\n\n```go\nfunc (p *WorkerPool) SetMaxNumberOfWorkers(newMax int)\n```\nSetMaxNumberOfWorkers sets the maximum number of workers automatically added to the pool Changing this number will not change the number of current workers but will change the limit for future additions\n\n```go\nfunc (p *WorkerPool) SetPoolSettings(maxNumberOfWorkers, boostWorkers int, timeout time.Duration)\n```\nSetPoolSettings sets the setable boost values\n\n```go\nfunc (p *WorkerPool) Wait()\n```\nWait for WorkerPool to finish\n\n```go\ntype WorkerPoolConfiguration struct {\n\tQueueLength  int\n\tBatchLength  int\n\tBlockTimeout time.Duration\n\tBoostTimeout time.Duration\n\tBoostWorkers int\n\tMaxWorkers   int\n}\n```\nWorkerPoolConfiguration is the basic configuration for a WorkerPool\n\n```go\ntype WrappedQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nWrappedQueue wraps a delayed starting queue\n\n```go\nfunc (q *WrappedQueue) Flush(timeout time.Duration) error\n```\nFlush flushes the queue and blocks till the queue is empty\n\n```go\nfunc (q *WrappedQueue) FlushWithContext(ctx context.Context) error\n```\nFlushWithContext implements the final part of Flushable\n\n```go\nfunc (q *WrappedQueue) IsEmpty() bool\n```\nIsEmpty checks whether the queue is empty\n\n```go\nfunc (q *WrappedQueue) Name() string\n```\nName returns the name of the queue\n\n```go\nfunc (q *WrappedQueue) Push(data Data) error\n```\nPush will push the data to the internal channel checking it against the exemplar\n\n```go\nfunc (q *WrappedQueue) Run(atShutdown, atTerminate func(context.Context, func()))\n```\nRun starts to run the queue and attempts to create the internal queue\n\n```go\nfunc (q *WrappedQueue) Shutdown()\n```\nShutdown this queue and stop processing\n\n```go\nfunc (q *WrappedQueue) Terminate()\n```\nTerminate this queue and close the queue\n\n```go\ntype WrappedQueueConfiguration struct {\n\tUnderlying  Type\n\tTimeout     time.Duration\n\tMaxAttempts int\n\tConfig      interface{}\n\tQueueLength int\n\tName        string\n}\n```\nWrappedQueueConfiguration is the configuration for a WrappedQueue\n\n```go\ntype WrappedUniqueQueue struct {\n\t*WrappedQueue\n\t// contains filtered or unexported fields\n}\n```\nWrappedUniqueQueue wraps a delayed starting unique queue\n\n```go\nfunc (q *WrappedUniqueQueue) Has(data Data) (bool, error)\n```\nHas checks if the data is in the queue\n\n```go\nfunc (q *WrappedUniqueQueue) IsEmpty() bool\n```\nIsEmpty checks whether the queue is empty\n\n```go\nfunc (q *WrappedUniqueQueue) Push(data Data) error\n```\nPush will push the data to the internal channel checking it against the exemplar\n\n```go\nfunc (q *WrappedUniqueQueue) PushFunc(data Data, fn func() error) error\n```\nPushFunc will push the data to the internal channel checking it against the exemplar\n\n```go\ntype WrappedUniqueQueueConfiguration struct {\n\tUnderlying  Type\n\tTimeout     time.Duration\n\tMaxAttempts int\n\tConfig      interface{}\n\tQueueLength int\n\tName        string\n}\n```\nWrappedUniqueQueueConfiguration is the configuration for a WrappedUniqueQueue\n\n","path":"github.com/RedAFD/code-core/modules/queue","name":"queue","synopsis":"","isRedistributable":true}
