gofr icon indicating copy to clipboard operation
gofr copied to clipboard

feat: add HTTP connection pool configuration support

Open ish1416 opened this issue 1 month ago • 0 comments

Pull Request Template

Description:

  • Added HTTP Connection Pool Configuration support to GoFr's HTTP service initialization
  • Addresses issue #2505 by providing configurable connection pool settings to resolve performance bottlenecks
  • Introduces ConnectionPoolConfig struct with MaxIdleConns, MaxIdleConnsPerHost, and IdleConnTimeout options
  • Solves connection pool exhaustion errors and reduces latency from 13.6ms to 4.5ms for high-frequency inter-service calls
  • Maintains backward compatibility with existing GoFr applications

Breaking Changes (if applicable):

  • None. This is a purely additive feature that maintains full backward compatibility with existing code.

Additional Information:

  • Implements the existing Options interface pattern used by Circuit Breaker and Health Check configurations
  • Added comprehensive unit tests covering all configuration scenarios
  • Updated existing examples and created dedicated connection pool example with documentation
  • Works seamlessly with existing service options (can be combined with Circuit Breaker and Health Check)

Usage Example:

app.AddHTTPService("api-service", "https://api.example.com",
    &service.ConnectionPoolConfig{
        MaxIdleConns:        100, // Total idle connections
        MaxIdleConnsPerHost: 20,  // Per-host idle connections (vs default 2)
        IdleConnTimeout:     90 * time.Second, // Keep alive duration
    },
)
Checklist:

 I have formatted my code using goimport and golangci-lint.
 All new code is covered by unit tests.
 This PR does not decrease the overall code coverage.
 I have reviewed the code comments and documentation for clarity.
Thank you for your contribution!

ish1416 avatar Nov 10 '25 05:11 ish1416