httpclient

package
v0.0.0-...-8ca05e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2025 License: Apache-2.0 Imports: 3 Imported by: 1

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

type MockPoolOption struct {
	mock.Mock
}

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 (*MockPoolOption) Execute

func (_m *MockPoolOption) Execute(_a0 *http.Client)

Execute provides a mock function with given fields: _a0

type MockPoolOption_Execute_Call

type MockPoolOption_Execute_Call struct {
	*mock.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 (*MockPoolOption_Execute_Call) Run

func (*MockPoolOption_Execute_Call) RunAndReturn

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

type PoolOption func(*http.Client)

func WithTimeout

func WithTimeout(timeout time.Duration) PoolOption

func WithTransport

func WithTransport(transport http.RoundTripper) PoolOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL