proxy

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MPL-2.0 Imports: 26 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.

Package proxy is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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        *logrus.Logger
	FetchTimeout  time.Duration
	LookupTimeout time.Duration
}

type FastHTTPWebSocketClient added in v0.6.13

type FastHTTPWebSocketClient struct {
	Dialer  *websocket.Dialer
	ConnStr string
	Logger  *logrus.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 *logrus.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
}

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 Options added in v0.6.13

type Options struct {
	InitialPoolCapacity int
	ClientPoolCapacity  int
	InsecureConnection  bool
	RootCA              string
	MaxConnsPerHost     int
	DNSConfig           config.DNS

	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	DialTimeout  time.Duration

	ReadBufferSize      int
	WriteBufferSize     int
	MaxResponseBodySize int

	Logger *logrus.Logger

	DNSResolver DNSCache
}

type Pool

type Pool interface {
	// Get returns a new ReverseProxy from the pool.
	Get() (HTTPClient, string, error)

	// Put the ReverseProxy puts it back to the Pool.
	Put(string, HTTPClient) error

	// Close closes the pool and all its connections. After Close() the pool is
	// no longer usable.
	Close()
}

func NewChanPool

func NewChanPool(hostAddr string, options *Options) (Pool, error)

NewChanPool to new a pool with some params

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 *logrus.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