Documentation ¶
Index ¶
- type Backend
- type BackendConfig
- type BackendControl
- type Backends
- type BackendsConfig
- type Configuration
- type Frontend
- type FrontendConfig
- type Frontends
- type FrontendsConfig
- type GeneralConfig
- type SSLBRequest
- type SSLBRequestChan
- type Server
- type ShutdownChan
- type Worker
- type WorkerPool
- type Workers
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 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 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 ¶
type Server struct { Configuration Frontends ShutdownChan *WorkerPool sync.Mutex *sync.WaitGroup }
func NewServer ¶
func NewServer(configuration Configuration) *Server
func (*Server) RunFrontendServer ¶
Lets run the frontned
type ShutdownChan ¶
type ShutdownChan chan bool
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
Click to show internal directories.
Click to hide internal directories.