mirror of
				https://github.com/oarkflow/mq.git
				synced 2025-10-31 09:16:22 +08:00 
			
		
		
		
	feat: implement Validate to check for cycle
				
					
				
			This commit is contained in:
		
							
								
								
									
										40
									
								
								pool_options.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								pool_options.go
									
									
									
									
									
										Normal 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 | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 sujit
					sujit