upstream

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllSessions

func AllSessions() map[string]*Sessions

func RemoveBackend

func RemoveBackend(cmb *BackendCombined) (onLast bool)

func UpsertBackend

func UpsertBackend(cmb *BackendCombined) (onFirst bool, err error)

Types

type Backend

type Backend struct {
	ID        string  `json:"id"`     // backend server id(name)
	IP        string  `json:"ip"`     // backend server ip
	Port      uint64  `json:"port"`   // backend server port
	Scheme    string  `json:"scheme"` // http / https, auto detect & setup by httpProxy
	Version   string  `json:"version"`
	Weight    float64 `json:"weihgt"`
	CleanName string  `json:"clean_name"` // backend server clean id(name)
}

Backend

func GetBackend

func GetBackend(ups, backend string) *Backend

func (*Backend) Addr

func (b *Backend) Addr() string

type BackendCombined

type BackendCombined struct {
	*Upstream `json:"upstream"`
	*Backend  `json:"backend"`
}

BackendCombined

func Lookup

func Lookup(remoteIP, ups, backend string) *BackendCombined

lookup select a suitable backend according by sessions & balancer

func LookupAlias

func LookupAlias(remoteIP, alias string) *BackendCombined

similar as lookup, but by upstream alias

func LookupListen

func LookupListen(remoteIP, listen string) *BackendCombined

similar as lookup, but by upstream listen

func (*BackendCombined) Valid

func (cmb *BackendCombined) Valid() error

type BackendEvent

type BackendEvent struct {
	Action string // add/del/update
	*BackendCombined
}

BackendEvent

func BuildBackendEvent

func BuildBackendEvent(act, ups, alias, listen, backend, ip, ver string, port uint64, weight float64) *BackendEvent

func (*BackendEvent) Format

func (ev *BackendEvent) Format()

func (*BackendEvent) String

func (ev *BackendEvent) String() string

type Balancer

type Balancer interface {
	Next([]*Backend) *Backend
}

type Sessions

type Sessions struct {
	sync.RWMutex // protect m
	// contains filtered or unexported fields
}

Sessions

func (*Sessions) MarshalJSON

func (s *Sessions) MarshalJSON() ([]byte, error)

type UpsManager

type UpsManager struct {
	Upstreams []*Upstream `json:"upstreams"`
	sync.RWMutex
}

Type & Method Definitions ...

type Upstream

type Upstream struct {
	Name     string     `json:"name"`     // uniq name
	Alias    string     `json:"alias"`    // advertised url
	Listen   string     `json:"listen"`   // listen addr
	Backends []*Backend `json:"backends"` // backend servers
	// contains filtered or unexported fields
}

func AllUpstreams

func AllUpstreams() []*Upstream

Exported Functions ....

func GetUpstream

func GetUpstream(ups string) *Upstream

Jump to

Keyboard shortcuts

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