backend

package
v0.0.0-...-1f713e5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOk          = "OK"
	StatusDegraded    = "DEGRADED"
	StatusCritical    = "CRITICAL"
	StatusMaintenance = "MAINTENANCE"
	StatusUnknown     = "UNKNOWN"
)
View Source
const (
	Tstartup = 60   // Startup time in seconds
	Kstartup = 4096 // Maximum slow start cost
)

Variables

This section is empty.

Functions

func IsValidStatus

func IsValidStatus(s string) bool

func StatusWeight

func StatusWeight(s string) uint32

Types

type ConnectionMetrics

type ConnectionMetrics struct {
	ActiveConnections uint32
	TotalConnections  uint64
}

func NewConnectionMetrics

func NewConnectionMetrics() ConnectionMetrics

func (*ConnectionMetrics) ConnectionDone

func (c *ConnectionMetrics) ConnectionDone()

func (*ConnectionMetrics) ConnectionStart

func (c *ConnectionMetrics) ConnectionStart()

func (*ConnectionMetrics) GetActiveConnections

func (c *ConnectionMetrics) GetActiveConnections() uint32

func (*ConnectionMetrics) GetTotalConnections

func (c *ConnectionMetrics) GetTotalConnections() uint64

type Pool

type Pool struct {
	Name    string
	Dummy   bool
	Servers map[string]*Server
	Config  PoolConfig

	Metrics ConnectionMetrics
	// contains filtered or unexported fields
}

func DummyPool

func DummyPool(name string) *Pool

func NewPool

func NewPool(name string, config PoolConfig) *Pool

func (*Pool) AddServer

func (p *Pool) AddServer(name string, server *Server)

func (*Pool) DelServer

func (p *Pool) DelServer(name string)

func (*Pool) Handle

func (p *Pool) Handle(logRecord *logger.HAProxyLogRecord)

func (Pool) Next

func (p Pool) Next() *Server

func (*Pool) Reconfigure

func (p *Pool) Reconfigure(config PoolConfig)

func (*Pool) RunChecks

func (p *Pool) RunChecks()

func (*Pool) Shutdown

func (p *Pool) Shutdown()

type PoolConfig

type PoolConfig struct {
	HealthzEvery   time.Duration
	HealthzTimeout time.Duration
	RequestTimeout time.Duration
	Status         string
}

type ResponseError

type ResponseError struct {
	Response *http.Response
	Error    error
}

type Server

type Server struct {
	Address   string
	Status    ServerStatus
	Metrics   ServerMetrics
	Transport *http.Transport
}

func NewServer

func NewServer(address string) *Server

func (*Server) CheckStatus

func (s *Server) CheckStatus(tout time.Duration)

func (*Server) Cost

func (s *Server) Cost(accept string) uint32

func (*Server) Handle

func (s *Server) Handle(logRecord *logger.HAProxyLogRecord, tout time.Duration)

func (*Server) RoundTrip

func (s *Server) RoundTrip(req *http.Request, ch chan ResponseError)

type ServerMetrics

type ServerMetrics struct {
	RequestsInFlight uint32
	RequestsServiced uint64
}

func NewServerMetrics

func NewServerMetrics() ServerMetrics

func (*ServerMetrics) Cost

func (s *ServerMetrics) Cost() uint32

func (*ServerMetrics) RequestDone

func (s *ServerMetrics) RequestDone()

func (*ServerMetrics) RequestStart

func (s *ServerMetrics) RequestStart()

type ServerStatus

type ServerStatus struct {
	Current string
	Checked time.Time
	Changed time.Time
}

func NewServerStatus

func NewServerStatus() ServerStatus

func (*ServerStatus) Cost

func (s *ServerStatus) Cost(accept string) uint32

func (*ServerStatus) ParseAndSet

func (s *ServerStatus) ParseAndSet(res *http.Response) bool

func (*ServerStatus) Set

func (s *ServerStatus) Set(status string) bool

Returns a bool representing if the status changed

func (*ServerStatus) SlowStartFactor

func (s *ServerStatus) SlowStartFactor() uint32

Jump to

Keyboard shortcuts

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