A generic object pool implementation for Go, directly rewritten from Apache Commons Pool with rich configuration options.
Go Commons Pool is a generic object pooling library for Go that enables efficient reuse of expensive-to-create objects like database connections, network sockets, or complex data structures. It solves the performance problem of repeatedly creating and destroying heavy objects by maintaining a pool of reusable instances with configurable lifecycle management.
Go developers building high-performance applications that need to manage expensive resources efficiently, particularly those familiar with Apache Commons Pool from Java or similar pooling patterns.
Developers choose Go Commons Pool because it provides a production-ready, battle-tested pooling implementation directly ported from Apache Commons Pool, with comprehensive configuration options and predictable behavior that matches the Java reference implementation.
a generic object pool for golang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Direct rewrite of Apache Commons Pool, offering battle-tested pooling patterns with similar defaults and performance, as validated in performance tests matching the Java version.
Rich options via ObjectPoolConfig, including LIFO/FIFO ordering, capacity limits, validation triggers, and eviction policies, allowing precise control over object lifecycle.
Built for multi-goroutine environments with proper synchronization, ensuring thread-safe operations in high-concurrency applications like web servers.
Performance tests show results almost equal to the Java version, indicating efficient implementation and reliable object reuse for resource-intensive scenarios.
Lacks KeyedObjectPool from Apache Commons Pool, limiting its use for scenarios requiring object categorization by keys, as noted in the README's TODO section.
Does not include ProxiedObjectPool or pool statistics (marked as TODO), missing advanced functionalities available in the original Java library.
Pooled objects must be pointers, not values, which can lead to runtime errors if overlooked, as cautioned in the README with explicit examples.