lb

package
v0.0.0-...-dbd2ff8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	BackendConfig
	BackendControl
	sync.RWMutex
}

Backend structure

func NewBackend

func NewBackend(backendConfig BackendConfig) *Backend

func (*Backend) HeartCheck

func (b *Backend) HeartCheck()

Monitoring the backend, can add or remove if heartbeat fail

type BackendConfig

type BackendConfig struct {
	Name      string `json:"name"`
	Address   string `json:"address"`
	Heartbeat string `json:"heartbeat"`
	HBMethod  string `json:"hbmethod"`

	ActiveAfter   int `json:"activeAfter"`
	InactiveAfter int `json:"inactiveAfter"` // Consider inactive after max inactiveAfter
	Weight        int `json:"weigth"`

	HeartbeatTime time.Duration `json:"heartbeatTime"` // Heartbeat time if health
	RetryTime     time.Duration `json:"retryTime"`     // Retry to time after failed
}

BackendConfig it's the configuration loaded

type BackendControl

type BackendControl struct {
	Failed bool // The last request failed
	Active bool

	InactiveTries int
	ActiveTries   int
	Score         int
}

BackendControl keep the control data

type Backends

type Backends []*Backend

type BackendsConfig

type BackendsConfig []BackendConfig

type Configuration

type Configuration struct {
	GeneralConfig   `json:"general"`
	FrontendsConfig `json:"frontends"`
}

type Frontend

type Frontend struct {
	FrontendConfig
	Backends
	sync.RWMutex
}

Frontend structure

func NewFrontend

func NewFrontend(frontendConfig FrontendConfig) *Frontend

type FrontendConfig

type FrontendConfig struct {
	Name           string        `json:"name"`
	Host           string        `json:"host"`
	Port           int           `json:"port"`
	Route          string        `json:"route"`
	Timeout        time.Duration `json:"timeout"`
	BackendsConfig `json:"backends"`
}

FrontendConfig it's the configuration loaded

type Frontends

type Frontends []*Frontend

type FrontendsConfig

type FrontendsConfig []FrontendConfig

type GeneralConfig

type GeneralConfig struct {
	MaxProcs         int    `json:"maxProcs"`
	WorkerPoolSize   int    `json:"workerPoolSize"`
	GracefulShutdown bool   `json:"gracefulShutdown"`
	Websocket        bool   `json:"websocket"`
	LogLevel         string `json:"logLevel"` // Need to define how it works
	RPCHost          string `json:"rpchost"`
	RPCPort          int    `json:"rpcport"`
}

type SSLBRequest

type SSLBRequest struct {
	Header   http.Header
	Status   int
	Body     []byte
	Upgraded bool
	Backend  *Backend
}

func NewWorkerRequest

func NewWorkerRequest(status int, header http.Header, body []byte) SSLBRequest

func NewWorkerRequestErr

func NewWorkerRequestErr(status int, body []byte) SSLBRequest

func NewWorkerRequestUpgraded

func NewWorkerRequestUpgraded() SSLBRequest

func (*SSLBRequest) HijackWebSocket

func (s *SSLBRequest) HijackWebSocket(w http.ResponseWriter, r *http.Request)

type SSLBRequestChan

type SSLBRequestChan chan SSLBRequest

type Server

func NewServer

func NewServer(configuration Configuration) *Server

func (*Server) Run

func (s *Server) Run()

func (*Server) RunFrontendServer

func (s *Server) RunFrontendServer(frontend *Frontend)

Lets run the frontned

func (*Server) Stop

func (s *Server) Stop()

type ShutdownChan

type ShutdownChan chan bool

type Worker

type Worker struct {
	Idle bool
	sync.RWMutex
}

func NewWorker

func NewWorker() *Worker

func (*Worker) Run

func (w *Worker) Run(r *http.Request, frontend *Frontend) SSLBRequestChan

type WorkerPool

type WorkerPool struct {
	Configuration
	Workers
	sync.RWMutex
}

func NewWorkerPool

func NewWorkerPool(configuration Configuration) *WorkerPool

func (*WorkerPool) CountIdle

func (wp *WorkerPool) CountIdle() int

func (*WorkerPool) Get

func (wp *WorkerPool) Get(r *http.Request, frontend *Frontend) SSLBRequestChan

type Workers

type Workers []*Worker

Jump to

Keyboard shortcuts

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