2017-04-01 04:19:50 +00:00
|
|
|
package server
|
2017-03-20 00:04:47 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
//Status --
|
|
|
|
type Status struct {
|
|
|
|
ctx context.Context
|
|
|
|
Name string
|
|
|
|
StartTime time.Time
|
|
|
|
WssDomain string
|
|
|
|
AdminDomain string
|
|
|
|
DeadTime *StatusDeadTime
|
|
|
|
ConnectionTracking *Tracking
|
|
|
|
ConnectionTable *Table
|
2020-04-28 06:26:00 +00:00
|
|
|
servers *Servers
|
2017-03-20 00:04:47 +00:00
|
|
|
LoadbalanceDefaultMethod string
|
|
|
|
AdminStats *TrafficStats
|
2017-03-23 23:10:49 +00:00
|
|
|
AdminReqTyoe *AdminReqType
|
2017-03-20 00:04:47 +00:00
|
|
|
TrafficStats *TrafficStats
|
|
|
|
ExtConnections *ConnectionStats
|
|
|
|
WSSConnections *ConnectionStats
|
|
|
|
}
|
|
|
|
|
|
|
|
//NewStatus --
|
|
|
|
func NewStatus(ctx context.Context) (p *Status) {
|
|
|
|
p = new(Status)
|
|
|
|
p.ctx = ctx
|
|
|
|
p.AdminStats = new(TrafficStats)
|
|
|
|
p.TrafficStats = new(TrafficStats)
|
|
|
|
p.ExtConnections = new(ConnectionStats)
|
|
|
|
p.WSSConnections = new(ConnectionStats)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// South Facing Functions
|
|
|
|
|
|
|
|
//WSSConnectionRegister --
|
|
|
|
func (p *Status) WSSConnectionRegister(newRegistration *Registration) {
|
|
|
|
p.ConnectionTable.Register() <- newRegistration
|
|
|
|
p.WSSConnections.IncConnections()
|
|
|
|
}
|
|
|
|
|
|
|
|
//WSSConnectionUnregister --
|
|
|
|
//unregisters a south facing connection
|
|
|
|
//intercept and update global statistics
|
|
|
|
func (p *Status) WSSConnectionUnregister() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// External Facing Functions
|
|
|
|
|
|
|
|
//ExtConnectionRegister --
|
|
|
|
//registers an ext facing connection
|
|
|
|
//intercept and update global statistics
|
|
|
|
func (p *Status) ExtConnectionRegister(newTrack *Track) {
|
|
|
|
p.ConnectionTracking.register <- newTrack
|
|
|
|
p.ExtConnections.IncConnections()
|
|
|
|
}
|
|
|
|
|
|
|
|
//ExtConnectionUnregister --
|
|
|
|
//unregisters an ext facing connection
|
|
|
|
//intercept and update global statistics
|
|
|
|
func (p *Status) ExtConnectionUnregister(extConn *WedgeConn) {
|
|
|
|
p.ConnectionTracking.unregister <- extConn
|
|
|
|
p.ExtConnections.DecConnections()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//SendExtRequest --
|
|
|
|
//sends a request to a south facing connection
|
|
|
|
//intercept the send, update our global stats
|
|
|
|
func (p *Status) SendExtRequest(conn *Connection, sendTrack *SendTrack) {
|
|
|
|
p.TrafficStats.IncRequests()
|
|
|
|
p.TrafficStats.AddBytesOut(int64(len(sendTrack.data)))
|
|
|
|
conn.SendCh() <- sendTrack
|
|
|
|
}
|