balancer

package
v0.0.0-...-c8b15d8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendServer

type BackendServer struct {
	Addr           protocols.Addr
	Client         protocols.CircuitBreaker
	Sessions       map[*BalancingSession]bool
	Plugin         *BalancingPlugin
	BackupSessions uint
	Load           float64 // 1 per session + backup_session_weight per backup session
}

func (*BackendServer) String

func (server *BackendServer) String() string

type BackendServerSlice

type BackendServerSlice []*BackendServer

func (BackendServerSlice) Len

func (slice BackendServerSlice) Len() int

Implement sort.Interface

func (BackendServerSlice) Less

func (slice BackendServerSlice) Less(i, j int) bool

func (BackendServerSlice) Sort

func (slice BackendServerSlice) Sort()

func (BackendServerSlice) Swap

func (slice BackendServerSlice) Swap(i, j int)

type BalancingPlugin

type BalancingPlugin struct {
	Server         *protocols.PluginServer
	BackendServers BackendServerSlice
	// contains filtered or unexported fields
}

func NewBalancingPlugin

func NewBalancingPlugin(handler BalancingPluginHandler, make_detector FaultDetectorFactory) *BalancingPlugin

func (*BalancingPlugin) AddBackendServer

func (plugin *BalancingPlugin) AddBackendServer(addr string, callback protocols.FaultDetectorCallback) error

func (*BalancingPlugin) NewSession

func (*BalancingPlugin) Start

func (plugin *BalancingPlugin) Start(server *protocols.PluginServer)

func (*BalancingPlugin) Stop

func (plugin *BalancingPlugin) Stop() error

type BalancingPluginHandler

type BalancingPluginHandler interface {
	NewClient(detector protocols.FaultDetector) (protocols.CircuitBreaker, error)
	Protocol() protocols.Protocol

	// Create and fully initialize new session. The param data is passed from
	// plugin to plugin, enabling one plugin to modify the input data for the next plugin.
	// Modify param if necessary and copy values from it. Do not store it.
	NewSession(balancingSession *BalancingSession, param protocols.SessionParameter) (BalancingSessionHandler, error)
}

type BalancingSession

type BalancingSession struct {
	Client         string
	Plugin         *BalancingPlugin
	SendingSession protocols.PluginSessionHandler
	Handler        BalancingSessionHandler

	PrimaryServer *BackendServer
	BackupServers BackendServerSlice
	// contains filtered or unexported fields
}

func (*BalancingSession) Cleanup

func (session *BalancingSession) Cleanup() error

func (*BalancingSession) LogServerError

func (session *BalancingSession) LogServerError(err error)

func (*BalancingSession) Start

func (session *BalancingSession) Start(sendingSession protocols.PluginSessionHandler)

func (*BalancingSession) StopContainingSession

func (session *BalancingSession) StopContainingSession() error

func (*BalancingSession) String

func (session *BalancingSession) String() string

func (*BalancingSession) Tasks

func (session *BalancingSession) Tasks() []golib.Task

type BalancingSessionHandler

type BalancingSessionHandler interface {
	StopRemote() error
	RedirectStream(newHost string, newPort int) error
	HandleServerFault() (*BackendServer, error)
}

type FaultDetectorFactory

type FaultDetectorFactory func(endpoint string) (protocols.FaultDetector, error)

Jump to

Keyboard shortcuts

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