GoPool is a high-performance, feature-rich, and easy-to-use worker pool library for Golang. It is designed to manage and recycle a pool of goroutines to complete tasks concurrently, improving the efficiency and performance of your applications.
-
Task Queue: GoPool uses a thread-safe task queue to store tasks waiting to be processed. Multiple workers can simultaneously fetch tasks from this queue.
-
Dynamic Worker Adjustment: GoPool can dynamically adjust the number of workers based on the number of tasks and system load.
-
Graceful Shutdown: GoPool can shut down gracefully. It stops accepting new tasks and waits for all ongoing tasks to complete before shutting down when there are no more tasks or a shutdown signal is received.
-
Error Handling: GoPool can handle errors that occur during task execution. For example, it can provide an error callback function.
-
Task Timeout Handling: GoPool can handle task execution timeouts. For example, it can set a timeout period, and if a task is not completed within this period, the task is considered failed.
-
Task Priority: GoPool supports task priority. Tasks with higher priority are processed first.
-
Task Result Retrieval: GoPool provides a way to retrieve task results. For example, it can provide a result callback function.
-
Task Retry: GoPool provides a retry mechanism for failed tasks. For example, it can set the number of retries and the retry interval.
-
Task Progress Tracking: GoPool provides task progress tracking. For example, it can provide a progress callback function or a method to query the current task progress.
-
Concurrency Control: GoPool can control the number of concurrent tasks to prevent system overload.
To install GoPool, use go get
:
go get -u github.com/devchat-ai/gopool
Here is a simple example of how to use GoPool:
// code example here
We welcome contributions! Please see CONTRIBUTING.md for details.
GoPool is released under the MIT License. See LICENSE for details.