Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSharedPool ¶
func NewSharedPool(opts ...PoolOption) *http.Client
NewSharedPool returns a new http.Client instance with customizable options, ensures the efficient reuse of resources by pooling HTTP connections, thereby reducing overhead and improving performance across multiple clients
Example:
func main() { sharedPool := NewSharedPool() thirdPartyServiceClient1 := thirdPartyService.NewClient(sharedPool) thirdPartyServiceClient2 := thirdPartyService.NewClient(sharedPool) } // Inside third party service func (srv thirdPartyService) Send(ctx context.Context) error { srv.sharedPool.Do(ctx,... ) // Implement your logic }
Refer https://www.loginradius.com/blog/engineering/tune-the-go-http-client-for-high-performance/
Types ¶
type MockPoolOption ¶
MockPoolOption is an autogenerated mock type for the PoolOption type
func NewMockPoolOption ¶
func NewMockPoolOption(t interface { mock.TestingT Cleanup(func()) }) *MockPoolOption
NewMockPoolOption creates a new instance of MockPoolOption. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockPoolOption) EXPECT ¶
func (_m *MockPoolOption) EXPECT() *MockPoolOption_Expecter
func (*MockPoolOption) Execute ¶
func (_m *MockPoolOption) Execute(_a0 *http.Client)
Execute provides a mock function with given fields: _a0
type MockPoolOption_Execute_Call ¶
MockPoolOption_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'
func (*MockPoolOption_Execute_Call) Return ¶
func (_c *MockPoolOption_Execute_Call) Return() *MockPoolOption_Execute_Call
func (*MockPoolOption_Execute_Call) Run ¶
func (_c *MockPoolOption_Execute_Call) Run(run func(_a0 *http.Client)) *MockPoolOption_Execute_Call
func (*MockPoolOption_Execute_Call) RunAndReturn ¶
func (_c *MockPoolOption_Execute_Call) RunAndReturn(run func(*http.Client)) *MockPoolOption_Execute_Call
type MockPoolOption_Expecter ¶
type MockPoolOption_Expecter struct {
// contains filtered or unexported fields
}
func (*MockPoolOption_Expecter) Execute ¶
func (_e *MockPoolOption_Expecter) Execute(_a0 interface{}) *MockPoolOption_Execute_Call
Execute is a helper method to define mock.On call
- _a0 *http.Client
type PoolOption ¶
func WithTimeout ¶
func WithTimeout(timeout time.Duration) PoolOption
func WithTransport ¶
func WithTransport(transport http.RoundTripper) PoolOption