Documentation
¶
Index ¶
- Constants
- func GetRetryFromContext(r *http.Request) int
- type Backend
- func (b *Backend) DecrementConnections()
- func (b *Backend) GetConnectionCount() int
- func (b *Backend) GetCurrentWeight() int
- func (b *Backend) GetURL() string
- func (b *Backend) GetWeight() int
- func (b *Backend) IncrementConnections() bool
- func (b *Backend) IsAlive() bool
- func (b *Backend) SetCurrentWeight(weight int)
- type BufferPool
- type ConnectionPool
- type PoolConfig
- type ProxyError
- type ProxyOption
- type RewriteConfig
- type RouteConfig
- type ServerPool
- func (s *ServerPool) AddBackend(cfg config.BackendConfig, rc RouteConfig) error
- func (s *ServerPool) GetAlgorithm() algorithm.Algorithm
- func (s *ServerPool) GetBackendByURL(url string) *Backend
- func (s *ServerPool) GetBackends() []*algorithm.Server
- func (s *ServerPool) GetConfig() PoolConfig
- func (s *ServerPool) GetCurrentIndex() uint64
- func (s *ServerPool) GetMaxConnections() int32
- func (s *ServerPool) GetNextPeer() *Backend
- func (s *ServerPool) GetNextProxy(r *http.Request) *URLRewriteProxy
- func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)
- func (s *ServerPool) RemoveBackend(backendURL string) error
- func (s *ServerPool) SetAlgorithm(algorithm algorithm.Algorithm) error
- func (s *ServerPool) SetCurrentIndex(idx uint64)
- func (s *ServerPool) SetMaxConnections(maxConns int32) error
- func (s *ServerPool) UpdateBackends(configs []config.BackendConfig) error
- func (s *ServerPool) UpdateConfig(update PoolConfig)
- type Transport
- type URLRewriteProxy
- type URLRewriter
Constants ¶
View Source
const ( // HTTP Status codes StatusMovedPermanently = http.StatusMovedPermanently StatusFound = http.StatusFound StatusSeeOther = http.StatusSeeOther StatusTemporaryRedirect = http.StatusTemporaryRedirect StatusPermanentRedirect = http.StatusPermanentRedirect // Header keys HeaderServer = "Server" HeaderXPoweredBy = "X-Powered-By" HeaderXProxyBy = "X-Proxy-By" HeaderLocation = "Location" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedHost = "X-Forwarded-Host" HeaderHost = "Host" DefaultScheme = "http" DefaultProxyLabel = "terraster" )
View Source
const (
RetryKey contextKey = iota
)
Variables ¶
This section is empty.
Functions ¶
func GetRetryFromContext ¶
helper function for retry context
Types ¶
type Backend ¶
type Backend struct {
URL *url.URL
Host string
Alive bool
Weight int
CurrentWeight int
Proxy *URLRewriteProxy
ConnectionCount int32
MaxConnections int32
// contains filtered or unexported fields
}
func (*Backend) DecrementConnections ¶
func (b *Backend) DecrementConnections()
func (*Backend) GetConnectionCount ¶
func (*Backend) GetCurrentWeight ¶
func (*Backend) IncrementConnections ¶
func (*Backend) SetCurrentWeight ¶
type BufferPool ¶
func NewBufferPool ¶
func NewBufferPool() *BufferPool
func (*BufferPool) Get ¶
func (b *BufferPool) Get() []byte
func (*BufferPool) Put ¶
func (b *BufferPool) Put(buf []byte)
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
func NewConnectionPool ¶
func NewConnectionPool(maxIdle, maxOpen int, idleTimeout time.Duration) *ConnectionPool
func (*ConnectionPool) Get ¶
func (p *ConnectionPool) Get() *http.Client
func (*ConnectionPool) Put ¶
func (p *ConnectionPool) Put(client *http.Client)
type PoolConfig ¶
type ProxyError ¶
func (*ProxyError) Error ¶
func (e *ProxyError) Error() string
type ProxyOption ¶
type ProxyOption func(*URLRewriteProxy)
func WithLogger ¶
func WithLogger(logger *log.Logger) ProxyOption
func WithURLRewriter ¶
func WithURLRewriter(config RouteConfig, backendURL *url.URL) ProxyOption
type RewriteConfig ¶
type RouteConfig ¶
type ServerPool ¶
type ServerPool struct {
// contains filtered or unexported fields
}
func NewServerPool ¶
func NewServerPool() *ServerPool
func (*ServerPool) AddBackend ¶
func (s *ServerPool) AddBackend(cfg config.BackendConfig, rc RouteConfig) error
func (*ServerPool) GetAlgorithm ¶
func (s *ServerPool) GetAlgorithm() algorithm.Algorithm
func (*ServerPool) GetBackendByURL ¶
func (s *ServerPool) GetBackendByURL(url string) *Backend
func (*ServerPool) GetBackends ¶
func (s *ServerPool) GetBackends() []*algorithm.Server
func (*ServerPool) GetConfig ¶
func (s *ServerPool) GetConfig() PoolConfig
func (*ServerPool) GetCurrentIndex ¶
func (s *ServerPool) GetCurrentIndex() uint64
func (*ServerPool) GetMaxConnections ¶
func (s *ServerPool) GetMaxConnections() int32
func (*ServerPool) GetNextPeer ¶
func (s *ServerPool) GetNextPeer() *Backend
func (*ServerPool) GetNextProxy ¶
func (s *ServerPool) GetNextProxy(r *http.Request) *URLRewriteProxy
func (*ServerPool) MarkBackendStatus ¶
func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)
func (*ServerPool) RemoveBackend ¶
func (s *ServerPool) RemoveBackend(backendURL string) error
func (*ServerPool) SetAlgorithm ¶
func (s *ServerPool) SetAlgorithm(algorithm algorithm.Algorithm) error
func (*ServerPool) SetCurrentIndex ¶
func (s *ServerPool) SetCurrentIndex(idx uint64)
func (*ServerPool) SetMaxConnections ¶
func (s *ServerPool) SetMaxConnections(maxConns int32) error
func (*ServerPool) UpdateBackends ¶
func (s *ServerPool) UpdateBackends(configs []config.BackendConfig) error
Add method to update backends from config
func (*ServerPool) UpdateConfig ¶
func (s *ServerPool) UpdateConfig(update PoolConfig)
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶
func NewTransport(transport http.RoundTripper, skipTLSVerify bool) *Transport
type URLRewriteProxy ¶
type URLRewriteProxy struct {
// contains filtered or unexported fields
}
func NewReverseProxy ¶
func NewReverseProxy( target *url.URL, config RouteConfig, px *httputil.ReverseProxy, opts ...ProxyOption, ) *URLRewriteProxy
func (*URLRewriteProxy) ServeHTTP ¶
func (p *URLRewriteProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
type URLRewriter ¶
type URLRewriter struct {
// contains filtered or unexported fields
}
func NewURLRewriter ¶
func NewURLRewriter(config RewriteConfig, backendURL *url.URL) *URLRewriter
Click to show internal directories.
Click to hide internal directories.