upstream

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnavailable = errors.New("upstream: unavailable")
)

Errors

Functions

This section is empty.

Types

type H2CTransport added in v0.9.0

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

H2CTransport type

func (*H2CTransport) RoundTrip added in v0.9.0

func (t *H2CTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implement http.RoundTripper

type HTTPSTransport added in v0.9.0

type HTTPSTransport struct {
	DialTimeout           time.Duration
	TCPKeepAlive          time.Duration
	DisableKeepAlives     bool
	MaxConn               int
	MaxIdleConns          int
	IdleConnTimeout       time.Duration
	ResponseHeaderTimeout time.Duration
	TLSClientConfig       *tls.Config
	// contains filtered or unexported fields
}

HTTPSTransport type

func (*HTTPSTransport) RoundTrip added in v0.9.0

func (t *HTTPSTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implement http.RoundTripper

type HTTPTransport added in v0.9.0

type HTTPTransport struct {
	DialTimeout           time.Duration
	TCPKeepAlive          time.Duration
	DisableKeepAlives     bool
	MaxConn               int
	MaxIdleConns          int
	IdleConnTimeout       time.Duration
	ResponseHeaderTimeout time.Duration
	// contains filtered or unexported fields
}

HTTPTransport type

func (*HTTPTransport) RoundTrip added in v0.9.0

func (t *HTTPTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implement http.RoundTripper

type RoundRobinLoadBalancer added in v0.9.0

type RoundRobinLoadBalancer struct {
	Targets []*Target
	// contains filtered or unexported fields
}

RoundRobinLoadBalancer strategy

func NewRoundRobinLoadBalancer added in v0.9.0

func NewRoundRobinLoadBalancer(targets []*Target) *RoundRobinLoadBalancer

NewRoundRobinLoadBalancer creates new round-robin load balancer

func (*RoundRobinLoadBalancer) RoundTrip added in v0.9.0

func (l *RoundRobinLoadBalancer) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip sends a request to upstream server

type Target added in v0.9.0

type Target struct {
	Host      string
	Transport http.RoundTripper
}

Target is the load balancer target

type UnixTransport added in v0.9.0

type UnixTransport struct {
	DisableKeepAlives     bool
	MaxIdleConns          int
	IdleConnTimeout       time.Duration
	ResponseHeaderTimeout time.Duration
	// contains filtered or unexported fields
}

UnixTransport type

func (*UnixTransport) RoundTrip added in v0.9.0

func (t *UnixTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implement http.RoundTripper

type Upstream

type Upstream struct {
	Transport     http.RoundTripper
	ErrorLog      *log.Logger
	Host          string // override host
	Path          string // target prefix path
	Retries       int
	BackoffFactor time.Duration
}

Upstream controls request flow to upstream server via load balancer

func New

func New(transport http.RoundTripper) *Upstream

New creates new upstream

func SingleHost added in v0.2.0

func SingleHost(host string, transport http.RoundTripper) *Upstream

SingleHost creates new single host upstream

func (*Upstream) RoundTrip added in v0.7.0

func (m *Upstream) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip wraps transport round-trip

func (Upstream) ServeHandler

func (m Upstream) ServeHandler(h http.Handler) http.Handler

ServeHandler implements middleware interface

Jump to

Keyboard shortcuts

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