core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const MAX_HEADER_SIZE = 16385
View Source
const MaxTicks = 40

MaxTicks defines the length of the stats for the UI

Variables

This section is empty.

Functions

func HttpHostHeader

func HttpHostHeader(br *bufio.Reader) string

HttpHostHeader returns the HTTP Host header from br without consuming any of its bytes. It returns "" if it can't find one.

func Proxy

func Proxy(to BufferedConn, from BufferedConn) <-chan bool

func Sniff

func Sniff(conn net.Conn, readTimeout time.Duration) (net.Conn, string, error)

Sniff sniffs hostname from ClientHello message (if any), returns sni.Conn, filling it's Hostname field

Types

type BufferedConn

type BufferedConn struct {
	Reader *bufio.Reader
	net.Conn
}

func NewBufferedConn

func NewBufferedConn(c net.Conn) BufferedConn

func (BufferedConn) Peek

func (b BufferedConn) Peek(n int) ([]byte, error)

func (BufferedConn) Read

func (b BufferedConn) Read(p []byte) (int, error)

type Cluster

type Cluster struct {
	Key         string
	RouterHosts map[string]*RouterHost
	Routes      map[string]Route
}

func NewCluster

func NewCluster(key string, routes map[string]Route) *Cluster

func (*Cluster) Stop

func (c *Cluster) Stop()

type ClusterUpdate

type ClusterUpdate struct {
	Routes      map[string]Route      `json:"routes"`
	RouterHosts map[string]RouterHost `json:"routerHosts"`
}

type Conn

type Conn struct {
	net.Conn //delegate
	// contains filtered or unexported fields
}

Conn delegates all calls to net.Conn, but Read to reader

func (Conn) Read

func (c Conn) Read(b []byte) (n int, err error)

type Context

type Context struct {
	HTTPS    bool
	Hostname string
	Conn     BufferedConn
}

type GlobalStats

type GlobalStats struct {
	Mutation           string                         `json:"mutation"`
	Hosts              map[string]RouterHostWithStats `json:"hosts"`
	Ticks              []string                       `json:"ticks"`
	OverallConnections []uint                         `json:"overallConnections"`
	UnhealthyHosts     []int                          `json:"unhealthyHosts"`
	HealthyHosts       []int                          `json:"healthyHosts"`
}

type HealthCheck

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

func NewHealthCheck

func NewHealthCheck(routerHost *RouterHost, checkPort int,
	status chan HealthCheckResult, checkInterval time.Duration) *HealthCheck

func (*HealthCheck) Start

func (hc *HealthCheck) Start()

func (*HealthCheck) Stop

func (hc *HealthCheck) Stop()

type HealthCheckResult

type HealthCheckResult struct {
	RouterHost *RouterHost
	Healthy    bool
}

type HostStats

type HostStats struct {
	Healthy            bool   `json:"healthy"`
	TotalConnections   int64  `json:"totalConnections"`
	ActiveConnections  uint   `json:"activeConnections"`
	RefusedConnections uint64 `json:"refusedConnections"`
}

type ReadWriteCount

type ReadWriteCount struct {
	CountRead  uint
	CountWrite uint
}

func (ReadWriteCount) IsZero

func (rwc ReadWriteCount) IsZero() bool

type Route

type Route struct {
	URL    string `json:"url"`
	Weight int    `json:"weight"`
}

type RouterHost

type RouterHost struct {
	ClusterKey string
	Name       string `json:"name"`
	HostIP     string `json:"hostIP"`
	HTTPPort   int    `json:"httpPort"`
	HTTPSPort  int    `json:"httpsPort"`
	LastState  HostStats
	// contains filtered or unexported fields
}

func NewRouterHost

func NewRouterHost(name string, ip string, httpPort int, httpsPort int, s chan HealthCheckResult, clusterKey string) *RouterHost

func (*RouterHost) Start

func (rh *RouterHost) Start()

func (*RouterHost) Stop

func (rh *RouterHost) Stop()

type RouterHostWithStats

type RouterHostWithStats struct {
	ClusterKey string      `json:"clusterKey"`
	HostIP     string      `json:"hostIP"`
	HTTPPort   int         `json:"httpPort"`
	HTTPSPort  int         `json:"httpsPort"`
	Stats      []HostStats `json:"stats"`
}

Jump to

Keyboard shortcuts

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