Documentation
¶
Index ¶
- func Chain(handler http.Handler, middlewares ...func(http.Handler) http.Handler) http.Handler
- func LoggingMiddleware(logger *logging.Logger, next http.Handler) http.Handler
- func MetricsMiddleware(metrics *Metrics, next http.Handler) http.Handler
- func RecoveryMiddleware(logging *logging.Logger, next http.Handler) http.Handler
- func TracingMiddleware(next http.Handler) http.Handler
- type BackendConfig
- type Config
- type ControlPlaneClient
- func (c *ControlPlaneClient) Close() error
- func (c *ControlPlaneClient) Connect(ctx context.Context) error
- func (c *ControlPlaneClient) GetConfig() *pb.ConfigUpdate
- func (c *ControlPlaneClient) Register(ctx context.Context) (*pb.RegistrationResponse, error)
- func (c *ControlPlaneClient) StartConfigStream(ctx context.Context) (<-chan struct{}, <-chan error, error)
- type ControlPlaneConfig
- type Handler
- type Metrics
- type ProxyConfig
- type Server
- type TimeoutConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggingMiddleware ¶
func MetricsMiddleware ¶
Middleware to record metrics for the request
func RecoveryMiddleware ¶
Middleware to recover from panics and log the error This will prevent the entire proxy from crashing
Types ¶
type BackendConfig ¶
type Config ¶
type Config struct {
Proxy ProxyConfig `yaml:"proxy"`
ControlPlane ControlPlaneConfig `yaml:"control_plane"`
}
func (*Config) GetBackendURL ¶
type ControlPlaneClient ¶
type ControlPlaneClient struct {
// contains filtered or unexported fields
}
This manages the connection to the control plane.
func NewControlPlaneClient ¶
func NewControlPlaneClient(config *Config, logger *logging.Logger) *ControlPlaneClient
func (*ControlPlaneClient) Close ¶
func (c *ControlPlaneClient) Close() error
func (*ControlPlaneClient) Connect ¶
func (c *ControlPlaneClient) Connect(ctx context.Context) error
func (*ControlPlaneClient) GetConfig ¶
func (c *ControlPlaneClient) GetConfig() *pb.ConfigUpdate
func (*ControlPlaneClient) Register ¶
func (c *ControlPlaneClient) Register(ctx context.Context) (*pb.RegistrationResponse, error)
func (*ControlPlaneClient) StartConfigStream ¶
func (c *ControlPlaneClient) StartConfigStream(ctx context.Context) (<-chan struct{}, <-chan error, error)
type ControlPlaneConfig ¶
type ControlPlaneConfig struct {
Address string `yaml:"address"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Proxy struct, a reverse proxy reference and a config reference
func NewHandler ¶
Builds a new Handler
type Metrics ¶
type Metrics struct {
// Counter for the total number of requests (by service and status code)
RequestsTotal *prometheus.CounterVec
// Tracks request latency distribution
RequestDuration *prometheus.HistogramVec
// Tracks how many requests are currently being handled by the proxy
RequestsInFlight prometheus.Gauge
// Tracks the number of errors (by type)
ErrorsTotal *prometheus.CounterVec
}
func NewMetrics ¶
func NewMetrics() *Metrics
func (*Metrics) DecInFlight ¶
func (m *Metrics) DecInFlight()
Decrement the number of requests in flight
func (*Metrics) IncInFlight ¶
func (m *Metrics) IncInFlight()
Increment the number of requests in flight
func (*Metrics) RecordError ¶
Record an error (by service and type)
type ProxyConfig ¶
type ProxyConfig struct {
ID string `yaml:"id"`
Version string `yaml:"version"`
ListenPort int `yaml:"listen_port"`
AdvertiseAddr string `yaml:"advertise_addr"`
Backend BackendConfig `yaml:"backend"`
Timeout TimeoutConfig `yaml:"timeout"`
}
Click to show internal directories.
Click to hide internal directories.