feat: implement Validate to check for cycle

This commit is contained in:
sujit
2024-10-23 14:11:39 +05:45
parent 9ca4e1c2f4
commit 1ec5630d3e
6 changed files with 112 additions and 57 deletions

40
pool_options.go Normal file
View File

@@ -0,0 +1,40 @@
package mq
type PoolOption func(*Pool)
func WithTaskQueueSize(size int) PoolOption {
return func(p *Pool) {
// Initialize the task queue with the specified size
p.taskQueue = make(PriorityQueue, 0, size)
}
}
func WithMaxMemoryLoad(maxMemoryLoad int64) PoolOption {
return func(p *Pool) {
p.maxMemoryLoad = maxMemoryLoad
}
}
func WithBatchSize(batchSize int) PoolOption {
return func(p *Pool) {
p.batchSize = batchSize
}
}
func WithHandler(handler Handler) PoolOption {
return func(p *Pool) {
p.handler = handler
}
}
func WithPoolCallback(callback Callback) PoolOption {
return func(p *Pool) {
p.callback = callback
}
}
func WithTaskStorage(storage TaskStorage) PoolOption {
return func(p *Pool) {
p.taskStorage = storage
}
}