rproxy

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PLUGINPATH string

PLUGINPATH can be set by linker to define a default proxy module dir

View Source
var RIDHEADER string

RIDHEADER can be by linker to define the default HTTP header for request id (Defaults to "X-Request-ID")

View Source
var RIDKEY string

RIDKEY can be set by linker to define the default log key for request id (default to "rid")

Functions

func RegisterReverseProxyModule

func RegisterReverseProxyModule(typename string, initfunc func(jconf.SubConfig) (rproxymod.ProxyModule, error))

RegisterReverseProxyModule registers an initalization function for a reverse proxy module under a type name, so it can be used in the config. If a "ReverseProxy" handler is configured with this module type name, the supplied init function is called with the module config.

Types

type HealthCheckConfig

type HealthCheckConfig struct {
	Interval jconf.Duration
	URIPath  string
	Timeout  jconf.Duration
	Expect   int
}

type ModuleConfig

type ModuleConfig struct {
	Type   string
	Config *jconf.MandatorySubConfig
}

ModuleConfig configures a rproxy module.

type OzoneProxy

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

OzoneProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client. It's build upon the standard library ReverseProxy, but allows for plugin modules to process incoming requests and to modify responses and to proxy to a "virtual transport" consisting of multiple backend HTTP servers. Incoming request processing modules can pick a destination like the stdlib "Director" function but in general control every aspect of the proxy behavior.

func NewProxy

func NewProxy(name string, js jconf.SubConfig) (proxy *OzoneProxy, err error)

NewProxy instantiates a new reverse proxy handler based on the provided JSON config

func (*OzoneProxy) Deinit

func (p *OzoneProxy) Deinit() error

Deinit is a function hook invoked when the associated HTTP server receives a shutdown signal

func (*OzoneProxy) ServeHTTP

func (p *OzoneProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements stdlib http.Handler

func (*OzoneProxy) Service

func (p *OzoneProxy) Service() *proxyservice

Service returns any activity object the proxy might want to perform. To start the activity, call Serve(context) on the returned object. The activity will run to the context is canceled.

type ProxyConfig

type ProxyConfig struct {
	Transport   *TransportConfig
	ModuleDir   string
	Modules     map[string]ModuleConfig
	ModuleOrder []string
	Cache       *jconf.OptionalSubConfig
}

ProxyConfig defines JSON configuration for the "ReverseProxy" handler type

type RRUpstreamConfig

type RRUpstreamConfig struct {
	MaxFails         int
	Quarantine       jconf.Duration
	BackendPin       jconf.Duration
	BurstFailGrace   jconf.Duration
	RoutingKeyHeader string
	HealthCheck      *HealthCheckConfig
}

type TransportConfig

type TransportConfig struct {
	Type                string
	Config              *jconf.OptionalSubConfig
	TLS                 *tlsconf.TLSClientConfig
	MaxIdleConns        int
	MaxIdleConnsPerHost int
	IdleConnTimeout     jconf.Duration

	// close the connection after this amount of time without traffic.
	IOActivityTimeout jconf.Duration

	TLSHandshakeTimeout   jconf.Duration
	ResponseHeaderTimeout jconf.Duration
	DisableKeepAlives     bool
	DisableCompression    bool
}

TransportConfig defines JSON for configuring the HTTP transport used by the proxy. Type "Virtual" enabled the virtual transport which recognizes the URI scheme "vt:<name>" to refer to a named target cluster of multiple backends as destination.

type VirtualTransportConfig

type VirtualTransportConfig struct {
	Type      string
	Retries   int
	Upstreams map[string][]string
	Config    *jconf.OptionalSubConfig
	// Legacy
	MaxFails         int
	Quarantine       jconf.Duration
	BackendPin       jconf.Duration
	RoutingKeyHeader string
}

VirtualTransport defines JSON for configuring a virtual backend transport. Multiple named virtual upstreams can be defined as an array of "scheme://host:port/" URIs Requests are send to the hosts in a virtual upstream in a RR manner, but if the request contains a RoutingKey Header a specific backend host will be used for all req. with the same Header for "BackendPin" duration. This can be used to ensure backend caches are used optimally. If a host has MaxFails errors it will be put in Quarantine and request will be routes to a different host.

Directories

Path Synopsis
module

Jump to

Keyboard shortcuts

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