proxy

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package proxy is a generated GoMock package.

Package proxy is a generated GoMock package.

Package proxy is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTLSConfig added in v0.9.6

func BuildTLSConfig(insecure bool, rootCA string) (*tls.Config, error)

BuildTLSConfig creates a TLS configuration with optional custom root CA.

func Perform added in v0.6.13

func Perform(ctx *fasthttp.RequestCtx, proxyPool Pool, customHostHeader string) error

Perform function proxies the request to the backend server

Types

type DNSCache added in v0.8.0

type DNSCache interface {
	LookupIPAddr(context.Context, string) (names []net.IPAddr, err error)
	Refresh()
	Stop()
}

func NewDNSResolver added in v0.8.0

func NewDNSResolver(resolver *net.Resolver, options *DNSCacheOptions) (DNSCache, error)

NewDNSResolver initializes DNS cache resolver and starts auto refreshing in a new goroutine. To stop refreshing, call `Stop()` function.

type DNSCacheOptions added in v0.8.2

type DNSCacheOptions struct {
	UseCache      bool
	Logger        zerolog.Logger
	FetchTimeout  time.Duration
	LookupTimeout time.Duration
}

type FastHTTPWebSocketClient added in v0.6.13

type FastHTTPWebSocketClient struct {
	Dialer  *websocket.Dialer
	ConnStr string
	Logger  zerolog.Logger
}

FastHTTPWebSocketClient implements the WebSocketClient interface

func (*FastHTTPWebSocketClient) GetConn added in v0.6.13

type FastHTTPWebSocketConn added in v0.6.13

type FastHTTPWebSocketConn struct {
	Conn   *websocket.Conn
	Logger zerolog.Logger
	Ctx    *fasthttp.RequestCtx
	// contains filtered or unexported fields
}

FastHTTPWebSocketConn implements the WebSocketConn interface

func (*FastHTTPWebSocketConn) Close added in v0.6.13

func (f *FastHTTPWebSocketConn) Close() error

func (*FastHTTPWebSocketConn) ReadMessage added in v0.6.13

func (f *FastHTTPWebSocketConn) ReadMessage() (messageType int, p []byte, err error)

func (*FastHTTPWebSocketConn) SendCloseConnection added in v0.6.13

func (f *FastHTTPWebSocketConn) SendCloseConnection(closeType int) error

func (*FastHTTPWebSocketConn) SendComplete added in v0.6.13

func (f *FastHTTPWebSocketConn) SendComplete(messageType int, id string) error

func (*FastHTTPWebSocketConn) SendError added in v0.6.13

func (f *FastHTTPWebSocketConn) SendError(messageType int, msgID string, requestErrors error) error

func (*FastHTTPWebSocketConn) WriteMessage added in v0.6.13

func (f *FastHTTPWebSocketConn) WriteMessage(messageType int, data []byte) error

type GqlWSErrorMessage added in v0.6.13

type GqlWSErrorMessage struct {
	ID      string                `json:"id"`
	Type    string                `json:"type"`
	Payload graphql.RequestErrors `json:"payload,omitempty"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *fasthttp.Request, resp *fasthttp.Response) error
}

HTTPClient is the interface for making HTTP requests.

type LoadBalancer added in v0.9.6

type LoadBalancer struct {
	// contains filtered or unexported fields
}

LoadBalancer provides round-robin load balancing across multiple backends with health checking support. It is lock-free for the hot path (Next).

func NewLoadBalancer added in v0.9.6

func NewLoadBalancer(opts *LoadBalancerOptions) *LoadBalancer

NewLoadBalancer creates a new load balancer with the given backends

func (*LoadBalancer) GetBackends added in v0.9.6

func (lb *LoadBalancer) GetBackends() []string

func (*LoadBalancer) GetHealthyCount added in v0.9.6

func (lb *LoadBalancer) GetHealthyCount() int

func (*LoadBalancer) IsHealthy added in v0.9.6

func (lb *LoadBalancer) IsHealthy(idx int) bool

func (*LoadBalancer) Next added in v0.9.6

func (lb *LoadBalancer) Next() string

Next returns the next healthy backend using round-robin selection. This method is lock-free and safe for concurrent use.

func (*LoadBalancer) SetHealthy added in v0.9.6

func (lb *LoadBalancer) SetHealthy(idx int, healthy bool)

func (*LoadBalancer) Stop added in v0.9.6

func (lb *LoadBalancer) Stop()

type LoadBalancerOptions added in v0.9.6

type LoadBalancerOptions struct {
	Backends            []string
	HealthCheckInterval time.Duration
	HealthCheckTimeout  time.Duration
	Logger              zerolog.Logger
}

LoadBalancerOptions configures the load balancer

type MockDNSCache added in v0.8.0

type MockDNSCache struct {
	// contains filtered or unexported fields
}

MockDNSCache is a mock of DNSCache interface.

func NewMockDNSCache added in v0.8.0

func NewMockDNSCache(ctrl *gomock.Controller) *MockDNSCache

NewMockDNSCache creates a new mock instance.

func (*MockDNSCache) EXPECT added in v0.8.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDNSCache) LookupIPAddr added in v0.8.2

func (m *MockDNSCache) LookupIPAddr(arg0 context.Context, arg1 string) ([]net.IPAddr, error)

LookupIPAddr mocks base method.

func (*MockDNSCache) Refresh added in v0.8.0

func (m *MockDNSCache) Refresh()

Refresh mocks base method.

func (*MockDNSCache) Stop added in v0.8.0

func (m *MockDNSCache) Stop()

Stop mocks base method.

type MockDNSCacheMockRecorder added in v0.8.0

type MockDNSCacheMockRecorder struct {
	// contains filtered or unexported fields
}

MockDNSCacheMockRecorder is the mock recorder for MockDNSCache.

func (*MockDNSCacheMockRecorder) LookupIPAddr added in v0.8.2

func (mr *MockDNSCacheMockRecorder) LookupIPAddr(arg0, arg1 interface{}) *gomock.Call

LookupIPAddr indicates an expected call of LookupIPAddr.

func (*MockDNSCacheMockRecorder) Refresh added in v0.8.0

func (mr *MockDNSCacheMockRecorder) Refresh() *gomock.Call

Refresh indicates an expected call of Refresh.

func (*MockDNSCacheMockRecorder) Stop added in v0.8.0

func (mr *MockDNSCacheMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop.

type MockHTTPClient added in v0.6.9

type MockHTTPClient struct {
	// contains filtered or unexported fields
}

MockHTTPClient is a mock of HTTPClient interface.

func NewMockHTTPClient added in v0.6.9

func NewMockHTTPClient(ctrl *gomock.Controller) *MockHTTPClient

NewMockHTTPClient creates a new mock instance.

func (*MockHTTPClient) Do added in v0.6.9

Do mocks base method.

func (*MockHTTPClient) EXPECT added in v0.6.9

EXPECT returns an object that allows the caller to indicate expected use.

type MockHTTPClientMockRecorder added in v0.6.9

type MockHTTPClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockHTTPClientMockRecorder is the mock recorder for MockHTTPClient.

func (*MockHTTPClientMockRecorder) Do added in v0.6.9

func (mr *MockHTTPClientMockRecorder) Do(req, resp interface{}) *gomock.Call

Do indicates an expected call of Do.

type MockPool added in v0.6.9

type MockPool struct {
	// contains filtered or unexported fields
}

MockPool is a mock of Pool interface.

func NewMockPool added in v0.6.9

func NewMockPool(ctrl *gomock.Controller) *MockPool

NewMockPool creates a new mock instance.

func (*MockPool) Close added in v0.6.9

func (m *MockPool) Close()

Close mocks base method.

func (*MockPool) EXPECT added in v0.6.9

func (m *MockPool) EXPECT() *MockPoolMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPool) Get added in v0.6.9

func (m *MockPool) Get() (HTTPClient, string, error)

Get mocks base method.

func (*MockPool) Put added in v0.6.9

func (m *MockPool) Put(arg0 string, arg1 HTTPClient) error

Put mocks base method.

type MockPoolMockRecorder added in v0.6.9

type MockPoolMockRecorder struct {
	// contains filtered or unexported fields
}

MockPoolMockRecorder is the mock recorder for MockPool.

func (*MockPoolMockRecorder) Close added in v0.6.9

func (mr *MockPoolMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockPoolMockRecorder) Get added in v0.6.9

func (mr *MockPoolMockRecorder) Get() *gomock.Call

Get indicates an expected call of Get.

func (*MockPoolMockRecorder) Put added in v0.6.9

func (mr *MockPoolMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call

Put indicates an expected call of Put.

type MockWebSocketClient added in v0.6.13

type MockWebSocketClient struct {
	// contains filtered or unexported fields
}

MockWebSocketClient is a mock of WebSocketClient interface.

func NewMockWebSocketClient added in v0.6.13

func NewMockWebSocketClient(ctrl *gomock.Controller) *MockWebSocketClient

NewMockWebSocketClient creates a new mock instance.

func (*MockWebSocketClient) EXPECT added in v0.6.13

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWebSocketClient) GetConn added in v0.6.13

GetConn mocks base method.

type MockWebSocketClientMockRecorder added in v0.6.13

type MockWebSocketClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockWebSocketClientMockRecorder is the mock recorder for MockWebSocketClient.

func (*MockWebSocketClientMockRecorder) GetConn added in v0.6.13

func (mr *MockWebSocketClientMockRecorder) GetConn(ctx interface{}) *gomock.Call

GetConn indicates an expected call of GetConn.

type MockWebSocketConn added in v0.6.13

type MockWebSocketConn struct {
	// contains filtered or unexported fields
}

MockWebSocketConn is a mock of WebSocketConn interface.

func NewMockWebSocketConn added in v0.6.13

func NewMockWebSocketConn(ctrl *gomock.Controller) *MockWebSocketConn

NewMockWebSocketConn creates a new mock instance.

func (*MockWebSocketConn) Close added in v0.6.13

func (m *MockWebSocketConn) Close() error

Close mocks base method.

func (*MockWebSocketConn) EXPECT added in v0.6.13

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWebSocketConn) ReadMessage added in v0.6.13

func (m *MockWebSocketConn) ReadMessage() (int, []byte, error)

ReadMessage mocks base method.

func (*MockWebSocketConn) SendCloseConnection added in v0.6.13

func (m *MockWebSocketConn) SendCloseConnection(closeType int) error

SendCloseConnection mocks base method.

func (*MockWebSocketConn) SendComplete added in v0.6.13

func (m *MockWebSocketConn) SendComplete(messageType int, id string) error

SendComplete mocks base method.

func (*MockWebSocketConn) SendError added in v0.6.13

func (m *MockWebSocketConn) SendError(messageType int, msgID string, requestErrors error) error

SendError mocks base method.

func (*MockWebSocketConn) WriteMessage added in v0.6.13

func (m *MockWebSocketConn) WriteMessage(messageType int, data []byte) error

WriteMessage mocks base method.

type MockWebSocketConnMockRecorder added in v0.6.13

type MockWebSocketConnMockRecorder struct {
	// contains filtered or unexported fields
}

MockWebSocketConnMockRecorder is the mock recorder for MockWebSocketConn.

func (*MockWebSocketConnMockRecorder) Close added in v0.6.13

Close indicates an expected call of Close.

func (*MockWebSocketConnMockRecorder) ReadMessage added in v0.6.13

func (mr *MockWebSocketConnMockRecorder) ReadMessage() *gomock.Call

ReadMessage indicates an expected call of ReadMessage.

func (*MockWebSocketConnMockRecorder) SendCloseConnection added in v0.6.13

func (mr *MockWebSocketConnMockRecorder) SendCloseConnection(closeType interface{}) *gomock.Call

SendCloseConnection indicates an expected call of SendCloseConnection.

func (*MockWebSocketConnMockRecorder) SendComplete added in v0.6.13

func (mr *MockWebSocketConnMockRecorder) SendComplete(messageType, id interface{}) *gomock.Call

SendComplete indicates an expected call of SendComplete.

func (*MockWebSocketConnMockRecorder) SendError added in v0.6.13

func (mr *MockWebSocketConnMockRecorder) SendError(messageType, msgID, requestErrors interface{}) *gomock.Call

SendError indicates an expected call of SendError.

func (*MockWebSocketConnMockRecorder) WriteMessage added in v0.6.13

func (mr *MockWebSocketConnMockRecorder) WriteMessage(messageType, data interface{}) *gomock.Call

WriteMessage indicates an expected call of WriteMessage.

type Pool

type Pool interface {
	Get() (HTTPClient, string, error)
	Put(string, HTTPClient) error
	Close()
}

Pool manages HTTP client connections to backend servers.

func NewPoolV2 added in v0.9.6

func NewPoolV2(hostAddr string, opts *PoolV2Options) (Pool, error)

NewPoolV2 creates a new lock-free connection pool

type PoolV2 added in v0.9.6

type PoolV2 struct {
	// contains filtered or unexported fields
}

PoolV2 is a lock-free connection pool that leverages fasthttp.Client's internal connection pooling.

Key design: - Lock-free operation using atomic values - Single fasthttp.Client with proper MaxConnsPerHost - Zero allocations per request in Get/Put - Built-in load balancing with health checks

func (*PoolV2) Close added in v0.9.6

func (p *PoolV2) Close()

func (*PoolV2) Get added in v0.9.6

func (p *PoolV2) Get() (HTTPClient, string, error)

Get returns the shared HTTP client. The actual backend is selected inside the Dial function when the connection is established.

func (*PoolV2) Put added in v0.9.6

func (p *PoolV2) Put(ip string, client HTTPClient) error

Put is a no-op -- fasthttp.Client manages connection lifecycle internally.

func (*PoolV2) Stats added in v0.9.6

func (p *PoolV2) Stats() PoolV2Stats

type PoolV2Options added in v0.9.6

type PoolV2Options struct {
	// Connection settings
	MaxConnsPerHost     int
	MaxIdleConnDuration time.Duration
	ReadTimeout         time.Duration
	WriteTimeout        time.Duration
	DialTimeout         time.Duration

	// Buffer sizes
	ReadBufferSize      int
	WriteBufferSize     int
	MaxResponseBodySize int

	// TLS configuration
	InsecureConnection bool
	RootCA             string

	// Load balancing - if empty, uses single backend from hostAddr
	Backends            []string
	HealthCheckInterval time.Duration

	// Logging
	Logger zerolog.Logger
}

PoolV2Options configures the PoolV2 connection pool

type PoolV2Stats added in v0.9.6

type PoolV2Stats struct {
	Host         string
	Port         string
	Backends     []string
	HealthyCount int
	IsClosed     bool
}

PoolV2Stats contains pool statistics

type Resolver added in v0.8.0

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver is DNS cache resolver which cache DNS resolve results in memory.

func (*Resolver) LookupIPAddr added in v0.8.2

func (r *Resolver) LookupIPAddr(ctx context.Context, addr string) ([]net.IPAddr, error)

LookupIPAddr lookups IP list from the cache and returns DNS server then it saves result in the cache. If you want to get result from the cache use `Fetch` function.

func (*Resolver) Refresh added in v0.8.0

func (r *Resolver) Refresh()

Refresh refreshes IP list cache.

func (*Resolver) Stop added in v0.8.0

func (r *Resolver) Stop()

Stop stops auto refreshing.

type WSClientOptions added in v0.6.13

type WSClientOptions struct {
	Scheme             string
	Host               string
	Path               string
	InsecureConnection bool
	RootCA             string
	DialTimeout        time.Duration
}

type WebSocketClient added in v0.6.13

type WebSocketClient interface {
	GetConn(ctx *fasthttp.RequestCtx) (*FastHTTPWebSocketConn, error)
}

WebSocketClient defines the interface for WebSocket connections Pool

func NewWSClient added in v0.6.13

func NewWSClient(logger zerolog.Logger, options *WSClientOptions) (WebSocketClient, error)

type WebSocketConn added in v0.6.13

type WebSocketConn interface {
	ReadMessage() (messageType int, p []byte, err error)
	WriteMessage(messageType int, data []byte) error
	SendError(messageType int, msgID string, requestErrors error) error
	SendComplete(messageType int, id string) error
	SendCloseConnection(closeType int) error
	Close() error
}

WebSocketConn defines the interface for WebSocket connections

Jump to

Keyboard shortcuts

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